I'm getting c__DisplayClass files appearing in my code coverage analysis that appear to be auto generated code from closures (see this link).
My question is, HOW do you remove this auto generated code from code coverage results?
After some research, I've discovered you can make use of a .runsettings file (documentation).
You can customize your code coverage results within this file like so:
<CodeCoverage>
<ModulePaths>
<Exclude></Exclude>
</ModulePaths>
<Functions>
<Exclude>
<Function>.*c__DisplayClass.*</Function>
</Exclude>
</Functions>
</CodeCoverage>
This gave me the results I wanted. All auto generated c__DisplayClass functions are excluded from the results.
Just to add to Anthony's excellent answer, I had lots of auto generated rubbish which can be hidden neatly with the following .runsettings file:
<CodeCoverage>
<ModulePaths>
<Exclude></Exclude>
</ModulePaths>
<Functions>
<Exclude>
<Function>.*<*>.*</Function>
</Exclude>
</Functions>
</CodeCoverage>
Note that < and > are the triangular brackets < and > so this should (in my experience) cover all automatically generated code in the coverage results.
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