-
Notifications
You must be signed in to change notification settings - Fork 4.2k
update System.CommandLine to the latest version #68549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
stop using System.CommandLine.NamingConventionBinder as it's reflection based and won't be supported in the long term stop using ancient System.CommandLine.Experimental
| <add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" /> | ||
| <add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" /> | ||
| <add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" /> | ||
| <add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nine different dotnet feeds now ... I feel like we're making NuGet unnecessarily complicated.
|
|
||
| var parser = CreateCommandLineParser(); | ||
| return await parser.InvokeAsync(args); | ||
| return await parser.Parse(args).InvokeAsync(CancellationToken.None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What cancellation token should be going in here? Was the old behavior listening to Ctrl+C to raise the token or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs show InvokeAsync with no cancellationtoken. Might be one of our analyzers telling it to pass a cancellation token?
https://learn.microsoft.com/en-us/dotnet/standard/commandline/handle-termination
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever token we pass here, S.CL is going to create a source linked to it:
and create it's own token out of it, then request the cancellation when its Ctrl+C is pressed
jasonmalinowski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks OK, some questions about cancellation tokens but that could be done as a follow-up.
| var logLevelOption = new CliOption<LogLevel>("--logLevel") | ||
| { | ||
| var value = result.Tokens.Single().Value; | ||
| return !Enum.TryParse<LogLevel>(value, out var logLevel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dibarbet Were enums just not supported on the version we were on or was this necessary for some special reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't remember. If this works with VSCode then I'm good with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enums are now supported OOTB, I can not speak about the past as I've been involved in this project only for a year and a half
| cancellationToken); | ||
| }); | ||
|
|
||
| return generateCommand.Parse(args).InvokeAsync(CancellationToken.None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as earlier: what should go here for the token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as earlier: what should go here for the token?
If this is Main, then None.
If this was any other async method that would have it's own token, then that token.
stop using System.CommandLine.NamingConventionBinder as it's reflection based and won't be supported in the long term
stop using ancient System.CommandLine.Experimental
Contributes to dotnet/sdk#33157