-
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
[BUG] coverage.cobetura.file.xml filenames inconsistent between .NET 7 and .NET 8 #1658
Comments
Hi! I do some research and I found the following:
|
Please use latest coverage.collector V6.0.2 package and replicate the issue. |
@Bertk I used the latest version. |
@Bertk In the TestResults folder you can see the problem. You can also reproduce the issue just clone the repo then change the SDK version in the
or
Hope this helps. |
Thank you for the repo but I was not able to reproduce the issue on my system. I noticed some generated code in your I used the following sequence to create the output in artifacts.zip. dotnet restore C:\GitHub\coverlet-issue-1658\CoverletBug_net6.sln
dotnet build C:\GitHub\coverlet-issue-1658\CoverletBug_net6.sln
dotnet test TestProject\TestProject_net6.csproj -c Debug --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
reportgenerator -reports:"TestProject/**/*.cobertura.xml" -targetdir:"artifacts\reports.cobertura.net6.0" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura"
dotnet clean
rd /S /Q TestProject\TestResults
=> "adapt global.json for net8.0"
dotnet restore C:\GitHub\coverlet-issue-1658\CoverletBug_net8.sln
dotnet build C:\GitHub\coverlet-issue-1658\CoverletBug_net8.sln
dotnet test TestProject\TestProject_net8.csproj -c Debug --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
reportgenerator -reports:"TestProject/**/*.cobertura.xml" -targetdir:"artifacts\reports.cobertura.net8.0" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura" |
@Bertk did you clone my repo or just download it? Because the issue is reproducable only in the first case. |
the issue is only for .net 8. Did you try running this too on the cloned repo?
|
Finally, this issue is not related to cobertura coverage file format but the UseSourceLink option and coverlet.collector uses the local file name for net6.0 because UseSourceLink is not activated for net6.0 project files. There is a .NET 8.0 breaking change Source Link included in the .NET SDK The filename without activated UseSourceLink option. <package name="CoveredClassLibrary_net8" line-rate="1" branch-rate="1" complexity="1">
<classes>
<class name="CoveredClassLibrary.CoveredClass" filename="CoveredClassLibrary\CoveredClass.cs" line-rate="1" branch-rate="1" complexity="1">
<methods>
<method name="Sum" signature="(System.Int32,System.Int32)" line-rate="1" branch-rate="1" complexity="1">
<lines>
<line number="5" hits="1" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="5" hits="1" branch="False" />
</lines>
</class>
</classes> The filename with activated UseSourceLink option. <package name="CoveredClassLibrary_net8" line-rate="1" branch-rate="1" complexity="1">
<classes>
<class name="CoveredClassLibrary.CoveredClass" filename="https://raw.githubusercontent.com/tungi52/CoverletBug/89244e69a571cda8ff30e53aa8aa4760e0985249/CoveredClassLibrary/CoveredClass.cs" line-rate="1" branch-rate="1" complexity="1">
<methods>
<method name="Sum" signature="(System.Int32,System.Int32)" line-rate="1" branch-rate="1" complexity="1">
<lines>
<line number="5" hits="1" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="5" hits="1" branch="False" />
</lines>
</class>
</classes> Please |
Please aware that if a library is fully uncovered with UseSourceLink option the tool generates different filenames in the same report: https://github.com/tungi52/CoverletBug/blob/main/TestResults/with_sdk8/coverage.cobertura.xml#L9 https://github.com/tungi52/CoverletBug/blob/main/TestResults/with_sdk8/coverage.cobertura.xml#L25 |
@tungi52 Please create a separate issue for the inconsistent file name of uncovered library with enabled SourceLink configuration.
The proposed update could have an performance impact and need further investigations. |
Newer issue #1679 addresses inconsistent filenames in coverage files with activated SourceLink option. |
Describe the bug
There appears to be an pretty severe inconsistency between the cobetura output in .NET 7 and .NET 8. Please see issue below for details.
To Reproduce
See microsoft/azure-pipelines-tasks#19901 for the difference in output between .NET 7 and .NET 8
Expected behavior
Output should be consistent across runtimes. Or at a minimum there should be a flag to have .NET 8 output the full path to the file.
Actual behavior
See linked issue.
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used? 6.0.0
* Which version of .NET is the code running on? . SDK 8.0.300 and 7.0.409
* What OS and version, and what distro if applicable? Windows
* What is the architecture (x64, x86, ARM, ARM64)? X64
* Do you know whether it is specific to that configuration?
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: