From 537c17c126cefe4da5de2bb885cee520cdf43b70 Mon Sep 17 00:00:00 2001 From: Daniel Palme Date: Fri, 6 Dec 2024 18:09:48 +0100 Subject: [PATCH] #700 Fixed handling of .netconfig files (sourceDirectories, reportTypes, plugins, assemblyFilters, etc.) --- README.md | 50 +++++++++---------- src/Readme.txt | 4 ++ .../ReportConfigurationBuilder.cs | 18 +++---- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 2dfc5f97..87af7a73 100644 --- a/README.md +++ b/README.md @@ -128,33 +128,33 @@ section. Examples: ```gitconfig [ReportGenerator] - reports = coverage.xml + reports = "coverage.xml" targetdir = "C:\\report" - reporttypes = Latex,HtmlSummary - assemblyfilters = +Test,-Test - classfilters = +Test2,-Test2 + reporttypes = "Latex;HtmlSummary" + assemblyfilters = "+Test;-Test" + classfilters = "+Test2;-Test2" ``` All the plural options can also be specified as multiple singular entries, like: ```gitconfig [ReportGenerator] - report = coverage1.xml - report = coverage2.xml - reporttype = Latex - reporttype = HtmlSummary - assemblyfilter = +Test - assemblyfilter = -Test - classfilter = +Test2 - classfilter = -Test2 - filefilter = +cs - filefilter = -vb - riskhotspotassemblyfilter = +Test - riskhotspotassemblyfilter = -Test - riskhotspotclassfilter = +Test2 - riskhotspotclassfilter = -Test2 - sourcedir = src - sourcedir = test + report = "coverage1.xml" + report = "coverage2.xml" + reporttype = "Latex" + reporttype = "HtmlSummary" + assemblyfilter = "+Test" + assemblyfilter = "-Test" + classfilter = "+Test2" + classfilter = "-Test2" + filefilter = "+cs" + filefilter = "-vb" + riskhotspotassemblyfilter = "+Test" + riskhotspotassemblyfilter = "-Test" + riskhotspotclassfilter = "+Test2" + riskhotspotclassfilter = "-Test2" + sourcedir = "src" + sourcedir = "test" ``` Adding/removing values is trivial using the [dotnet-config](https://dotnetconfig.org) CLI: @@ -197,11 +197,11 @@ Given the following `.netconfig`: ```gitconfig [ReportGenerator] - reporttypes = Html;Latex - targetdirectory = report - historydirectory = history - assemblyfilters = +Include;-Excluded - verbosityLevel = Verbose + reporttypes = "Html;Latex" + targetdirectory = "report" + historydirectory = "history" + assemblyfilters = "+Include;-Excluded" + verbosityLevel = "Verbose" ``` The above target could be simplified as: diff --git a/src/Readme.txt b/src/Readme.txt index e3e956ae..fa6bc086 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -67,6 +67,10 @@ For further details take a look at LICENSE.txt. CHANGELOG +5.4.2.0 + + * Fix: #700 Fixed handling of .netconfig files (sourceDirectories, reportTypes, plugins, assemblyFilters, etc.) + 5.4.1.0 * Fix: #707 Fixed issue with file filters diff --git a/src/ReportGenerator.Core/ReportConfigurationBuilder.cs b/src/ReportGenerator.Core/ReportConfigurationBuilder.cs index 08cf57a2..c85ae120 100644 --- a/src/ReportGenerator.Core/ReportConfigurationBuilder.cs +++ b/src/ReportGenerator.Core/ReportConfigurationBuilder.cs @@ -52,7 +52,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.Reports, out value)) { - reportFilePatterns = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + reportFilePatterns = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -78,7 +78,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.SourceDirectories, out value)) { - sourceDirectories = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + sourceDirectories = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -108,7 +108,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.ReportTypes, out value)) { - reportTypes = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + reportTypes = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -125,7 +125,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.Plugins, out value)) { - plugins = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + plugins = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -146,7 +146,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.AssemblyFilters, out value)) { - assemblyFilters = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + assemblyFilters = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -163,7 +163,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.ClassFilters, out value)) { - classFilters = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + classFilters = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -180,7 +180,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.FileFilters, out value)) { - fileFilters = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + fileFilters = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -197,7 +197,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.RiskHotspotAssemblyFilters, out value)) { - riskHotspotAssemblyFilters = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + riskHotspotAssemblyFilters = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else { @@ -214,7 +214,7 @@ public ReportConfiguration Create(Dictionary cliArguments) } else if (config.TryGetString(DotNetConfigSettingNames.RiskHotspotClassFilters, out value)) { - riskHotspotClassFilters = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + riskHotspotClassFilters = value.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); } else {