Skip to content

Commit 3f6fb3a

Browse files
Fix issues with handling of multiple assemblies with the same name
1 parent 3ebe884 commit 3f6fb3a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/ReportGenerator.Core/Parser/DynamicCodeCoverageParser.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public ParserResult Parse(XContainer report)
8383
/// <returns>The <see cref="Assembly"/>.</returns>
8484
private Assembly ProcessAssembly(XElement module)
8585
{
86-
string assemblyName = module.Attribute("name").Value;
86+
string assemblyName = module.Attribute("name").Value + "_" + module.Attribute("id").Value;
8787

8888
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);
8989

@@ -187,7 +187,9 @@ private static CodeFile ProcessFile(XElement module, string fileId, ClassWithNam
187187
var linesOfFile = methods
188188
.Elements("ranges")
189189
.Elements("range")
190+
.Where(r => r.Attribute("source_id").Value == fileId)
190191
.Where(l => l.Attribute("start_line").Value != "15732480")
192+
.Distinct()
191193
.Select(l => new
192194
{
193195
LineNumberStart = int.Parse(l.Attribute("start_line").Value, CultureInfo.InvariantCulture),

src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public void TestMethods(IEnumerable<TestMethod> testMethods, IEnumerable<FileAna
299299
codeElement.FirstLine,
300300
codeElement.CoverageQuota.HasValue ? coverageRounded.ToString() : "undefined",
301301
codeElement.CoverageQuota.HasValue ? ReportResources.Coverage2 + " " + codeElement.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "% - " : string.Empty,
302-
WebUtility.HtmlEncode(codeElement.Name),
302+
WebUtility.HtmlEncode($"File {item.Key} => " + codeElement.Name),
303303
codeElement.CodeElementType == CodeElementType.Method ? "cube" : "wrench");
304304
}
305305
}
@@ -626,7 +626,8 @@ public void KeyValueRow(string key, string value)
626626
/// <param name="files">The files.</param>
627627
public void KeyValueRow(string key, IEnumerable<string> files)
628628
{
629-
string value = string.Join("<br />", files.Select(v => string.Format(CultureInfo.InvariantCulture, "<a href=\"#{0}\" class=\"navigatetohash\">{1}</a>", WebUtility.HtmlEncode(StringHelper.ReplaceNonLetterChars(v)), WebUtility.HtmlEncode(v))));
629+
int fileIndex = 0;
630+
string value = string.Join("<br />", files.Select(v => string.Format(CultureInfo.InvariantCulture, "<a href=\"#{0}\" class=\"navigatetohash\">{1}</a>", WebUtility.HtmlEncode(StringHelper.ReplaceNonLetterChars(v)), WebUtility.HtmlEncode($"File {fileIndex++}: " + v))));
630631

631632
this.reportTextWriter.WriteLine(
632633
"<tr><th>{0}</th><td>{1}</td></tr>",
@@ -686,11 +687,11 @@ public void MetricsTable(Class @class)
686687
WebUtility.HtmlEncode(methodMetric.FullName),
687688
fileIndex,
688689
methodMetric.Line,
689-
WebUtility.HtmlEncode(methodMetric.ShortName));
690+
WebUtility.HtmlEncode($"File {fileIndex} => " + methodMetric.ShortName));
690691
}
691692
else
692693
{
693-
this.reportTextWriter.Write("<td title=\"{0}\">{1}</td>", WebUtility.HtmlEncode(methodMetric.FullName), WebUtility.HtmlEncode(methodMetric.ShortName));
694+
this.reportTextWriter.Write("<td title=\"{0}\">{1}</td>", WebUtility.HtmlEncode(methodMetric.FullName), WebUtility.HtmlEncode(file.Path + " => " + methodMetric.ShortName));
694695
}
695696

696697
foreach (var metric in metrics)

0 commit comments

Comments
 (0)