-
Notifications
You must be signed in to change notification settings - Fork 387
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
Code coverage not working with MVC/Razor applications targeting ASP.NET 6 preview 3+ #1140
Comments
As of .NET 6 preview 5, you can workaround this issue by adding the following to the <PropertyGroup>
<_UseRazorSourceGenerator>false</_UseRazorSourceGenerator>
</PropertyGroup> |
In preview 6 the workaround changes to: <PropertyGroup>
<UseRazorSourceGenerator>false</UseRazorSourceGenerator>
</PropertyGroup> |
I also tried adding an exclude of |
Also tried using Expected:
Actual:
The |
This was fixed by dotnet/sdk#18943 which will be in .NET 6 RC1, but I think this has highlighted that there's some room for improvement in how coverlet handles what it perceives to be missing source files as this is the second time I'm aware of that projects using source generators have had to be changed to get coverlet to produce any coverage output for them, this issue and #1084. |
In .NET 6 preview 3, the Razor compiler was changed to use a Roslyn source generator instead of compiling a separate
.Views
assembly (announcement).Similar to #1084, this causes coverlet to be unable to instrument the application's assembly due to seemingly missing source files emitted into the assembly/PDB for the views:
At first I thought this might have been caused by dotnet/sdk#16777, but having updated to a nightly build of the preview 4 SDK containing the fix for that issue to verify that (
6.0.100-preview.4.21210.1
), code coverage is still not reported.I'm not sure if this is an SDK issue (missing
.g.cs
suffix), a coverlet issue, or both, so I'm opening this issue here andwill open a separate issue referencing this onehave opened dotnet/sdk#16835 in the dotnet/sdk repo.To replicate the issue and generate an MSBuild binary log file with the coverlet logging present, run the following commands:
You can then open the
msbuild.binlog
file in MSBuild Structured Log Viewer and search for[coverlet]
to find the log message.The text was updated successfully, but these errors were encountered: