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
- Create a new NUnit/xUnit test project.
dotnet test /v:q /nologo --results-directory TestResults --logger "trx" --collect:"XPlat Code Coverage" --diag:log.txt
- Observe that
TestResults\[...]\coverage.cobertura.xml contains no reference to the module under test. Observe the error in log.datacollector[...].txt.
Expected Behavior
The generator should
a) emit files using a g.cs-suffix, or
b) 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)
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.txtTestResults\[...]\coverage.cobertura.xmlcontains 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)