-
-
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
Cobertura output async "class" merging can create duplicate method entries #630
Comments
I will have a look within the days. |
Possibly related, this happens with nested classes as well. public static class Outer
{
public static class InnerFirst
{
}
public static class InnerSecond
{
}
} Will create two entries under "Outer" with the name of ".cctr" and an empty signature |
I just had a look at the two problems:
This is the relevant information from coverage.cobertura.txt <class name="CoverletRepro.TestController" filename="TestController.cs" line-rate="1" branch-rate="1" complexity="1">
<methods>
<method name="Index" signature="()" line-rate="1" branch-rate="1" complexity="1">
...
<class name="CoverletRepro.TestController/<Index>d__1" filename="TestController.cs" line-rate="1" branch-rate="1" complexity="1">
<methods>
<method name="MoveNext" signature="()" line-rate="1" branch-rate="1" complexity="1"> Both ReportGenerator does not parse the corresponding source code, it relies on the coverage file.
Methods and/or constructors of nested classes will be listed in the context of the parent class and therefore several entries with the same name and signature can appear. They are not referring to the same code lines though, you can see different |
This originally came up because the code coverage plugin I use in Jenkins updated and now errors if there are duplicated entries (See jenkinsci/code-coverage-api-plugin#785). Your point about the nested classes seems to say this behavior of rejecting duplicate method names is incorrect. |
"Incorrect" is a bit too hard. I would say, it would be good not to rely on unique names. |
I understand that this makes sense for the user interface, but wouldn't it be more appropriate if the model would retain the original structure and add these nested classes to the parent file? E.g. in JaCoCo reports those nested classes are also shown as direct descendants of the associated file, but they are not removed (i.e. the class in class hierarchy is flattened). Can't you ignore these classes in the HTML reports only? I added a fix to ignore and skip those method nodes on my side (see jenkinsci/coverage-model#39) but it would be more appropriate if the generated model would retain this information. |
@uhafner |
No worries, I released a new version of the Jenkins coverage plugin that is more resilient about "errors" during parsing. |
I appreciate the dialog here and the work you've both done on your respective tools =) |
I decided to not implement the required changes (at least not at the moment). Reasons:
|
Ms code coverage isn't a solution because of |
…e data of nested or compiler generated classes is included in the parent class. This is useful to merge several Cobertura files into one file.
…e data of nested or compiler generated classes is included in the parent class. This is useful to merge several Cobertura files into one file.
I just released version 5.2.4. This version includes a new setting ( The setting disables that coverage data of nested or compiler generated classes is included in the parent class. Limitations:
You need a PRO license to use the new feature. Documentation of the new feature: |
Describe the bug
When using reportgenerator to output a Cobertura report, classes with async method overrides with the same name will have duplicate entries in the generated XML.
For example, this MVC controller code:
Generates this XML using Coverlet:
If that XML file is then fed into reportgenerator, it creates this XML file:
Which has two "Index" entries with the same empty signature.
I'm not sure if this is a limitation of the format, a problem with Coverlet, or a problem with reportgenerator but as it only occurs after running through reportgenerator I thought I would start here.
To Reproduce
The following input helps to reproduce your issue:
The text was updated successfully, but these errors were encountered: