-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Fix issues with handling of multiple assemblies with the same name #426
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ public ParserResult Parse(XContainer report) | |
/// <returns>The <see cref="Assembly"/>.</returns> | ||
private Assembly ProcessAssembly(XElement module) | ||
{ | ||
string assemblyName = module.Attribute("name").Value; | ||
string assemblyName = module.Attribute("name").Value + "_" + module.Attribute("id").Value; | ||
|
||
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName); | ||
|
||
|
@@ -187,7 +187,9 @@ private static CodeFile ProcessFile(XElement module, string fileId, ClassWithNam | |
var linesOfFile = methods | ||
.Elements("ranges") | ||
.Elements("range") | ||
.Where(r => r.Attribute("source_id").Value == fileId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevent the tool from applying the same coverage for different files invoked in the method being processed. It should only apply the associated coverage for the file. |
||
.Where(l => l.Attribute("start_line").Value != "15732480") | ||
.Distinct() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove it. |
||
.Select(l => new | ||
{ | ||
LineNumberStart = int.Parse(l.Attribute("start_line").Value, CultureInfo.InvariantCulture), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,7 +299,7 @@ public void TestMethods(IEnumerable<TestMethod> testMethods, IEnumerable<FileAna | |
codeElement.FirstLine, | ||
codeElement.CoverageQuota.HasValue ? coverageRounded.ToString() : "undefined", | ||
codeElement.CoverageQuota.HasValue ? ReportResources.Coverage2 + " " + codeElement.CoverageQuota.Value.ToString(CultureInfo.InvariantCulture) + "% - " : string.Empty, | ||
WebUtility.HtmlEncode(codeElement.Name), | ||
WebUtility.HtmlEncode($"File {item.Key} => " + codeElement.Name), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add file index before the method name, so that we know which file is associated with this method instance. This is to handle the scenario that multiple files may be invoke for the same method, and there are multiple method instances listed on the class coverage page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea, but in the sidebar the horizontal space is limited. I would prefer to show the file index only in the tooltip. |
||
codeElement.CodeElementType == CodeElementType.Method ? "cube" : "wrench"); | ||
} | ||
} | ||
|
@@ -626,7 +626,8 @@ public void KeyValueRow(string key, string value) | |
/// <param name="files">The files.</param> | ||
public void KeyValueRow(string key, IEnumerable<string> files) | ||
{ | ||
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)))); | ||
int fileIndex = 0; | ||
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)))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assign a file index to each file to shown on the class coverage page. So that we can reference to this file index in those method instances - when there are multiple instances of the same method listed on that page. |
||
|
||
this.reportTextWriter.WriteLine( | ||
"<tr><th>{0}</th><td>{1}</td></tr>", | ||
|
@@ -686,11 +687,11 @@ public void MetricsTable(Class @class) | |
WebUtility.HtmlEncode(methodMetric.FullName), | ||
fileIndex, | ||
methodMetric.Line, | ||
WebUtility.HtmlEncode(methodMetric.ShortName)); | ||
WebUtility.HtmlEncode($"File {fileIndex} => " + methodMetric.ShortName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add file index before the method name, so that we know which file is associated with this method instance. This is to handle the scenario that multiple files may be invoke for the same method, and there are multiple method instances listed on the class coverage page. |
||
} | ||
else | ||
{ | ||
this.reportTextWriter.Write("<td title=\"{0}\">{1}</td>", WebUtility.HtmlEncode(methodMetric.FullName), WebUtility.HtmlEncode(methodMetric.ShortName)); | ||
this.reportTextWriter.Write("<td title=\"{0}\">{1}</td>", WebUtility.HtmlEncode(methodMetric.FullName), WebUtility.HtmlEncode(file.Path + " => " + methodMetric.ShortName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add file index before the method name, so that we know which file is associated with this method instance. This is to handle the scenario that multiple files may be invoke for the same method, and there are multiple method instances listed on the class coverage page. |
||
} | ||
|
||
foreach (var metric in metrics) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will prevent the tool from mixing code coverage data from different versions of the same module (same name) together (when those coverage data exists in the same coverage file). E.g. x86 and x64 version of the same DLL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you generating the XML file by hand? I.e. are you manually copying the relevant section from the x86 coverage file to the x64 file or vice versa?
If yes: How about renaming the modules to "???_x86" and "???_x64" if you want separate results? The id looks "ugly" in the report.
In generell users would expect that modules with the same name are handled as a single module. I'm not willing to change that behavior, because users rely on it. Often ReportGenerator is used to merge several coverage files.
You are the first user that does not want to merge the results :-)