-
Notifications
You must be signed in to change notification settings - Fork 386
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
Uncovered lines in .NET 8 #1555
Comments
we are are having this issue since the MSBUILD 17.8 update, but for .NET 7 projects. GH Actions updated their latest agents to use MSBUILD 17.8 and we started seeing this issue. For now as a workaround we are building with older agents that still have MSBuild 17.7, but I'm also going to see if I can specify an older language version in the csproj or something. Still, it seems like this might prevent us from updating to .NET 8 |
I can confirm that this does not work at least when it comes to updating to .NET 8. My computer has .NET 8 installed but all .csproj files in the project I'm working on have |
Hi, thank you for the information but I can not reproduce the error using the latest preview. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1-preview.25.g21d3964f03">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ExampleProject\ExampleProject.csproj" />
</ItemGroup>
</Project>
|
I have updated the example. Could you try the following?
|
Thanks I will check it tomorrow. By the way, please use this command to generate a valid .gitignore file for the example git repository: |
The coverlet.runsetting excludes generated code and therefore uncovered line is removed.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings> Please check whether this is an acceptable solution. This will also remove async methods from the coverage results (more details #1561). |
I can confirm the proposed solution removes the uncovered line in |
@daveMueller Awesome! Thank you for your work on this. Can you explain the release cadence or when this change will be available on nuget? |
@daveMueller Any idea when this will make it into the nightly build? The last nightly was two days prior to merging this in.... it'd be nice to have these fixes there as well |
@pinkfloydx33 we are working on fixing the nightly pipeline. @camp-007 a new release currently has a really high priority among the maintainers but we had some issues with that in the last months. I'm optimistic that we can publish a new release in the near future. Until then you can consume the nightly build. |
I can confirm the solution implemented in nightly works in my example project: https://github.com/samuel-utbult-oborgen/coverlet-missing-line-example/tree/fix |
@daveMueller Any news or updates on when this will make it to a formal release on nuget? |
Describe the bug
When creating a record inheriting another record in a .NET 8 project, the initial line containing
public record
is reported as not covered by tests even though the record is used in the tests.To Reproduce
public record
on the second record is reported as not tested.Here is an example project showcasing the problem: https://github.com/samuel-utbult-oborgen/coverlet-missing-line-example
Expected behavior
The uncovered line should either be covered or ignored.
Actual behavior
The line is reported as uncovered.
Configuration
The following environment it used:
The text was updated successfully, but these errors were encountered: