Skip to content

Commit

Permalink
#536: Improved support for C code in Visual Studio coverage input for…
Browse files Browse the repository at this point in the history
…mat (*.coveragexml)
  • Loading branch information
danielpalme committed Feb 9, 2023
1 parent 97735f5 commit a36064a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ CHANGELOG

5.1.17.0

* Fix: #536: Improved support for C code in Visual Studio coverage input format (*.coveragexml)
* Fix: #582: Removed method coverage usage for line coverage if no coverage is available

5.1.16.0
Expand Down
13 changes: 10 additions & 3 deletions src/ReportGenerator.Core/Parser/DynamicCodeCoverageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ private Assembly ProcessAssembly(XElement module)
.Select(f => new ClassWithNamespace()
{
Namespace = f.Attribute("namespace")?.Value,
ClassName = f.Attribute("type_name").Value
ClassName = f.Attribute("type_name").Value,
TypeNameWasMissing = f.Attribute("type_name_missing") != null
})
.Where(c => !c.ClassName.Contains("<>")
&& !c.ClassName.StartsWith("$", StringComparison.OrdinalIgnoreCase))
.Select(c =>
{
int nestedClassSeparatorIndex = c.ClassName.IndexOf('.');
c.ClassName = nestedClassSeparatorIndex > -1 ? c.ClassName.Substring(0, nestedClassSeparatorIndex) : c.ClassName;
if (!c.TypeNameWasMissing)
{
int nestedClassSeparatorIndex = c.ClassName.IndexOf('.');
c.ClassName = nestedClassSeparatorIndex > -1 ? c.ClassName.Substring(0, nestedClassSeparatorIndex) : c.ClassName;
}

return c;
})
.Distinct()
Expand Down Expand Up @@ -353,6 +358,8 @@ private class ClassWithNamespace

public string ClassName { get; set; }

public bool TypeNameWasMissing { get; set; }

public string FullName => this.Namespace == null ? this.ClassName : $"{this.Namespace}.{this.ClassName}";

public override bool Equals(object obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private static void AddMissingTypeNames(XElement module)
if (firstSourceId != null && classNamesBySoureFileId.TryGetValue(firstSourceId, out string className))
{
function.Attribute("type_name").Value = className;
function.Add(new XAttribute("type_name_missing", "true"));
}
}
}
Expand Down

0 comments on commit a36064a

Please sign in to comment.