Improve coverage for edge cases
Take a look at @sharwell comment here https://github.com/dotnet/roslyn-analyzers/pull/3478#issuecomment-609793303
Can I work on this? Could you assign it to me.
Sure, let me know if you need help with test coverage debug, I usually work with ILSpy to inspect instrumentation on IL . Thanks.
There are two issues here:
- A empty line in a lambda body is reported as covered.
- A multiline conditional operator is reported as each line covered even if only one branch is hit.
For the first issue I created a PR #1023 and added some explanations. The second issue is much harder and we should probably create a separate issue for this. I spent a lot of time thinking about this but I couldn't find a solution. Here is what I analyzed:
For a multiline conditional operator like in the following screenshot the compiler always generates one sequence point that spans multiple lines.
So the IL code for the conditional operator in line 12-14 looks like this:
I can figure out the instructions for the branch points but personally I don't see a way how to map these to a specific line within the range of the sequence point.