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
Long story short: for all our libs that use Expressionify, coverlet does not generate coverage reports anymore. Briefly explained, coverlet does not detect the source generated by Expressionify as generated and won't instrument the assembly, as it doesn't have all the sources.
Why is this an issue with Expressionify?
If the generated source files follow a naming convention, coverlet detects the files as auto generated and magically starts working again. (see coverlet-coverage/coverlet#1084 (comment))
Fix
The file names simply have to end in .g.cs or .generated.cs
It's common to provide an explicit C# file extension such as ".g.cs" or ".generated.cs" for the name. The file name helps identify the file as being source generated.
Run test with dotnet test --collect:"XPlat Code Coverage"
At the end of the test run it outputs the path to a coverage.cobertura.xml. It is basically an empty XML at this point.
Remove [Expressionify] in Class1.cs
Rerun test
The new XML now has coverage info.
Debug output of coverlet can be retrieved with dotnet test --collect:"XPlat Code Coverage" --diag:log.txt
With the current version of Expressionify, the datacollector log contains a line [coverlet]Unable to instrument module: ... Expressionify.Coverage.dll, pdb without local source files
This is fixed once the generated source files end with .g.cs
jhartmann123
changed the title
Generated source files should be marked as auto generated
Generated source files should end with .g.cs to mark them as autogenerated
Nov 4, 2022
Source issue
Long story short: for all our libs that use Expressionify, coverlet does not generate coverage reports anymore. Briefly explained, coverlet does not detect the source generated by Expressionify as generated and won't instrument the assembly, as it doesn't have all the sources.
Why is this an issue with Expressionify?
If the generated source files follow a naming convention, coverlet detects the files as auto generated and magically starts working again. (see coverlet-coverage/coverlet#1084 (comment))
Fix
The file names simply have to end in
.g.cs
or.generated.cs
This naming convention isn't something random invented by coverlet, but is also hidden in plain sight in multiple docs. Examples:
https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview#get-started-with-source-generators
In the tip in point 6:
https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references#nullable-contexts
In the "Important"-block
The text was updated successfully, but these errors were encountered: