-
Notifications
You must be signed in to change notification settings - Fork 388
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] Generic methods are not correct translated #1691
Comments
Please refine the version information for .NET SDK/runtime e.g. 8.0.108 or 8.0.8 |
Sorry for the late answer. Somehow i missed the notification.. |
Sorry, I cannot reproduce the issue. Please add information how you create the the XML snipped (coverlet.collector v6.0.2). The method names did not change but the result looks different. I used <?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1727685297" lines-covered="6" lines-valid="6" branches-covered="0" branches-valid="0">
<sources>
<source>C:\</source>
</sources>
<packages>
<package name="CoverletGenericIssue" line-rate="1" branch-rate="1" complexity="2">
<classes>
<class name="CoverletGenericIssue.Class1" filename="GitHub\coverlet-issue-1691\CoverletGenericIssue\Class1.cs" line-rate="1" branch-rate="1" complexity="2">
<methods>
<method name="GetObject" signature="()" 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>
<method name="GetObject" signature="()" line-rate="1" branch-rate="1" complexity="1">
<lines>
<line number="11" hits="1" branch="False" />
<line number="12" hits="1" branch="False" />
<line number="13" 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" />
<line number="11" hits="1" branch="False" />
<line number="12" hits="1" branch="False" />
<line number="13" hits="1" branch="False" />
</lines>
</class>
</classes>
</package>
</packages>
</coverage> |
both "GetObject" methods have the same signature in your result and thats the same result as mine and the key problem here. Since they are different methods, they should also have a different signature. In other words the generic parameter should be taken into account. This case (2 methods with same signature) causes problems in our CI pipeline #1077 was the same issue but on class level. |
I am not sure whether this is an issue because line coverage and condition branch coverage is checked. |
These 2 methods are independent of each other and can do different things. I think the coverage report should reflect this. |
Well if you say it is good as it is, you can close this ticket |
Coverlet gathers method, branch and line coverage but not all reporters are supporting method coverage. This issue is a duplicate of #1077 which was not resolved and marked as a enhancement.
The generated coverage.opencover.xml shows example coverage.opencover.xml: <CoverageSession>
<Summary numSequencePoints="6" visitedSequencePoints="6" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="2" minCyclomaticComplexity="2" visitedClasses="1" numClasses="1" visitedMethods="2" numMethods="2"/>
<Modules>
<Module hash="CB7678B0-0726-4268-BD04-11A8E8029085">
<ModulePath>CoverletGenericIssue.dll</ModulePath>
<ModuleTime>2024-10-16T02:27:16</ModuleTime>
<ModuleName>CoverletGenericIssue</ModuleName>
<Files>
<File uid="1" fullPath="C:\GitHub\coverlet-issue-1691\CoverletGenericIssue\Class1.cs"/>
</Files>
<Classes>
<Class>
<Summary numSequencePoints="6" visitedSequencePoints="6" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="1" numClasses="1" visitedMethods="2" numMethods="2"/>
<FullName>CoverletGenericIssue.Class1</FullName>
<Methods>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="3" visitedSequencePoints="3" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1"/>
<MetadataToken/>
<Name>System.Object CoverletGenericIssue.Class1::GetObject()</Name>
<FileRef uid="1"/>
<SequencePoints>
<SequencePoint vc="1" uspid="6" ordinal="0" sl="6" sc="1" el="6" ec="2" bec="0" bev="0" fileid="1"/>
<SequencePoint vc="1" uspid="7" ordinal="1" sl="7" sc="1" el="7" ec="2" bec="0" bev="0" fileid="1"/>
<SequencePoint vc="1" uspid="8" ordinal="2" sl="8" sc="1" el="8" ec="2" bec="0" bev="0" fileid="1"/>
</SequencePoints>
<BranchPoints/>
<MethodPoint xmlns:p8="xsi" vc="3" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="6" ec="1" el="8" bec="0" bev="0" fileid="1"/>
</Method>
<Method cyclomaticComplexity="1" nPathComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="3" visitedSequencePoints="3" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="100" maxCyclomaticComplexity="1" minCyclomaticComplexity="1" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1"/>
<MetadataToken/>
<Name>T CoverletGenericIssue.Class1::GetObject()</Name>
<FileRef uid="1"/>
<SequencePoints>
<SequencePoint vc="1" uspid="11" ordinal="0" sl="11" sc="1" el="11" ec="2" bec="0" bev="0" fileid="1"/>
<SequencePoint vc="1" uspid="12" ordinal="1" sl="12" sc="1" el="12" ec="2" bec="0" bev="0" fileid="1"/>
<SequencePoint vc="1" uspid="13" ordinal="2" sl="13" sc="1" el="13" ec="2" bec="0" bev="0" fileid="1"/>
</SequencePoints>
<BranchPoints/>
<MethodPoint xmlns:p8="xsi" vc="3" uspid="0" p8:type="SequencePoint" ordinal="1" offset="1" sc="0" sl="11" ec="1" el="13" bec="0" bev="0" fileid="1"/>
</Method>
</Methods>
</Class>
</Classes>
</Module>
</Modules>
</CoverageSession> |
Describe the bug
I got some C# classes that have 2 methods with the same signature. One has a generic return value and one a fix type. So the outcoming cobertura report has the same function twice which leads to an error in our CI.
To Reproduce
I created a fresh c# library project with this class and a unit test project:
Created a github repo:
https://github.com/mischube/CoverletGenericIssue
Expected behavior
The generic method should have either a different name or signature
Actual behavior
Both methods have the same identifier.
Configuration (please complete the following information):
Additional context
Seems to be similar to #1077
The text was updated successfully, but these errors were encountered: