-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make S.CL builder DSLs more transferable #50685
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
|
This PR is targeting |
1efb89e to
704e9a9
Compare
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.
Pull Request Overview
This PR refactors the command-line option and argument infrastructure by:
- Extracting command-line extensions into a new
Microsoft.DotNet.Cli.CommandLineproject to improve modularity and reusability - Replacing interface-based dynamic option/argument markers (
IDynamicOption,IDynamicArgument) with property-based extension methods (IsDynamic) - Replacing the
ForwardedOption<T>class hierarchy with extension methods on standardOption<T>types - Consolidating documentation link handling through extension properties instead of the
ICommandDocumentinterface - Removing specialized option classes (
DynamicOption,DynamicForwardedOption,DocumentedCommand) in favor of standard types with extensions
Reviewed Changes
Copilot reviewed 99 out of 99 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/Cli/Microsoft.DotNet.Cli.CommandLine/ (new project) |
New library containing reusable command-line extensions for forwarding, documentation, dynamic completions, and result navigation |
src/Cli/dotnet/CommonOptions.cs |
Updated to use standard Option<T> with extension methods instead of custom option classes |
src/Cli/dotnet/Extensions/OptionForwardingExtensions.cs |
Removed ForwardedOption<T> class and IForwardedOption interface, now handled by new project |
src/Cli/dotnet/Extensions/ParseResultExtensions.cs |
Moved utility methods to Microsoft.DotNet.Cli.CommandLine |
src/System.CommandLine.StaticCompletions/ |
Removed IDynamicOption and IDynamicArgument interfaces; replaced with IsDynamic property via extensions |
| Command parser files (multiple) | Updated to use standard Command with DocsLink extension instead of DocumentedCommand |
| Test files (multiple) | Updated using statements to reference new Microsoft.DotNet.Cli.CommandLine namespace |
src/Cli/Microsoft.DotNet.Cli.CommandLine/ForwardedOptionExtensions.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Reference/Add/ReferenceAddCommandParser.cs
Outdated
Show resolved
Hide resolved
64978b7 to
824484f
Compare
|
This is green at last @MiYanni! |
|
/backport to release/10.0.2xx |
|
Started backporting to |
|
@baronfel backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: add new project and move some base-layer stuff over
.git/rebase-apply/patch:111: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M sdk.slnx
M src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs
M src/Cli/dotnet/Commands/Package/Remove/PackageRemoveCommand.cs
M src/Cli/dotnet/Commands/Run/RunCommand.cs
M src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M src/Cli/dotnet/Commands/Test/TestCommandParser.cs
M src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs
M src/Cli/dotnet/Commands/Tool/Install/ToolInstallGlobalOrToolPathCommand.cs
M src/Cli/dotnet/dotnet.csproj
Falling back to patching base and 3-way merge...
Auto-merging sdk.slnx
Auto-merging src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs
Auto-merging src/Cli/dotnet/Commands/Package/Remove/PackageRemoveCommand.cs
Auto-merging src/Cli/dotnet/Commands/Run/RunCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/TestCommandParser.cs
Auto-merging src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs
Auto-merging src/Cli/dotnet/Commands/Tool/Install/ToolInstallGlobalOrToolPathCommand.cs
Auto-merging src/Cli/dotnet/dotnet.csproj
Applying: Replace marker-interface dynamic completion with runtime-data-based variant.
Applying: forwarding is also just a set of extensions
Applying: Documentation links are now a separate feature as well, provided by extension members
error: sha1 information is lacking or useless (src/Cli/dotnet/Commands/Test/TestCommandParser.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0004 Documentation links are now a separate feature as well, provided by extension members
Error: The process '/usr/bin/git' failed with exit code 128 |
Co-authored-by: Marc Paine <marcpop@microsoft.com>
This refactors all of our additional layers of functionality on top of System.CommandLine to be implemented in terms of C# 13 extension members. This has the major benefit of removing the inheritance-hierarchy hell/matrix of pain that we had already been struggling with as we create more feature-adds.
Each separate feature slice has been extracted into a separate 'slice' into a new CLI-extensibility project. The slices are
I also added a helper for making options and arguments for any type that supports
ISpanParsable<T>- we should move to this overall in the CLI to get us away from the reflection-based default parsing in System.CommandLine over time, and we should lean into this mechanism to support new user-defined types.Everything else is just adjusting to that core change.