ademanuele / VSMac-CodeCoverage

A Visual Studio for Mac code coverage extension.
MIT License
75 stars 16 forks source link

Lambda expressions cause method to show null coverage #8

Closed cabal95 closed 3 years ago

cabal95 commented 4 years ago

First, thanks for the great tool! Not to put you out of business, but I hope Microsoft eventually builds something like this into VS for Mac directly. Until then, this has been great. Really helps when writing the tests to know that I'm not missing something in the method I'm testing.

Now for the issue. I'm not sure what to call it other than "null coverage". The method basically shows that the coverage tool doesn't really know about it. Nearly all lines are marked as neither red nor green. I've attached a small solution that demonstrates the problem.

If I comment out the indicated line with the lambda expression (in this case a Select() call), then everything works normally. I also tested with a simple Where() call instead and get the same results, so it doesn't seem to be the Select() call itself, but rather the lambda expression.

That said, I do have another method with a lamba/Where() call that does work - but it's also extremely simple method, only 3 lines, so this might be in combination with something else going on in this method, like the fact it's an async call.

Screen Shot 2020-07-04 at 2 18 46 PM

As you can see, the only line that the tool seems to think is actual code, is the one that causes the problem.

CoverageTest.zip

ademanuele commented 3 years ago

Hi.

Thanks for the issue and all the detail.

I will look into this at some point. However, it sounds like its probably an issue with the coverage gathering library itself, rather than my extension.

I have recently released a new version of the extension with the latest version of the coverage gathering library in. That may fix the issue you are seeing.

cabal95 commented 3 years ago

Thanks Arthur. I'll see if I can pull the latest version down and re-test and report back. It's been a while since I worked on the project where I first came across that.

Didn't realize you were using an internal library. If I can reproduce I'll see if I can get it reported on their tracker too.

ademanuele commented 3 years ago

Yeah the library that actually gathers the code coverage is Coverlet.

cabal95 commented 3 years ago

@ademanuele The updated version of the plugin solved the issue. I did see on the Coverlet repo that there were lots of fixed issues related to Lambdas so they must have got it sorted in the library itself. Thanks again!