Extract constant value of enum member equal clauses#4309
Extract constant value of enum member equal clauses#4309hvitved merged 4 commits intogithub:mainfrom
Conversation
| ? Expression.ValueAsString(constValue.Value) | ||
| : null; | ||
|
|
||
| var expr = new Expression(new ExpressionInfo( |
There was a problem hiding this comment.
Why aren't we extracting the expression itself as a subexpression?
enum MyEnum
{
A = 1+2+3,
B
}
If I read this correctly, then 1+2+3 is extracted here as a field access instead of an addition.
There was a problem hiding this comment.
You are right, we could extract that.
There was a problem hiding this comment.
It probably doesn't matter too much. One case that might be interesting if the constant expression contains a reference to a constant and in some check we need all the references to that constant.
3d89fe9 to
d862725
Compare
6bf42e5 to
b36b213
Compare
| # 40| 1: [MemberConstantAccess] access to constant AnotherBlue | ||
| # 40| 1: [AssignExpr] ... = ... | ||
| # 40| 0: [AddExpr] ... + ... | ||
| # 40| 0: [CastExpr] (...) ... |
There was a problem hiding this comment.
@hvitved These casts look a bit strange. How come we have no TypeAccess below these nodes?
b36b213 to
f17eee0
Compare
hvitved
left a comment
There was a problem hiding this comment.
LGTM. Let's run a CSharp-Differences job before we merge though.
|
C# differences job: https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/457/ |
@hvitved The differences job shows this change didn't work out as expected in |
|
Pushed a fix to this PR and restarted the differences job: https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/460/ |
|
The differences job looks good now. I don't understand why the two findings with |
7724f43 to
a635503
Compare
No description provided.