Skip to content

Commit

Permalink
#363: Fixed OpenCover file handling (not unique tracked methods)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Aug 29, 2020
1 parent e1214b2 commit 2ffeaf0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ CHANGELOG

4.6.5.0

* Fix: #363: Fixed OpenCover file handling (not unique tracked methods)
* Fix: #371: Fixed order of metrics

4.6.4.0
Expand Down
22 changes: 20 additions & 2 deletions src/ReportGenerator.Core/Parser/OpenCoverParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,26 @@ public ParserResult Parse(XContainer report)
.Where(m => m.Attribute("skippedDueTo") == null)
.ToArray();
var files = report.Descendants("File").ToArray();
var trackedMethods = report.Descendants("TrackedMethod")
.ToDictionary(t => t.Attribute("uid").Value, t => t.Attribute("name").Value);

var trackedMethods = new Dictionary<string, string>();

foreach (var trackedMethodElement in report.Descendants("TrackedMethod"))
{
if (trackedMethods.ContainsKey(trackedMethodElement.Attribute("uid").Value))
{
Logger.WarnFormat(
Resources.ErrorNotUniqueTrackedMethodUid,
trackedMethodElement.Attribute("name").Value);

trackedMethods.Clear();

break;
}
else
{
trackedMethods.Add(trackedMethodElement.Attribute("uid").Value, trackedMethodElement.Attribute("name").Value);
}
}

var assemblyNames = modules
.Select(m => m.Element("ModuleName").Value)
Expand Down
9 changes: 9 additions & 0 deletions src/ReportGenerator.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/ReportGenerator.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<data name="ErrorInvalidDotCoverReport" xml:space="preserve">
<value>The dotCover report does not contain line coverage data. Use the dotCover command line parameter '/ReportType=DetailedXML' to capture line coverage.</value>
</data>
<data name="ErrorNotUniqueTrackedMethodUid" xml:space="preserve">
<value>The 'uid' of tracked method '{0}' is not unique. Ignoring tracked methods.</value>
</data>
<data name="ErrorPartCover" xml:space="preserve">
<value>PartCover is no longer supported. If you want to generate coverage reports based on PartCover, please use version 3.x of ReportGenerator.</value>
</data>
Expand Down

0 comments on commit 2ffeaf0

Please sign in to comment.