-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Support for Deterministic Source Paths #405
Comments
I'm not sure I understand your problem correctly. If you use the If you use
The file Does this help?
|
Providing the source directory did solve the warnings, but in each of the type files, it seems to be duplicating the overlay (and possibly not fully merging the line hit counts)? Concretely, I have a result that looks like this with these two file names (same type,
The section of the report that shows the overlay is repeated twice, one for each file, so it's not clear that the line hit-counts are merged--what I want is to have those normalized and merged (they're the same file) to a single overlay. |
@MarcoRossignoli seems like you can write out the deterministic path in the cobertura file instead of the local file path. That'll fix the merging issues. The only requirement then will be that @danielpalme it may be worth an either a specific error or some reasonable default if ReportGenerator detects that the path starts with |
Maybe on coverlet side we should add a flag like |
@clairernovotny |
@clairernovotny |
I took a look at @clairernovotny files. In your coverage files all paths start with:
I understand that the following paths actually mean the same file:
In the class coverage report generated by ReportGenerator, you would expect that e.g. for class For me that means, we need a way to tell ReportGenerator that certain paths are mapped to other paths. What I don't understand yet:
|
The files don't contain anything that starts with Coverlet could add an option as @MarcoRossignoli suggests in #405 (comment) where it'd write the deterministic file paths instead. If they do that, on both Windows and Linux, the path would look something like
In that case, ReportGenerator wouldn't need to do any special mapping of paths when matching types/files, but a user would have to pass in |
Thanks. Now I got it. Adding support for this format should be easy in ReportGenerator. |
@danielpalme @clairernovotny you can try preview package of coverlet with deterministic report support https://f.feedz.io/marcorossignoli/coverletunofficial/nuget/index.json version
<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.8571" branch-rate="0.5" version="1.9" timestamp="1612702997" lines-covered="6" lines-valid="7" branches-covered="1" branches-valid="2">
<sources />
<packages>
<package name="MyLibrary" line-rate="0.8571" branch-rate="0.5" complexity="3">
<classes>
<class name="MyLibrary.Hello" filename="/_/MyLibrary/Hello.cs" line-rate="0.8571" branch-rate="0.5" complexity="3">
<methods>
<method name="get_Who" signature="()" line-rate="1" branch-rate="1" complexity="1">
<lines>
<line number="15" hits="1" branch="False" />
</lines>
</method>
<method name=".ctor" signature="(System.String)" line-rate="0.8332999999999999" branch-rate="0.5" complexity="2">
<lines>
<line number="7" hits="1" branch="False" />
<line number="8" hits="1" branch="False" />
<line number="9" hits="1" branch="True" condition-coverage="50% (1/2)">
<conditions>
<condition number="16" type="jump" coverage="50%" />
</conditions>
</line>
<line number="10" hits="0" branch="False" />
<line number="12" hits="1" branch="False" />
<line number="13" hits="1" branch="False" />
</lines>
</method>
... |
@MarcoRossignoli |
@MarcoRossignoli I tried out that version and it seems to have worked! |
@MarcoRossignoli
With both packages, I get the full path path instead of the determistic path in Any idea what's wrong? Here is my test project: |
@danielpalme can you add this to
<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1613461225" lines-covered="3" lines-valid="3" branches-covered="0" branches-valid="0">
<sources />
<packages>
<package name="CoverageSample" line-rate="1" branch-rate="1" complexity="1">
<classes>
<class name="CoverageSample.Calculator" filename="/_1/Calculator.cs" line-rate="1" branch-rate="1" complexity="1">
<methods>
<method name="Add" signature="(System.Int32,System.Int32)" line-rate="1" branch-rate="1" complexity="1">
<lines>
<line number="6" hits="1" branch="False" />
<line number="7" hits="1" branch="False" />
<line number="8" hits="1" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="6" hits="1" branch="False" />
<line number="7" hits="1" branch="False" />
<line number="8" hits="1" branch="False" />
</lines>
</class>
</classes>
</package>
</packages>
</coverage> |
My repo is under source control. When I add the I tried with the following <Project>
<!-- SourceLink starts here. See https://github.com/dotnet/sourcelink -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>
<PropertyGroup>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
</PropertyGroup>
<!-- Workaround. Remove once we're on 3.1.300+ https://github.com/dotnet/sourcelink/issues/572 -->
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
</Project> Now i get the expected path: How does |
Deterministic paths can be anything that starts with |
It's not decided by coverlet, it's a msbuild sdk target that fill available roots. |
I just added support for deterministic source paths in b0fd9b4. Before publishing an official release it would be helpful, if you could test a pre-release. |
Just made some additional changes 1350d0f and published release 4.8.6 |
Sorry for late response and thx @danielpalme. |
Today, it appears that ReportGenerator requires the "real" path to a file to work. If ContinousIntegrationBuild is set to true though, the paths in the report files should generate file paths of the like
etc.
They'll always be normalized across OS versions.
What we'd need is for the sources parameter to search against all roots (ignore the /_{n}/) and try to find it against something like
and match the files.
What can we do here?
Thanks!
The text was updated successfully, but these errors were encountered: