When looking at code coverage data with Visual Studio 2010 I see the following output under a given namespace:
SomeClass1
SomeClass2
SomeClass2.< >c__DisplayClass1
SomeClass2.< >c__DisplayClass19
SomeClass2.< >c__DisplayClass28
SomeClass3
SomeClass3.< >c__DisplayClass2F
etc
If I expand out any of the entries with "DisplayClass" in it I see that it is a method that has a lambda expression in it. Due to so many lambda expressions it is difficult to get meaningful data from the code coverage results.
Is there anyway to clean this report up?
The functions generated from a lambda expression are the direct result of the code you wrote. They may come back in the report as having a deceptively high number of lines due to the complier’s expansion, but you want to test that their behavior is correct. Therefore they should be included in the coverage report.
I also agree with the comments: code coverage shouldn't be taken as an exact measurement. I think of it as having one significant digit.
Having said all that… I think your best hope is the ExcludeFromCodeCoverage Attribute. It's fairly flexible, but is normally applied to a declaration. How you would apply it to a lambda isn't clear to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With