You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trympet
changed the title
Coverlet doesn't collect coverage for modules referencing ThisClass.*
Coverlet doesn't collect coverage for modules referencing ThisAssembly.*
Jan 9, 2023
Describe the Bug
Generated files are not excluded from code coverage, causing Coverlet coverage collection to fail for any module that contains generated sources.
Coverlet error:
TpTrace Verbose: 0 : 22984, 1, 2023/01/09, 18:02:20.108, 21604793925156, datacollector.dll, [coverlet]Unable to instrument module: C:\Users\trym\source\repos\FizzBuzz\bin\FizzBuzz.dll, pdb without local source files, [C:\Users\trym\source\repos\FizzBuzz\src\FizzBuzz\FizzBuzz\ThisAssembly.AssemblyInfo\ThisAssembly.AssemblyInfoGenerator\ThisAssembly.Info.cs]
If the source generator emits files using the
g.cs
-suffix, Coverlet ignores the file [1], thus, the fix is trivial.I'd be happy to submit a PR to resolve the issue! 😄
Steps to Reproduce
dotnet test /v:q /nologo --results-directory TestResults --logger "trx" --collect:"XPlat Code Coverage" --diag:log.txt
TestResults\[...]\coverage.cobertura.xml
contains no reference to the module under test. Observe the error inlog.datacollector[...].txt
.Expected Behavior
The generator should
a) emit files using a
g.cs
-suffix, orb) decorate any generated files with the ExcludeFromCodeCoverage-attribute.
Version Info
ThisAssembly.AssemblyInfo version 1.0.10.
coverlet.collector version 3.2.0
Additional Info
[1] - coverlet-coverage/coverlet#1084 (comment)
The text was updated successfully, but these errors were encountered: