From e07dbd7954171b3ccf7461f2daad18c5e6bdbdfd Mon Sep 17 00:00:00 2001 From: Daniel Palme Date: Tue, 28 May 2024 21:42:50 +0200 Subject: [PATCH] #663: Improved support for Cobertura files generated by "Microsoft CodeCoverage" --- src/Readme.txt | 1 + src/ReportGenerator.Core/Parser/CoberturaParser.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Readme.txt b/src/Readme.txt index b8881129..21c96615 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -69,6 +69,7 @@ CHANGELOG 5.3.5.0 + * New: #663: Improved support for Cobertura files generated by "Microsoft CodeCoverage" * New: #674: License can now be supplied via the REPORTGENERATOR_LICENSE environment variable 5.3.4.0 diff --git a/src/ReportGenerator.Core/Parser/CoberturaParser.cs b/src/ReportGenerator.Core/Parser/CoberturaParser.cs index adf33375..796e661f 100644 --- a/src/ReportGenerator.Core/Parser/CoberturaParser.cs +++ b/src/ReportGenerator.Core/Parser/CoberturaParser.cs @@ -153,6 +153,12 @@ private Assembly ProcessAssembly(XElement[] modules, string assemblyName) if (fullname.Contains("<")) { + if (fullname.Contains("__") + || fullname.Contains(".<>")) + { + return Tuple.Create(string.Empty, string.Empty); + } + var match = AsyncClassRegex.Match(fullname); if (match.Success) @@ -166,7 +172,8 @@ private Assembly ProcessAssembly(XElement[] modules, string assemblyName) return Tuple.Create(fullname, fullname); }) .Where(c => this.RawMode - || (!c.Item1.Contains("$") + || (c.Item1 != string.Empty + && !c.Item1.Contains("$") && (!c.Item1.Contains("<") || GenericClassRegex.IsMatch(c.Item1)))) .Distinct() .Where(c => this.ClassFilter.IsElementIncludedInReport(c.Item1))