Skip to content

Commit b9a0d16

Browse files
committed
update System.CommandLine version and add nuget.config
1 parent 5d352ca commit b9a0d16

File tree

4 files changed

+42
-33
lines changed

4 files changed

+42
-33
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
<LangVersion>12.0</LangVersion>
1818
<NoWarn>$(NoWarn);NU1507;NU5105;CS1591;NU1608;NU1900</NoWarn>
1919
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20-
<RestoreSources>
20+
<!--<RestoreSources>
2121
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json
2222
https://api.nuget.org/v3/index.json;
23-
</RestoreSources>
23+
</RestoreSources>-->
2424
<!--<UsingMicrosoftArtifactsSdk>true</UsingMicrosoftArtifactsSdk>-->
2525
<!-- https://learn.microsoft.com/en-us/dotnet/core/sdk/artifacts-output -->
2626
<!-- C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.DefaultOutputPaths.targets -->

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<PackageVersion Include="ReportGenerator.Core" Version="5.3.11" />
4040
<!--For test issue 809 https://github.com/coverlet-coverage/coverlet/issues/809-->
4141
<PackageVersion Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.7" />
42-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.24528.1" />
42+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.25072.1" />
4343
<!--To test issue 1104 https://github.com/coverlet-coverage/coverlet/issues/1104-->
4444
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
4545
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
@@ -48,9 +48,9 @@
4848
<PackageVersion Include="System.Reflection.Metadata" Version="8.0.1" />
4949
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
5050
<PackageVersion Include="Tmds.ExecFunction" Version="0.8.0" />
51-
<PackageVersion Include="xunit" Version="2.9.2" />
51+
<PackageVersion Include="xunit" Version="2.9.3" />
5252
<PackageVersion Include="xunit.assemblyfixture" Version="2.2.0" />
53-
<PackageVersion Include="xunit.assert" Version="2.9.2" />
53+
<PackageVersion Include="xunit.assert" Version="2.9.3" />
5454
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
5555
<PackageVersion Include="System.Buffers" Version="4.6.0" />
5656
<PackageVersion Include="System.Memory" Version="4.6.0" />

nuget.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
7+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
8+
</packageSources>
9+
</configuration>

src/coverlet.console/Program.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Toni Solarin-Sodara
1+
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System;
@@ -30,31 +30,31 @@ public static class Program
3030
static int s_exitCode;
3131
static async Task Main(string[] args)
3232
{
33-
CliArgument<string> moduleOrAppDirectory = new ("path") { Description = "Path to the test assembly or application directory." };
34-
CliOption<string> target = new ("--target", aliases: new[]{ "--target", "-t" }) { Description = "Path to the test runner application." , Arity = ArgumentArity.ZeroOrOne, Required = true };
35-
CliOption<string> targs = new ("--targetargs", aliases: new[] { "--targetargs", "-a" } ) { Description = "Arguments to be passed to the test runner.", Arity = ArgumentArity.ZeroOrOne };
36-
CliOption<string> output = new ("--output", aliases: new[] { "--output", "-o" }) { Description = "Output of the generated coverage report", Arity = ArgumentArity.ZeroOrOne };
37-
CliOption<LogLevel> verbosity = new ("--verbosity", aliases: new[] { "--verbosity", "-v" }) { DefaultValueFactory = (_) => LogLevel.Normal, Description = "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.", Arity = ArgumentArity.ZeroOrOne };
38-
CliOption<string[]> formats = new ("--format", aliases: new[] { "--format", "-f" }) { DefaultValueFactory = (_) => new[] { "json" }, Description = "Format of the generated coverage report.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
39-
CliOption<string> threshold = new ("--threshold") { Description = "Exits with error if the coverage % is below value.", Arity = ArgumentArity.ZeroOrOne };
40-
CliOption<List<string>> thresholdTypes = new ("--threshold-type") { DefaultValueFactory = (_) => new List<string>(new string[] { "line", "branch", "method" }), Description = ("Coverage type to apply the threshold to.")};
33+
Argument<string> moduleOrAppDirectory = new("path") { Description = "Path to the test assembly or application directory." };
34+
Option<string> target = new("--target", aliases: new[] { "--target", "-t" }) { Description = "Path to the test runner application.", Arity = ArgumentArity.ZeroOrOne, Required = true };
35+
Option<string> targs = new("--targetargs", aliases: new[] { "--targetargs", "-a" }) { Description = "Arguments to be passed to the test runner.", Arity = ArgumentArity.ZeroOrOne };
36+
Option<string> output = new("--output", aliases: new[] { "--output", "-o" }) { Description = "Output of the generated coverage report", Arity = ArgumentArity.ZeroOrOne };
37+
Option<LogLevel> verbosity = new("--verbosity", aliases: new[] { "--verbosity", "-v" }) { DefaultValueFactory = (_) => LogLevel.Normal, Description = "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.", Arity = ArgumentArity.ZeroOrOne };
38+
Option<string[]> formats = new("--format", aliases: new[] { "--format", "-f" }) { DefaultValueFactory = (_) => new[] { "json" }, Description = "Format of the generated coverage report.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
39+
Option<string> threshold = new("--threshold") { Description = "Exits with error if the coverage % is below value.", Arity = ArgumentArity.ZeroOrOne };
40+
Option<List<string>> thresholdTypes = new("--threshold-type") { DefaultValueFactory = (_) => new List<string>(new string[] { "line", "branch", "method" }), Description = ("Coverage type to apply the threshold to.") };
4141
thresholdTypes.AcceptOnlyFromAmong("line", "branch", "method");
42-
CliOption<ThresholdStatistic> thresholdStat = new ("--threshold-stat") {DefaultValueFactory = (_) => ThresholdStatistic.Minimum, Description = "Coverage statistic used to enforce the threshold value." , Arity = ArgumentArity.ZeroOrOne };
43-
CliOption<string[]> excludeFilters = new ("--exclude") { Description = "Filter expressions to exclude specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
44-
CliOption<string[]> includeFilters = new ("--include") { Description = "Filter expressions to include only specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
45-
CliOption<string[]> excludedSourceFiles = new ("--exclude-by-file") { Description = "Glob patterns specifying source files to exclude.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
46-
CliOption<string[]> includeDirectories = new("--include-directory") { Description = "Include directories containing additional assemblies to be instrumented.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
47-
CliOption<string[]> excludeAttributes = new ("--exclude-by-attribute") { Description = "Attributes to exclude from code coverage.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
48-
CliOption<bool> includeTestAssembly = new ("--include-test-assembly") { Description = "Specifies whether to report code coverage of the test assembly.", Arity = ArgumentArity.Zero };
49-
CliOption<bool> singleHit = new ("--single-hit") { Description = "Specifies whether to limit code coverage hit reporting to a single hit for each location", Arity = ArgumentArity.Zero };
50-
CliOption<bool> skipAutoProp = new ("--skipautoprops") { Description = "Neither track nor record auto-implemented properties.", Arity = ArgumentArity.Zero };
51-
CliOption<string> mergeWith = new ("--merge-with") { Description = "Path to existing coverage result to merge.", Arity = ArgumentArity.ZeroOrOne };
52-
CliOption<bool> useSourceLink = new ("--use-source-link") { Description = "Specifies whether to use SourceLink URIs in place of file system paths.", Arity = ArgumentArity.Zero };
53-
CliOption<string[]> doesNotReturnAttributes = new ("--does-not-return-attribute") { Description = "Attributes that mark methods that do not return", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
54-
CliOption<string> excludeAssembliesWithoutSources = new ("--exclude-assemblies-without-sources") { Description = "Specifies behaviour of heuristic to ignore assemblies with missing source documents.", Arity = ArgumentArity.ZeroOrOne };
55-
CliOption<string> sourceMappingFile = new ("--source-mapping-file") { Description = "Specifies the path to a SourceRootsMappings file.", Arity = ArgumentArity.ZeroOrOne };
56-
57-
CliRootCommand rootCommand = new("Cross platform .NET Core code coverage tool")
42+
Option<ThresholdStatistic> thresholdStat = new("--threshold-stat") { DefaultValueFactory = (_) => ThresholdStatistic.Minimum, Description = "Coverage statistic used to enforce the threshold value.", Arity = ArgumentArity.ZeroOrOne };
43+
Option<string[]> excludeFilters = new("--exclude") { Description = "Filter expressions to exclude specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
44+
Option<string[]> includeFilters = new("--include") { Description = "Filter expressions to include only specific modules and types.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
45+
Option<string[]> excludedSourceFiles = new("--exclude-by-file") { Description = "Glob patterns specifying source files to exclude.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
46+
Option<string[]> includeDirectories = new("--include-directory") { Description = "Include directories containing additional assemblies to be instrumented.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
47+
Option<string[]> excludeAttributes = new("--exclude-by-attribute") { Description = "Attributes to exclude from code coverage.", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
48+
Option<bool> includeTestAssembly = new("--include-test-assembly") { Description = "Specifies whether to report code coverage of the test assembly.", Arity = ArgumentArity.Zero };
49+
Option<bool> singleHit = new("--single-hit") { Description = "Specifies whether to limit code coverage hit reporting to a single hit for each location", Arity = ArgumentArity.Zero };
50+
Option<bool> skipAutoProp = new("--skipautoprops") { Description = "Neither track nor record auto-implemented properties.", Arity = ArgumentArity.Zero };
51+
Option<string> mergeWith = new("--merge-with") { Description = "Path to existing coverage result to merge.", Arity = ArgumentArity.ZeroOrOne };
52+
Option<bool> useSourceLink = new("--use-source-link") { Description = "Specifies whether to use SourceLink URIs in place of file system paths.", Arity = ArgumentArity.Zero };
53+
Option<string[]> doesNotReturnAttributes = new("--does-not-return-attribute") { Description = "Attributes that mark methods that do not return", Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
54+
Option<string> excludeAssembliesWithoutSources = new("--exclude-assemblies-without-sources") { Description = "Specifies behaviour of heuristic to ignore assemblies with missing source documents.", Arity = ArgumentArity.ZeroOrOne };
55+
Option<string> sourceMappingFile = new("--source-mapping-file") { Description = "Specifies the path to a SourceRootsMappings file.", Arity = ArgumentArity.ZeroOrOne };
56+
57+
RootCommand rootCommand = new("Cross platform .NET Core code coverage tool")
5858
{
5959
moduleOrAppDirectory,
6060
target,
@@ -82,7 +82,7 @@ static async Task Main(string[] args)
8282
rootCommand.Add(new HelpOption());
8383
rootCommand.Add(new VersionOption());
8484

85-
ParseResult parseResult = CliParser.Parse(rootCommand, args);
85+
ParseResult parseResult = CommandLineParser.Parse(rootCommand, args);
8686

8787
rootCommand.SetAction(async (context) =>
8888
{
@@ -138,7 +138,7 @@ static async Task Main(string[] args)
138138

139139
});
140140

141-
CliConfiguration config = new(rootCommand);
141+
CommandLineConfiguration config = new(rootCommand);
142142

143143
await config.InvokeAsync(args).ConfigureAwait(false);
144144
Environment.Exit(s_exitCode);
@@ -392,7 +392,7 @@ string sourceMappingFile
392392
}
393393
logger.LogError(errorMessageBuilder.ToString());
394394
}
395-
395+
396396
return Task.FromResult(s_exitCode);
397397

398398
}

0 commit comments

Comments
 (0)