Lowering of value is ConstantA or ConstantB
#77278
-
In my code I had line similar to Assert(value is ConstA or ConstB); This was lowered to bool condition = ((num == 1 || num == 4) ? true : false);
Assert(condition, ...); I understand that the JIT will most likely simplify this to avoid the ternary. However, when the code-coverage tool analyzes the code, it will consider that the falsy branch is never taken (and it should not be in this case, hence the Assert). Since I actually take branch covering very seriously, the false positives due to the lowering are annoying. So, why is this code lowered this way? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 40 replies
-
Feels like this should be a Roslyn question? I don't think the language spec says anything about how exactly that code should be lowered as long as the result is the same. |
Beta Was this translation helpful? Give feedback.
-
Code coverage tools should be working on the high-level representation of code, not the lowered version. |
Beta Was this translation helpful? Give feedback.
-
It's lowered to this IL. What you see is C# code "lifted" by decompiler from IL. |
Beta Was this translation helpful? Give feedback.
-
Closing as all discussion indicates that the user is complaining about external tools (a particular decompiler, and a particular code coverage tool. No claim against Roslyn had been levied, and the user themselves indicates that the IL emitted by Roslyn is efficient and that they are not asking for a change there. As such, this is not actionable by Roslyn (as this was not actionable by the language design team). @dellamonica please report your issues with these particular tools to their respective owners. Just because you are working with c# does not mean the issue lies with the language or our compiler. -- Locking as well as this is going in circles and there doesn't seem to be any willingness to understand the distinction/responsibilities of all the pieces at play here. |
Beta Was this translation helpful? Give feedback.
Closing as all discussion indicates that the user is complaining about external tools (a particular decompiler, and a particular code coverage tool.
No claim against Roslyn had been levied, and the user themselves indicates that the IL emitted by Roslyn is efficient and that they are not asking for a change there.
As such, this is not actionable by Roslyn (as this was not actionable by the language design team).
@dellamonica please report your issues with these particular tools to their respective owners. Just because you are working with c# does not mean the issue lies with the language or our compiler.
--
Locking as well as this is going in circles and there doesn't seem to be any willi…