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

[CoberturaParser] System.IndexOutOfRangeException: Index was outside the bounds of the array #79

Closed
nulltoken opened this issue Feb 9, 2017 · 7 comments
Labels

Comments

@nulltoken
Copy link

Running the following (stripped down) Cobertura file

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="0.781948881789137" branch-rate="0.678638941398866" lines-covered="979" lines-valid="1252" branches-covered="359" branches-valid="529" complexity="0" version="0" timestamp="1486670906">
  <sources>
    <source>.</source>
  </sources>
  <packages>
    <package name="Cpq.Web" line-rate="0.781948881789137" branch-rate="0.678638941398866" complexity="0">
      <classes>
        <class name="Dummy.Thing" filename="F:\Dummy\Thing.cs" line-rate="0.625" branch-rate="0.75" complexity="0">
          <methods>
            <method name="TryValidate" signature="(System.String,System.String[],System.String&amp;)" line-rate="0.714285714285714" branch-rate="0.75">
              <lines>
                <line number="15" hits="62" branch="true" condition-coverage="100% (2/2)" />
                <line number="17" hits="2" branch="false" />
                <line number="20" hits="60" branch="true" condition-coverage="50% (1/2)" />
                <line number="22" hits="0" branch="false" />
                <line number="23" hits="0" branch="false" />
                <line number="26" hits="60" branch="false" />
                <line number="27" hits="60" branch="false" />
              </lines>
            </method>
            <method name=".ctor" signature="()" line-rate="1" branch-rate="1">
              <lines />
            </method>
            <method name=".cctor" signature="()" line-rate="0" branch-rate="1">
              <lines>
                <line number="7" hits="0" branch="false" />
              </lines>
            </method>
          </methods>
          <lines>
            <line number="15" hits="62" branch="true" condition-coverage="100% (2/2)" />
            <line number="17" hits="2" branch="false" />
            <line number="20" hits="60" branch="true" condition-coverage="50% (1/2)" />
            <line number="22" hits="0" branch="false" />
            <line number="23" hits="0" branch="false" />
            <line number="26" hits="60" branch="false" />
            <line number="27" hits="60" branch="false" />
            <line number="7" hits="0" branch="false" />
          </lines>
        </class>
      </classes>
    </package>
  </packages>
</coverage>

triggers the following exception

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more
 errors occurred. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Palmmedia.ReportGenerator.Parser.CoberturaParser.ProcessFile(Class class, String filePath)
   at Palmmedia.ReportGenerator.Parser.CoberturaParser.ProcessClass(Assembly assembly, String className)

*Note: The initial file has been produced by the OpenCoverCobertura converter from an xunit test result. As I'm not proficient with the file formats, I'm not able to tell if the error lies in the parser or in the way the file has been converted to Cobertura format.

@nulltoken
Copy link
Author

The exception is triggered by line 281

@danielpalme
Copy link
Owner

I fixed the problem is this beta release:
https://www.nuget.org/packages/ReportGenerator/2.5.3-beta2

By the way:
You can process the OpenCover file directly, no need to convert it to Cobertura format!

@nulltoken
Copy link
Author

I fixed the problem

@danielpalme Thanks for that! I'm going to give that a try and will let you know about the result on my side

You can process the OpenCover file directly, no need to convert it to Cobertura format!

I know 😉

I was playing with this nice tooling of yours, prepping my way for integration with VSTS.

Then I tried to feed ReportGenerator with the output of the Converter to ensure the output was similar from what I was getting from OpenCover.

And.. 💥

Thought you'd like to know about it 😉

@danielpalme
Copy link
Owner

Yes of course i would like to know!

But OpenCover reports contain much more information than the Cobertura reports, so I would highly recommend to use them.

@nulltoken
Copy link
Author

But OpenCover reports contain much more information than the Cobertura reports, so I would highly recommend to use them.

I agree. However, my target is to get those coverage data to be gathered by VSTS and it looks like Cobertura format looks like my only option when it comes to .NET Core based app.

@nulltoken
Copy link
Author

I fixed the problem

@danielpalme Thanks for that! I'm going to give that a try and will let you know about the result on my side

Issue fixed. Awesome.

Tons of ❤️s !

Just discovered a tiny issue. Will open a separate one.

@nulltoken
Copy link
Author

But OpenCover reports contain much more information than the Cobertura reports, so I would highly recommend to use them.

I agree. However, my target is to get those coverage data to be gathered by VSTS and it looks like Cobertura format looks like my only option when it comes to .NET Core based app.

@danielpalme I eventually (sigh) understood what you were hinting at: Use Cobertura format for the summary and upload the detailed OpenCover based generated Html report.

Although the experience isn't that rich at the moment (because of microsoft/azure-pipelines-tasks#3027), it was a very good advice. Thanks a lot for it!

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

No branches or pull requests

2 participants