Skip to content

Commit 16ca983

Browse files
committed
#384: Added warning for unknown or duplicate command line arguments
1 parent cbbe7a0 commit 16ca983

19 files changed

+343
-92
lines changed

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ variables:
1212
- name: disable.coverage.autogenerate
1313
value: 'true'
1414
- name: version
15-
value: '4.6.7'
15+
value: '4.7.0'
1616

1717
stages:
1818
- stage: Build

src/AzureDevopsTask/ReportGenerator/task.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"author": "Palmmedia",
1313
"version": {
1414
"Major": 4,
15-
"Minor": 6,
16-
"Patch": 7
15+
"Minor": 7,
16+
"Patch": 0
1717
},
1818
"instanceNameFormat": "ReportGenerator",
1919
"groups": [

src/AzureDevopsTask/vss-extension.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "reportgenerator",
44
"name": "ReportGenerator",
5-
"version": "4.6.7",
5+
"version": "4.7.0",
66
"publisher": "Palmmedia",
77
"public": true,
88
"targets": [

src/Readme.txt

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ CHANGELOG
6666
4.7.0.0
6767

6868
* New: Dropped support for Nuget package 'dotnet-reportgenerator-cli'. Use 'dotnet-reportgenerator-globaltool' instead.
69+
* New: #384: Added warning for unknown or duplicate command line arguments
6970

7071
4.6.7.0
7172

src/ReportGenerator.Console.NetCore/ReportGenerator.Console.NetCore.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -7,8 +7,8 @@
77
<AssemblyName>ReportGenerator</AssemblyName>
88
<RootNamespace>Palmmedia.ReportGenerator</RootNamespace>
99
<StartupObject>Palmmedia.ReportGenerator.Console.NetCore.Program</StartupObject>
10-
<AssemblyVersion>4.6.7.0</AssemblyVersion>
11-
<FileVersion>4.6.7.0</FileVersion>
10+
<AssemblyVersion>4.7.0.0</AssemblyVersion>
11+
<FileVersion>4.7.0.0</FileVersion>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

src/ReportGenerator.Console/Properties/AssemblyInfo.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.InteropServices;
33

44
// General Information about an assembly is controlled through the following
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("")]
1111
[assembly: AssemblyProduct("ReportGenerator.Console")]
12-
[assembly: AssemblyCopyright("Copyright © 2018")]
12+
[assembly: AssemblyCopyright("Copyright © 2018")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("4.6.7.0")]
35-
[assembly: AssemblyFileVersion("4.6.7.0")]
34+
[assembly: AssemblyVersion("4.7.0.0")]
35+
[assembly: AssemblyFileVersion("4.7.0.0")]

src/ReportGenerator.Core.Test/ReportConfigurationBuilderTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void ConfigProvidesMissingArguments()
8484
{
8585
var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
8686
Directory.CreateDirectory(dir);
87-
var config = Config.Build(dir).GetSection(ReportConfigurationBuilder.SectionName);
87+
var config = Config.Build(dir).GetSection(DotNetConfigSettingNames.SectionName);
8888

8989
config.SetString("reports", ReportPath);
9090
config.SetString("targetdir", "C:\\temp");
@@ -116,7 +116,7 @@ public void ConfigProvidesMultiValuedSettings()
116116
{
117117
var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
118118
Directory.CreateDirectory(dir);
119-
var config = Config.Build(dir).GetSection(ReportConfigurationBuilder.SectionName);
119+
var config = Config.Build(dir).GetSection(DotNetConfigSettingNames.SectionName);
120120

121121
config.SetString("reports", ReportPath);
122122

src/ReportGenerator.Core.Test/ReportGenerator.Core.Test.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<RootNamespace>Palmmedia.ReportGenerator.Core.Test</RootNamespace>
7-
<AssemblyVersion>4.6.7.0</AssemblyVersion>
8-
<FileVersion>4.6.7.0</FileVersion>
7+
<AssemblyVersion>4.7.0.0</AssemblyVersion>
8+
<FileVersion>4.7.0.0</FileVersion>
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
</PropertyGroup>
1111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Reflection;
4+
5+
namespace Palmmedia.ReportGenerator.Core
6+
{
7+
/// <summary>
8+
/// Name of the command line arguments.
9+
/// </summary>
10+
internal static class CommandLineArgumentNames
11+
{
12+
/// <summary>
13+
/// The reports.
14+
/// </summary>
15+
public const string Reports = "REPORTS";
16+
17+
/// <summary>
18+
/// The target directory.
19+
/// </summary>
20+
public const string TargetDirectory = "TARGETDIR";
21+
22+
/// <summary>
23+
/// The source directories.
24+
/// </summary>
25+
public const string SourceDirectories = "SOURCEDIRS";
26+
27+
/// <summary>
28+
/// The history directory.
29+
/// </summary>
30+
public const string HistoryDirectory = "HISTORYDIR";
31+
32+
/// <summary>
33+
/// The report types.
34+
/// </summary>
35+
public const string ReportTypes = "REPORTTYPES";
36+
37+
/// <summary>
38+
/// Single report type (deprecated).
39+
/// </summary>
40+
public const string ReportType = "REPORTTYPE";
41+
42+
/// <summary>
43+
/// The plugins.
44+
/// </summary>
45+
public const string Plugins = "PLUGINS";
46+
47+
/// <summary>
48+
/// The assembly filters.
49+
/// </summary>
50+
public const string AssemblyFilters = "ASSEMBLYFILTERS";
51+
52+
/// <summary>
53+
/// The assembly filters (deprecated).
54+
/// </summary>
55+
public const string Filters = "FILTERS";
56+
57+
/// <summary>
58+
/// Single class filter.
59+
/// </summary>
60+
public const string ClassFilters = "CLASSFILTERS";
61+
62+
/// <summary>
63+
/// The file filters.
64+
/// </summary>
65+
public const string FileFilters = "FILEFILTERS";
66+
67+
/// <summary>
68+
/// The verbosity.
69+
/// </summary>
70+
public const string Verbosity = "VERBOSITY";
71+
72+
/// <summary>
73+
/// The title.
74+
/// </summary>
75+
public const string Title = "TITLE";
76+
77+
/// <summary>
78+
/// The tag.
79+
/// </summary>
80+
public const string Tag = "TAG";
81+
82+
/// <summary>
83+
/// All valid command line parameter names.
84+
/// </summary>
85+
private static readonly HashSet<string> ValidNames = new HashSet<string>(
86+
typeof(CommandLineArgumentNames)
87+
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
88+
.Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(string))
89+
.Select(x => (string)x.GetRawConstantValue())
90+
.ToList());
91+
92+
/// <summary>
93+
/// Gets a value indicating whether a command line parameter name is valid.
94+
/// </summary>
95+
/// <param name="name">The command line parameter name.</param>
96+
/// <returns><c>true</c> if command line parameter is valid; otherwise <c>false</c>.</returns>
97+
public static bool IsValid(string name)
98+
{
99+
if (name == null)
100+
{
101+
return false;
102+
}
103+
104+
return ValidNames.Contains(name.ToUpperInvariant());
105+
}
106+
}
107+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
namespace Palmmedia.ReportGenerator.Core
2+
{
3+
/// <summary>
4+
/// Name of configuration elements in .netconfig files.
5+
/// </summary>
6+
public static class DotNetConfigSettingNames
7+
{
8+
/// <summary>
9+
/// Name of the configuration section in a .netconfig file.
10+
/// </summary>
11+
public const string SectionName = "ReportGenerator";
12+
13+
/// <summary>
14+
/// The reports.
15+
/// </summary>
16+
public const string Reports = "reports";
17+
18+
/// <summary>
19+
/// Single report.
20+
/// </summary>
21+
public const string Report = "report";
22+
23+
/// <summary>
24+
/// The target directory.
25+
/// </summary>
26+
public const string TargetDirectory = "targetdir";
27+
28+
/// <summary>
29+
/// The source directories.
30+
/// </summary>
31+
public const string SourceDirectories = "sourcedirs";
32+
33+
/// <summary>
34+
/// Single source directory.
35+
/// </summary>
36+
public const string SourceDirectory = "sourcedir";
37+
38+
/// <summary>
39+
/// The history directory.
40+
/// </summary>
41+
public const string HistoryDirectory = "historydir";
42+
43+
/// <summary>
44+
/// The report types.
45+
/// </summary>
46+
public const string ReportTypes = "reporttypes";
47+
48+
/// <summary>
49+
/// Single report type.
50+
/// </summary>
51+
public const string ReportType = "reporttype";
52+
53+
/// <summary>
54+
/// The plugins.
55+
/// </summary>
56+
public const string Plugins = "plugins";
57+
58+
/// <summary>
59+
/// Single plugin.
60+
/// </summary>
61+
public const string Plugin = "plugin";
62+
63+
/// <summary>
64+
/// The assembly filters.
65+
/// </summary>
66+
public const string AssemblyFilters = "assemblyfilters";
67+
68+
/// <summary>
69+
/// Single assembly filter.
70+
/// </summary>
71+
public const string AssemblyFilter = "assemblyfilter";
72+
73+
/// <summary>
74+
/// The class filters.
75+
/// </summary>
76+
public const string ClassFilters = "classfilters";
77+
78+
/// <summary>
79+
/// Single class filter.
80+
/// </summary>
81+
public const string ClassFilter = "classfilter";
82+
83+
/// <summary>
84+
/// The file filters.
85+
/// </summary>
86+
public const string FileFilters = "filefilters";
87+
88+
/// <summary>
89+
/// Single file filter.
90+
/// </summary>
91+
public const string FileFilter = "filefilter";
92+
93+
/// <summary>
94+
/// The verbosity.
95+
/// </summary>
96+
public const string Verbosity = "verbosity";
97+
98+
/// <summary>
99+
/// The title.
100+
/// </summary>
101+
public const string Title = "title";
102+
103+
/// <summary>
104+
/// The tag.
105+
/// </summary>
106+
public const string Tag = "tag";
107+
}
108+
}

src/ReportGenerator.Core/Properties/Resources.Designer.cs

+19-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ReportGenerator.Core/Properties/Resources.resx

+6
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
<data name="DefaultReportBuilderReplaced" xml:space="preserve">
151151
<value>The default report builder for report type '{0}' was replaced.</value>
152152
</data>
153+
<data name="DuplicateCommandLineParameter" xml:space="preserve">
154+
<value>Duplicate command line parameter '{0}'. Using value '{1}'</value>
155+
</data>
153156
<data name="ErrorCoverageFormat" xml:space="preserve">
154157
<value>It seems that the report file '{0}' is a binary format generated by a Visual Studio code coverage tool. Please convert to XML format with 'CodeCoverage.exe' (See: https://github.com/danielpalme/ReportGenerator/wiki/Visual-Studio-Coverage-Tools#codecoverageexe)</value>
155158
</data>
@@ -298,6 +301,9 @@
298301
<data name="TargetDirectoryCouldNotBeCreated" xml:space="preserve">
299302
<value>The target directory '{0}' could not be created: {1}</value>
300303
</data>
304+
<data name="UnknownCommandLineParameter" xml:space="preserve">
305+
<value>Unknown command line parameter '{0}'</value>
306+
</data>
301307
<data name="UnknownReportType" xml:space="preserve">
302308
<value>Unknown report type '{0}'.</value>
303309
</data>

0 commit comments

Comments
 (0)