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
[BUG] Missing code coverage when there is logic that sets a default value for a parameter of a specific type #1640
Comments
Thanks for reporting and thanks for the repro. When enabling the log it can be seen that it is the same issue as #1102. The assembly To get coverage with the collector in your repro I had to do two things. Add MissingCoverage.Host.csproj <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
</Project> And additionally upgrade to |
@daveMueller, thanks for having a look in such a short time and providing a solution. What you suggested worked. |
Thanks so much for this - you saved us a ton of headaches. Interestingly enough this works fine for us on |
Describe the bug
There is no code coverage in a
Web
project when there is logic that sets the default value for a parameter of typeMicrosoft.Extensions.DependencyInjection.ServiceLifetime
.To Reproduce
MissingCoverage.zip
I've attached a sample project where the issue can be reproduced. By removing the
serviceLifetime
default value fromCheckLifetime
code coverage works.Expected behavior
To see project code coverage.
Actual behavior
The code coverage is simply missing in the project, there is no error, the test gets executed.
Configuration (please complete the following information):
The project is written in
.NET 6
, the tests project hascoverlet.collector 6.0.0
. My machine is running onWindows 11
. The issue is not specific to this configurations.Additional context
The code that breaks coverage doesn't needs to be used. I've also tried switching to other types and was not able to reproduce this.
The text was updated successfully, but these errors were encountered: