coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

Improve coverage for edge cases

Open MarcoRossignoli opened this issue 5 years ago • 4 comments

Take a look at @sharwell comment here https://github.com/dotnet/roslyn-analyzers/pull/3478#issuecomment-609793303

MarcoRossignoli avatar Apr 07 '20 12:04 MarcoRossignoli

Can I work on this? Could you assign it to me.

daveMueller avatar Jun 10 '20 23:06 daveMueller

Sure, let me know if you need help with test coverage debug, I usually work with ILSpy to inspect instrumentation on IL . Thanks.

MarcoRossignoli avatar Jun 11 '20 06:06 MarcoRossignoli

There are two issues here:

  1. A empty line in a lambda body is reported as covered.
  2. 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.

02_Multiline

So the IL code for the conditional operator in line 12-14 looks like this:

01_Multiline

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.

daveMueller avatar Aug 22 '20 23:08 daveMueller