Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverlet doesn't collect coverage for modules referencing ThisAssembly.* #159

Closed
trympet opened this issue Jan 9, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@trympet
Copy link

trympet commented 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

  1. Create a new NUnit/xUnit test project.
  2. dotnet test /v:q /nologo --results-directory TestResults --logger "trx" --collect:"XPlat Code Coverage" --diag:log.txt
  3. 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)

@trympet trympet added the bug Something isn't working label Jan 9, 2023
@trympet 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
@viceroypenguin
Copy link
Contributor

viceroypenguin commented Jan 9, 2023

If you update to v1.1.1, ThisAssembly.AssemblyInfo has already changed the generated file to ThisAssembly.AssemblyInfo.g.cs

@trympet
Copy link
Author

trympet commented Jan 9, 2023

If you update to v1.1.1, ThisAssembly.AssemblyInfo has already changed the generated file to ThisAssembly.AssemblyInfo.g.cs

Awesome, thanks! 😁

Fixed by #132

@trympet trympet closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants