Skip to content

Commit 2e283d9

Browse files
authored
Update .NET 10, System.CommandLine 2.0.0, fix warnings (#2677)
1 parent db1aa59 commit 2e283d9

File tree

26 files changed

+441
-421
lines changed

26 files changed

+441
-421
lines changed

Directory.Packages.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project>
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<MicrosoftAspNetCoreAppPackageVersion>10.0.0-preview.6.25358.103</MicrosoftAspNetCoreAppPackageVersion>
4+
<MicrosoftAspNetCoreAppPackageVersion>10.0.0</MicrosoftAspNetCoreAppPackageVersion>
55
<MicrosoftAspNetCoreApp9PackageVersion>9.0.4</MicrosoftAspNetCoreApp9PackageVersion>
66
<MicrosoftAspNetCoreApp8PackageVersion>8.0.15</MicrosoftAspNetCoreApp8PackageVersion>
77
<GrpcDotNetPackageVersion>2.70.0</GrpcDotNetPackageVersion>
88
<OpenTelemetryPackageVersion>1.6.0</OpenTelemetryPackageVersion>
99
<OpenTelemetryIntergationPackageVersion>1.8.1</OpenTelemetryIntergationPackageVersion>
1010
<OpenTelemetryGrpcPackageVersion>1.8.0-beta.1</OpenTelemetryGrpcPackageVersion>
11-
<MicrosoftExtensionsPackageVersion>10.0.0-preview.6.25358.103</MicrosoftExtensionsPackageVersion>
11+
<MicrosoftExtensionsPackageVersion>10.0.0</MicrosoftExtensionsPackageVersion>
1212
<MicrosoftExtensionsLtsPackageVersion>8.0.0</MicrosoftExtensionsLtsPackageVersion>
1313
</PropertyGroup>
1414
<ItemGroup>
@@ -65,7 +65,7 @@
6565
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
6666
<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.5" />
6767
<PackageVersion Include="Microsoft.Build" Version="17.3.2" />
68-
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.0-preview.25358.103" />
68+
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.100" />
6969
<PackageVersion Include="Microsoft.Crank.EventSources" Version="0.2.0-alpha.25128.2" />
7070
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
7171
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
@@ -76,8 +76,7 @@
7676
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
7777
<PackageVersion Include="protobuf-net.Grpc.AspNetCore" Version="1.0.140" />
7878
<PackageVersion Include="protobuf-net.Grpc" Version="1.0.140" />
79-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
80-
<PackageVersion Include="System.CommandLine.Rendering" Version="0.4.0-alpha.22272.1" />
79+
<PackageVersion Include="System.CommandLine" Version="2.0.0" />
8180
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="6.0.1" />
8281
<PackageVersion Include="System.Memory" Version="4.5.3" />
8382
<PackageVersion Include="System.Net.Http.WinHttpHandler" Version="8.0.3" />
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env
22
WORKDIR /app
33

44
# Copy everything
@@ -8,7 +8,7 @@ RUN dotnet restore examples/Container/Backend
88
RUN dotnet publish examples/Container/Backend -c Release -o out
99

1010
# Build runtime image
11-
FROM mcr.microsoft.com/dotnet/aspnet:10.0-preview
11+
FROM mcr.microsoft.com/dotnet/aspnet:10.0
1212
WORKDIR /app
1313
COPY --from=build-env /app/out .
1414
ENTRYPOINT ["dotnet", "Backend.dll"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env
22
WORKDIR /app
33

44
# Copy everything
@@ -8,7 +8,7 @@ RUN dotnet restore examples/Container/Frontend
88
RUN dotnet publish examples/Container/Frontend -c Release -o out
99

1010
# Build runtime image
11-
FROM mcr.microsoft.com/dotnet/aspnet:10.0-preview
11+
FROM mcr.microsoft.com/dotnet/aspnet:10.0
1212
WORKDIR /app
1313
COPY --from=build-env /app/out .
1414
ENTRYPOINT ["dotnet", "Frontend.dll"]

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "10.0.100-preview.6.25358.103",
3+
"version": "10.0.100",
44
"rollForward": "latestFeature"
55
}
66
}

perf/benchmarkapps/GrpcClient/Program.cs

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -62,66 +62,66 @@ class Program
6262

6363
public static async Task<int> Main(string[] args)
6464
{
65-
var urlOption = new Option<Uri>(new string[] { "-u", "--url" }, "The server url to request") { IsRequired = true };
66-
var udsFileNameOption = new Option<string>(new string[] { "--udsFileName" }, "The Unix Domain Socket file name");
67-
var namedPipeNameOption = new Option<string>(new string[] { "--namedPipeName" }, "The Named Pipe name");
68-
var connectionsOption = new Option<int>(new string[] { "-c", "--connections" }, () => 1, "Total number of connections to keep open");
69-
var warmupOption = new Option<int>(new string[] { "-w", "--warmup" }, () => 5, "Duration of the warmup in seconds");
70-
var durationOption = new Option<int>(new string[] { "-d", "--duration" }, () => 10, "Duration of the test in seconds");
71-
var callCountOption = new Option<int?>(new string[] { "--callCount" }, "Call count of test");
72-
var scenarioOption = new Option<string>(new string[] { "-s", "--scenario" }, "Scenario to run") { IsRequired = true };
73-
var latencyOption = new Option<bool>(new string[] { "-l", "--latency" }, () => false, "Whether to collect detailed latency");
74-
var protocolOption = new Option<string>(new string[] { "-p", "--protocol" }, "HTTP protocol") { IsRequired = true };
75-
var logOption = new Option<LogLevel>(new string[] { "-log", "--logLevel" }, () => LogLevel.None, "The log level to use for Console logging");
76-
var requestSizeOption = new Option<int>(new string[] { "--requestSize" }, "Request payload size");
77-
var responseSizeOption = new Option<int>(new string[] { "--responseSize" }, "Response payload size");
78-
var grpcClientTypeOption = new Option<GrpcClientType>(new string[] { "--grpcClientType" }, () => GrpcClientType.GrpcNetClient, "Whether to use Grpc.NetClient or Grpc.Core client");
79-
var streamsOption = new Option<int>(new string[] { "--streams" }, () => 1, "Maximum concurrent streams per connection");
80-
var enableCertAuthOption = new Option<bool>(new string[] { "--enableCertAuth" }, () => false, "Flag indicating whether client sends a client certificate");
81-
var deadlineOption = new Option<int>(new string[] { "--deadline" }, "Duration of deadline in seconds");
82-
var winHttpHandlerOption = new Option<bool>(new string[] { "--winhttphandler" }, () => false, "Whether to use WinHttpHandler with Grpc.Net.Client");
65+
var urlOption = new Option<Uri>("--url", ["-u"]) { Description = "The server url to request", Required = true };
66+
var udsFileNameOption = new Option<string>("--udsFileName") { Description = "The Unix Domain Socket file name" };
67+
var namedPipeNameOption = new Option<string>("--namedPipeName") { Description = "The Named Pipe name" };
68+
var connectionsOption = new Option<int>("--connections", ["-c"]) { DefaultValueFactory = (r) => 1, Description = "Total number of connections to keep open" };
69+
var warmupOption = new Option<int>("--warmup", ["-w"]) { DefaultValueFactory = (r) => 5, Description = "Duration of the warmup in seconds" };
70+
var durationOption = new Option<int>("--duration", ["-d"]) { DefaultValueFactory = (r) => 10, Description = "Duration of the test in seconds" };
71+
var callCountOption = new Option<int?>("--callCount") { Description = "Call count of test" };
72+
var scenarioOption = new Option<string>("--scenario", ["-s"]) { Description = "Scenario to run", Required = true };
73+
var latencyOption = new Option<bool>("--latency", ["-l"]) { DefaultValueFactory = (r) => false, Description = "Whether to collect detailed latency" };
74+
var protocolOption = new Option<string>("--protocol", ["-p"]) { Description = "HTTP protocol", Required = true };
75+
var logOption = new Option<LogLevel>("--logLevel", ["-log"]) { DefaultValueFactory = (_) => LogLevel.None, Description = "The log level to use for Console logging" };
76+
var requestSizeOption = new Option<int>("--requestSize") { Description = "Request payload size" };
77+
var responseSizeOption = new Option<int>("--responseSize") { Description = "Response payload size" };
78+
var grpcClientTypeOption = new Option<GrpcClientType>("--grpcClientType") { DefaultValueFactory = (r) => GrpcClientType.GrpcNetClient, Description = "Whether to use Grpc.NetClient or Grpc.Core client" };
79+
var streamsOption = new Option<int>("--streams") { DefaultValueFactory = (r) => 1, Description = "Maximum concurrent streams per connection" };
80+
var enableCertAuthOption = new Option<bool>("--enableCertAuth") { DefaultValueFactory = (r) => false, Description = "Flag indicating whether client sends a client certificate" };
81+
var deadlineOption = new Option<int>("--deadline") { Description = "Duration of deadline in seconds" };
82+
var winHttpHandlerOption = new Option<bool>("--winhttphandler") { DefaultValueFactory = (r) => false, Description = "Whether to use WinHttpHandler with Grpc.Net.Client" };
8383

8484
var rootCommand = new RootCommand();
85-
rootCommand.AddOption(urlOption);
86-
rootCommand.AddOption(udsFileNameOption);
87-
rootCommand.AddOption(namedPipeNameOption);
88-
rootCommand.AddOption(connectionsOption);
89-
rootCommand.AddOption(warmupOption);
90-
rootCommand.AddOption(durationOption);
91-
rootCommand.AddOption(callCountOption);
92-
rootCommand.AddOption(scenarioOption);
93-
rootCommand.AddOption(latencyOption);
94-
rootCommand.AddOption(protocolOption);
95-
rootCommand.AddOption(logOption);
96-
rootCommand.AddOption(requestSizeOption);
97-
rootCommand.AddOption(responseSizeOption);
98-
rootCommand.AddOption(grpcClientTypeOption);
99-
rootCommand.AddOption(streamsOption);
100-
rootCommand.AddOption(enableCertAuthOption);
101-
rootCommand.AddOption(deadlineOption);
102-
rootCommand.AddOption(winHttpHandlerOption);
103-
104-
rootCommand.SetHandler(async (InvocationContext context) =>
85+
rootCommand.Add(urlOption);
86+
rootCommand.Add(udsFileNameOption);
87+
rootCommand.Add(namedPipeNameOption);
88+
rootCommand.Add(connectionsOption);
89+
rootCommand.Add(warmupOption);
90+
rootCommand.Add(durationOption);
91+
rootCommand.Add(callCountOption);
92+
rootCommand.Add(scenarioOption);
93+
rootCommand.Add(latencyOption);
94+
rootCommand.Add(protocolOption);
95+
rootCommand.Add(logOption);
96+
rootCommand.Add(requestSizeOption);
97+
rootCommand.Add(responseSizeOption);
98+
rootCommand.Add(grpcClientTypeOption);
99+
rootCommand.Add(streamsOption);
100+
rootCommand.Add(enableCertAuthOption);
101+
rootCommand.Add(deadlineOption);
102+
rootCommand.Add(winHttpHandlerOption);
103+
104+
rootCommand.SetAction(async (ParseResult context) =>
105105
{
106106
_options = new ClientOptions();
107-
_options.Url = context.ParseResult.GetValueForOption(urlOption);
108-
_options.UdsFileName = context.ParseResult.GetValueForOption(udsFileNameOption);
109-
_options.NamedPipeName = context.ParseResult.GetValueForOption(namedPipeNameOption);
110-
_options.Connections = context.ParseResult.GetValueForOption(connectionsOption);
111-
_options.Warmup = context.ParseResult.GetValueForOption(warmupOption);
112-
_options.Duration = context.ParseResult.GetValueForOption(durationOption);
113-
_options.CallCount = context.ParseResult.GetValueForOption(callCountOption);
114-
_options.Scenario = context.ParseResult.GetValueForOption(scenarioOption);
115-
_options.Latency = context.ParseResult.GetValueForOption(latencyOption);
116-
_options.Protocol = context.ParseResult.GetValueForOption(protocolOption);
117-
_options.LogLevel = context.ParseResult.GetValueForOption(logOption);
118-
_options.RequestSize = context.ParseResult.GetValueForOption(requestSizeOption);
119-
_options.ResponseSize = context.ParseResult.GetValueForOption(responseSizeOption);
120-
_options.GrpcClientType = context.ParseResult.GetValueForOption(grpcClientTypeOption);
121-
_options.Streams = context.ParseResult.GetValueForOption(streamsOption);
122-
_options.EnableCertAuth = context.ParseResult.GetValueForOption(enableCertAuthOption);
123-
_options.Deadline = context.ParseResult.GetValueForOption(deadlineOption);
124-
_options.WinHttpHandler = context.ParseResult.GetValueForOption(winHttpHandlerOption);
107+
_options.Url = context.GetValue(urlOption);
108+
_options.UdsFileName = context.GetValue(udsFileNameOption);
109+
_options.NamedPipeName = context.GetValue(namedPipeNameOption);
110+
_options.Connections = context.GetValue(connectionsOption);
111+
_options.Warmup = context.GetValue(warmupOption);
112+
_options.Duration = context.GetValue(durationOption);
113+
_options.CallCount = context.GetValue(callCountOption);
114+
_options.Scenario = context.GetValue(scenarioOption);
115+
_options.Latency = context.GetValue(latencyOption);
116+
_options.Protocol = context.GetValue(protocolOption);
117+
_options.LogLevel = context.GetValue(logOption);
118+
_options.RequestSize = context.GetValue(requestSizeOption);
119+
_options.ResponseSize = context.GetValue(responseSizeOption);
120+
_options.GrpcClientType = context.GetValue(grpcClientTypeOption);
121+
_options.Streams = context.GetValue(streamsOption);
122+
_options.EnableCertAuth = context.GetValue(enableCertAuthOption);
123+
_options.Deadline = context.GetValue(deadlineOption);
124+
_options.WinHttpHandler = context.GetValue(winHttpHandlerOption);
125125

126126
var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";
127127
var isServerGC = GCSettings.IsServerGC;
@@ -160,7 +160,8 @@ public static async Task<int> Main(string[] args)
160160

161161
Log("gRPC Client");
162162

163-
return await rootCommand.InvokeAsync(args);
163+
var result = rootCommand.Parse(args);
164+
return await result.InvokeAsync();
164165
}
165166

166167
#if NET9_0_OR_GREATER

src/dotnet-grpc/Commands/AddFileCommand.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Copyright notice and license
1+
#region Copyright notice and license
22

33
// Copyright 2019 The gRPC Authors
44
//
@@ -25,7 +25,7 @@ namespace Grpc.Dotnet.Cli.Commands;
2525

2626
internal sealed class AddFileCommand : CommandBase
2727
{
28-
public AddFileCommand(IConsole console, string? projectPath, HttpClient httpClient)
28+
public AddFileCommand(ConsoleService console, string? projectPath, HttpClient httpClient)
2929
: base(console, projectPath, httpClient) { }
3030

3131
public static Command Create(HttpClient httpClient)
@@ -38,40 +38,40 @@ public static Command Create(HttpClient httpClient)
3838
var serviceOption = CommonOptions.ServiceOption();
3939
var additionalImportDirsOption = CommonOptions.AdditionalImportDirsOption();
4040
var accessOption = CommonOptions.AccessOption();
41-
var filesArgument = new Argument<string[]>
41+
var filesArgument = new Argument<string[]>("files")
4242
{
43-
Name = "files",
4443
Description = CoreStrings.AddFileCommandArgumentDescription,
4544
Arity = ArgumentArity.OneOrMore
4645
};
4746

48-
command.AddOption(projectOption);
49-
command.AddOption(serviceOption);
50-
command.AddOption(accessOption);
51-
command.AddOption(additionalImportDirsOption);
52-
command.AddArgument(filesArgument);
47+
command.Add(projectOption);
48+
command.Add(serviceOption);
49+
command.Add(accessOption);
50+
command.Add(additionalImportDirsOption);
51+
command.Add(filesArgument);
5352

54-
command.SetHandler(
53+
command.SetAction(
5554
async (context) =>
5655
{
57-
var project = context.ParseResult.GetValueForOption(projectOption);
58-
var services = context.ParseResult.GetValueForOption(serviceOption);
59-
var access = context.ParseResult.GetValueForOption(accessOption);
60-
var additionalImportDirs = context.ParseResult.GetValueForOption(additionalImportDirsOption);
61-
var files = context.ParseResult.GetValueForArgument(filesArgument);
56+
var project = context.GetValue(projectOption);
57+
var services = context.GetValue(serviceOption);
58+
var access = context.GetValue(accessOption);
59+
var additionalImportDirs = context.GetValue(additionalImportDirsOption);
60+
var files = context.GetValue(filesArgument) ?? [];
6261

62+
var console = new ConsoleService(context.InvocationConfiguration.Output, context.InvocationConfiguration.Error);
6363
try
6464
{
65-
var command = new AddFileCommand(context.Console, project, httpClient);
65+
var command = new AddFileCommand(console, project, httpClient);
6666
await command.AddFileAsync(services, access, additionalImportDirs, files);
6767

68-
context.ExitCode = 0;
68+
return 0;
6969
}
7070
catch (CLIToolException e)
7171
{
72-
context.Console.LogError(e);
72+
console.LogError(e);
7373

74-
context.ExitCode = -1;
74+
return -1;
7575
}
7676
});
7777

0 commit comments

Comments
 (0)