Skip to content
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

wrong handling of internal record structs #685

Closed
theKBro opened this issue Aug 5, 2024 · 5 comments
Closed

wrong handling of internal record structs #685

theKBro opened this issue Aug 5, 2024 · 5 comments
Labels
enhancement sponsorship Requires sponsorship

Comments

@theKBro
Copy link

theKBro commented Aug 5, 2024

internal record structs are handled incorrectly

namespace ClassLibrary1;

public class DummyMix
{
    private readonly record struct DummyInternalRecord(string Type, string Name, string Attribute);

    private readonly DummyInternalRecord _internalRecord;
    
    public DummyMix(string name)
    {
        _internalRecord = new DummyInternalRecord("string", name, "");
    }

    public string Name => _internalRecord.Name;

}

  • getting coverage with dotcover
  • converting with reportgenerator
    leads to multiple
<method name="Name" signature="()" line-rate="1" branch-rate="1" complexity="NaN">
    <lines>
      <line number="7" hits="1" branch="false" />
    </lines>
  </method>

with missing DummyInternalRecord context

for the full dummy project see
ClassLibrary1.zip

if I can help to inspect this further please don't hesitate to contact me.
thanks in advance

@theKBro
Copy link
Author

theKBro commented Aug 5, 2024

this leads to jenkins recordCoverage errors e.g. Found unhandled java.lang.IllegalArgumentException exception: There is already the same child [METHOD] Name() <0> with the name Name() in [CLASS]

possibly related with #630

@danielpalme
Copy link
Owner

Will have a look within the next 3-4 weeks.
Probably I won't be able to do anything about this problem, but we will see.

@theKBro
Copy link
Author

theKBro commented Aug 6, 2024

I filed a PR, would be great if you could have a look at it.

@danielpalme
Copy link
Owner

Yes. I will have a look as soon as possible.
But it will take some time!

danielpalme added a commit that referenced this issue Aug 18, 2024
…to disable that coverage data of nested or compiler generated classes is included in the parent class.
@danielpalme
Copy link
Owner

This is related to #630 (Cobertura format instead of dotCover).

Some history:
When I started to implement ReportGenerator only HTML format was available.
I decided to display nested classes and structs within the parent class.

This was a reasonable approach, since HTML is for human users.

Later Cobertura was added as an output format. Here is makes more sense to treat nested types separately.

Bad news

  • I won't merge your PR, because it will change the default handling of nested classes

Good news

The new feature will be available in version 5.3.9 (I will release as soon as all open issues are resolved)

The setting (settings:rawMode=true) disables that coverage data of nested or compiler generated classes is included in the parent class.

Limitations:

  • Raw mode is currently only supported for Cobertura and dotCover files.
  • If you want HTML report and Cobertura output, you should execute ReportGenerator twice:
    • Cobertura: settings:rawMode=true
    • HTML: settings:rawMode=false

Documentation of the new feature:
https://reportgenerator.io/features#rawmode
https://reportgenerator.io/pro
https://github.com/danielpalme/ReportGenerator/wiki/Settings#other-settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement sponsorship Requires sponsorship
Projects
None yet
Development

No branches or pull requests

2 participants