Skip to content

Compiler generated classes shown in the coverage result file #194

@LiangZugeng

Description

@LiangZugeng

I use coverlet to analyze my .NET Core 2.1 app and it outputs cobertura format, then I use report-generator to convert the result file into HTML format for human reading, it's been using in our project for a while and I still haven't figured out some strange issues.

  1. I have a class called BlockController, in the coverage result file I found compiler generated classes shown in parallel with BlockController, see screenshot below. I wonder if coverlet can eliminate those classes and combine the coverage data with the actual BlockController.

image

  1. The method name has something as a suffix, take this EaseSource.AnDa.SMT.Web.Controllers.BlockController/<GetAll>d__2, what's the "d__2"?

  2. There is one aggregation level missing in the report, the coverage result of all methods in BlockController should be aggregated to BlockController to show the total coverage of this class, unfortunately this is not done, I guess it's because in the coverage result output file, the method coverage data is put in the element, e.g.

        <class name="EaseSource.AnDa.SMT.Web.Controllers.BlockController/&lt;GetByIds&gt;d__5" filename="Web\Controllers\BlockController.cs" line-rate="1" branch-rate="0.5" complexity="0">
          <methods>
            <method name="MoveNext" signature="()" line-rate="1" branch-rate="0.5">
              <lines>
                <line number="496" hits="1" branch="True" condition-coverage="50% (1/2)">
                  <conditions>
                    <condition number="343" type="jump" coverage="50%" />
                  </conditions>
                </line>
                <line number="497" hits="1" branch="False" />
                <line number="498" hits="1" branch="False" />
                <line number="499" hits="1" branch="False" />
                <line number="500" hits="1" branch="False" />
                <line number="501" hits="1" branch="False" />
                <line number="503" hits="1" branch="False" />
                <line number="504" hits="1" branch="False" />
              </lines>
            </method>
          </methods>
          <lines>
            <line number="496" hits="1" branch="True" condition-coverage="50% (1/2)">
              <conditions>
                <condition number="343" type="jump" coverage="50%" />
              </conditions>
            </line>
            <line number="497" hits="1" branch="False" />
            <line number="498" hits="1" branch="False" />
            <line number="499" hits="1" branch="False" />
            <line number="500" hits="1" branch="False" />
            <line number="501" hits="1" branch="False" />
            <line number="503" hits="1" branch="False" />
            <line number="504" hits="1" branch="False" />
          </lines>
        </class>

The output cobertura file for this class is also attached.
coverage.cobertura.xml.zip

Please advice, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions