danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.59k stars 281 forks source link

Odd coverage reporting of compiler generated code with respect to class lexical scope #297

Closed SteveGilham closed 4 years ago

SteveGilham commented 4 years ago

I just spotted this unusual looking behaviour and wanted to at least get it on the record, even if the result is a "not worth fixing".

This coverage file coverage.opencover.xml.zip contains a class AltCover.StaticFilter that has a compiler generated member. When an HTML report is generated, some of the code associated with a lexically separate class (but actually belonging to a third, system generated, type) is shown in the HTML report here AltCover_StaticFilter.zip.

I assume that the autogenerated types <StartupCode$AltCover>.$Filter/get_Apply@48 and <StartupCode$AltCover>.$Filter/get_Apply@49-1 have been assigned to the lexically nearest type with some code location, rather than being exposed in all their weirdness to the unsuspecting consumer; but in this case, the end result does appear rather counter-intuitive.

danielpalme commented 4 years ago

I've tried to find a solution to fix this special case. There is no good way to determine that the found class is not correct for the compiler generated class. Matching the name would work here, but would break other cases in my test suite.

I'm closing this for now.