diff --git a/src/Readme.txt b/src/Readme.txt index b08d014f..07fd5302 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -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 diff --git a/src/ReportGenerator.Core/Parser/OpenCoverParser.cs b/src/ReportGenerator.Core/Parser/OpenCoverParser.cs index e012a714..d7bd69e9 100644 --- a/src/ReportGenerator.Core/Parser/OpenCoverParser.cs +++ b/src/ReportGenerator.Core/Parser/OpenCoverParser.cs @@ -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(); + + 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) diff --git a/src/ReportGenerator.Core/Properties/Resources.Designer.cs b/src/ReportGenerator.Core/Properties/Resources.Designer.cs index 50b1a214..b43822b7 100644 --- a/src/ReportGenerator.Core/Properties/Resources.Designer.cs +++ b/src/ReportGenerator.Core/Properties/Resources.Designer.cs @@ -258,6 +258,15 @@ internal static string ErrorInvalidDotCoverReport { } } + /// + /// Looks up a localized string similar to The 'uid' of tracked method '{0}' is not unique. Ignoring tracked methods.. + /// + internal static string ErrorNotUniqueTrackedMethodUid { + get { + return ResourceManager.GetString("ErrorNotUniqueTrackedMethodUid", resourceCulture); + } + } + /// /// Looks up a localized string similar to PartCover is no longer supported. If you want to generate coverage reports based on PartCover, please use version 3.x of ReportGenerator.. /// diff --git a/src/ReportGenerator.Core/Properties/Resources.resx b/src/ReportGenerator.Core/Properties/Resources.resx index 23d86c56..6a90f285 100644 --- a/src/ReportGenerator.Core/Properties/Resources.resx +++ b/src/ReportGenerator.Core/Properties/Resources.resx @@ -183,6 +183,9 @@ The dotCover report does not contain line coverage data. Use the dotCover command line parameter '/ReportType=DetailedXML' to capture line coverage. + + The 'uid' of tracked method '{0}' is not unique. Ignoring tracked methods. + PartCover is no longer supported. If you want to generate coverage reports based on PartCover, please use version 3.x of ReportGenerator.