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
Describe the bug
Issue is connected to this and partially explained: #1658
From .NET 8 source links are included in the SDK: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link, https://github.com/dotnet/sourcelink. This means enabling UseSourceLink option results in different filenames compared to previous versions. However if someone has a referenced assembly for a test project which content is fully uncovered filenames could be inconsistent inside a single generated report files. Meaning for example a coverage.cobertura.xml could contain filenames like c:\users\me\...\ProjectA\ClassA.cs and https://github.com/.../ProjectA/ClassA.cs at the same time.
Further problem with this that additional tools like ReportGenerator calculates invalid coverage if filenames are inconsistent through multiple report files.
To Reproduce
Issue can be easily reproduced in a .NET 8 solution if a tesproject has a reference for a covered and non-covered assembly.
Expected behavior
Filenames should be consistent inside a single and across multiple report files using the same configuration.
Actual behavior
Filenames are inconsistent inside a single and across multiple a report files with the same configuration. Possible root cause of the error is here: https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Coverage.cs#L368 between line 368 and 387. As I mentioned the issue is only reproducable if there is a fully uncovered referenced assembly. The linked code part is exactly shows this problem: if there is no hit for an assembly the source links are not processed and later the physical path will be used.
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Coverlet version: v6.0.2, but reproducable with older, .NET 8 compatible versions too
* .NET version: v8.0.303
* OS: Windows 11; Alpine linux
* Architecture: x64
* I think it is not configuration specific issue
Additional context
There was a small discussion here: #1658
tungi52
changed the title
[BUG] Different filenames with UseSourceLink after .NET 8
[BUG] Inconsistent filenames with UseSourceLink after .NET 8
Jul 29, 2024
Describe the bug
Issue is connected to this and partially explained: #1658
From .NET 8 source links are included in the SDK: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link, https://github.com/dotnet/sourcelink. This means enabling UseSourceLink option results in different filenames compared to previous versions. However if someone has a referenced assembly for a test project which content is fully uncovered filenames could be inconsistent inside a single generated report files. Meaning for example a
coverage.cobertura.xml
could contain filenames likec:\users\me\...\ProjectA\ClassA.cs
andhttps://github.com/.../ProjectA/ClassA.cs
at the same time.Further problem with this that additional tools like ReportGenerator calculates invalid coverage if filenames are inconsistent through multiple report files.
To Reproduce
Issue can be easily reproduced in a .NET 8 solution if a tesproject has a reference for a covered and non-covered assembly.
Small example can be found here: https://github.com/tungi52/CoverletBug. Running the following command the report XML will be wrong:
dotnet test CoverletBug_net8.sln --collect:"XPlat Code Coverage" --settings TestProject/test.runsettings
Problem is here:
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
Expected behavior
Filenames should be consistent inside a single and across multiple report files using the same configuration.
Actual behavior
Filenames are inconsistent inside a single and across multiple a report files with the same configuration. Possible root cause of the error is here: https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Coverage.cs#L368 between line 368 and 387. As I mentioned the issue is only reproducable if there is a fully uncovered referenced assembly. The linked code part is exactly shows this problem: if there is no hit for an assembly the source links are not processed and later the physical path will be used.
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Coverlet version: v6.0.2, but reproducable with older, .NET 8 compatible versions too
* .NET version: v8.0.303
* OS: Windows 11; Alpine linux
* Architecture: x64
* I think it is not configuration specific issue
Additional context
There was a small discussion here: #1658
The text was updated successfully, but these errors were encountered: