Skip to content

Commit

Permalink
#384: Added warning for unknown or duplicate command line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Sep 20, 2020
1 parent cbbe7a0 commit 16ca983
Show file tree
Hide file tree
Showing 19 changed files with 343 additions and 92 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Expand Up @@ -12,7 +12,7 @@ variables:
- name: disable.coverage.autogenerate
value: 'true'
- name: version
value: '4.6.7'
value: '4.7.0'

stages:
- stage: Build
Expand Down
4 changes: 2 additions & 2 deletions src/AzureDevopsTask/ReportGenerator/task.json
Expand Up @@ -12,8 +12,8 @@
"author": "Palmmedia",
"version": {
"Major": 4,
"Minor": 6,
"Patch": 7
"Minor": 7,
"Patch": 0
},
"instanceNameFormat": "ReportGenerator",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion src/AzureDevopsTask/vss-extension.json
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "reportgenerator",
"name": "ReportGenerator",
"version": "4.6.7",
"version": "4.7.0",
"publisher": "Palmmedia",
"public": true,
"targets": [
Expand Down
1 change: 1 addition & 0 deletions src/Readme.txt
Expand Up @@ -66,6 +66,7 @@ CHANGELOG
4.7.0.0

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

4.6.7.0

Expand Down
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -7,8 +7,8 @@
<AssemblyName>ReportGenerator</AssemblyName>
<RootNamespace>Palmmedia.ReportGenerator</RootNamespace>
<StartupObject>Palmmedia.ReportGenerator.Console.NetCore.Program</StartupObject>
<AssemblyVersion>4.6.7.0</AssemblyVersion>
<FileVersion>4.6.7.0</FileVersion>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<FileVersion>4.7.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/ReportGenerator.Console/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand All @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReportGenerator.Console")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.6.7.0")]
[assembly: AssemblyFileVersion("4.6.7.0")]
[assembly: AssemblyVersion("4.7.0.0")]
[assembly: AssemblyFileVersion("4.7.0.0")]
Expand Up @@ -84,7 +84,7 @@ public void ConfigProvidesMissingArguments()
{
var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(dir);
var config = Config.Build(dir).GetSection(ReportConfigurationBuilder.SectionName);
var config = Config.Build(dir).GetSection(DotNetConfigSettingNames.SectionName);

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

config.SetString("reports", ReportPath);

Expand Down
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Palmmedia.ReportGenerator.Core.Test</RootNamespace>
<AssemblyVersion>4.6.7.0</AssemblyVersion>
<FileVersion>4.6.7.0</FileVersion>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<FileVersion>4.7.0.0</FileVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

Expand Down
107 changes: 107 additions & 0 deletions src/ReportGenerator.Core/CommandLineArgumentNames.cs
@@ -0,0 +1,107 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Palmmedia.ReportGenerator.Core
{
/// <summary>
/// Name of the command line arguments.
/// </summary>
internal static class CommandLineArgumentNames
{
/// <summary>
/// The reports.
/// </summary>
public const string Reports = "REPORTS";

/// <summary>
/// The target directory.
/// </summary>
public const string TargetDirectory = "TARGETDIR";

/// <summary>
/// The source directories.
/// </summary>
public const string SourceDirectories = "SOURCEDIRS";

/// <summary>
/// The history directory.
/// </summary>
public const string HistoryDirectory = "HISTORYDIR";

/// <summary>
/// The report types.
/// </summary>
public const string ReportTypes = "REPORTTYPES";

/// <summary>
/// Single report type (deprecated).
/// </summary>
public const string ReportType = "REPORTTYPE";

/// <summary>
/// The plugins.
/// </summary>
public const string Plugins = "PLUGINS";

/// <summary>
/// The assembly filters.
/// </summary>
public const string AssemblyFilters = "ASSEMBLYFILTERS";

/// <summary>
/// The assembly filters (deprecated).
/// </summary>
public const string Filters = "FILTERS";

/// <summary>
/// Single class filter.
/// </summary>
public const string ClassFilters = "CLASSFILTERS";

/// <summary>
/// The file filters.
/// </summary>
public const string FileFilters = "FILEFILTERS";

/// <summary>
/// The verbosity.
/// </summary>
public const string Verbosity = "VERBOSITY";

/// <summary>
/// The title.
/// </summary>
public const string Title = "TITLE";

/// <summary>
/// The tag.
/// </summary>
public const string Tag = "TAG";

/// <summary>
/// All valid command line parameter names.
/// </summary>
private static readonly HashSet<string> ValidNames = new HashSet<string>(
typeof(CommandLineArgumentNames)
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
.Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(string))
.Select(x => (string)x.GetRawConstantValue())
.ToList());

/// <summary>
/// Gets a value indicating whether a command line parameter name is valid.
/// </summary>
/// <param name="name">The command line parameter name.</param>
/// <returns><c>true</c> if command line parameter is valid; otherwise <c>false</c>.</returns>
public static bool IsValid(string name)
{
if (name == null)
{
return false;
}

return ValidNames.Contains(name.ToUpperInvariant());
}
}
}
108 changes: 108 additions & 0 deletions src/ReportGenerator.Core/DotNetConfigSettingNames.cs
@@ -0,0 +1,108 @@
namespace Palmmedia.ReportGenerator.Core
{
/// <summary>
/// Name of configuration elements in .netconfig files.
/// </summary>
public static class DotNetConfigSettingNames
{
/// <summary>
/// Name of the configuration section in a .netconfig file.
/// </summary>
public const string SectionName = "ReportGenerator";

/// <summary>
/// The reports.
/// </summary>
public const string Reports = "reports";

/// <summary>
/// Single report.
/// </summary>
public const string Report = "report";

/// <summary>
/// The target directory.
/// </summary>
public const string TargetDirectory = "targetdir";

/// <summary>
/// The source directories.
/// </summary>
public const string SourceDirectories = "sourcedirs";

/// <summary>
/// Single source directory.
/// </summary>
public const string SourceDirectory = "sourcedir";

/// <summary>
/// The history directory.
/// </summary>
public const string HistoryDirectory = "historydir";

/// <summary>
/// The report types.
/// </summary>
public const string ReportTypes = "reporttypes";

/// <summary>
/// Single report type.
/// </summary>
public const string ReportType = "reporttype";

/// <summary>
/// The plugins.
/// </summary>
public const string Plugins = "plugins";

/// <summary>
/// Single plugin.
/// </summary>
public const string Plugin = "plugin";

/// <summary>
/// The assembly filters.
/// </summary>
public const string AssemblyFilters = "assemblyfilters";

/// <summary>
/// Single assembly filter.
/// </summary>
public const string AssemblyFilter = "assemblyfilter";

/// <summary>
/// The class filters.
/// </summary>
public const string ClassFilters = "classfilters";

/// <summary>
/// Single class filter.
/// </summary>
public const string ClassFilter = "classfilter";

/// <summary>
/// The file filters.
/// </summary>
public const string FileFilters = "filefilters";

/// <summary>
/// Single file filter.
/// </summary>
public const string FileFilter = "filefilter";

/// <summary>
/// The verbosity.
/// </summary>
public const string Verbosity = "verbosity";

/// <summary>
/// The title.
/// </summary>
public const string Title = "title";

/// <summary>
/// The tag.
/// </summary>
public const string Tag = "tag";
}
}
20 changes: 19 additions & 1 deletion src/ReportGenerator.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/ReportGenerator.Core/Properties/Resources.resx
Expand Up @@ -150,6 +150,9 @@
<data name="DefaultReportBuilderReplaced" xml:space="preserve">
<value>The default report builder for report type '{0}' was replaced.</value>
</data>
<data name="DuplicateCommandLineParameter" xml:space="preserve">
<value>Duplicate command line parameter '{0}'. Using value '{1}'</value>
</data>
<data name="ErrorCoverageFormat" xml:space="preserve">
<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>
</data>
Expand Down Expand Up @@ -298,6 +301,9 @@
<data name="TargetDirectoryCouldNotBeCreated" xml:space="preserve">
<value>The target directory '{0}' could not be created: {1}</value>
</data>
<data name="UnknownCommandLineParameter" xml:space="preserve">
<value>Unknown command line parameter '{0}'</value>
</data>
<data name="UnknownReportType" xml:space="preserve">
<value>Unknown report type '{0}'.</value>
</data>
Expand Down

0 comments on commit 16ca983

Please sign in to comment.