From c5ebffee4a802c1c27345e08a5d355a4fa1b3f19 Mon Sep 17 00:00:00 2001 From: Jon Sequeira Date: Tue, 8 Jul 2025 13:15:15 -0700 Subject: [PATCH] make the non-generic Option and Argument ctors non-private --- src/System.CommandLine/Argument.cs | 6 +++++- src/System.CommandLine/Argument{T}.cs | 2 +- src/System.CommandLine/Option.cs | 7 ++++++- src/System.CommandLine/Option{T}.cs | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/System.CommandLine/Argument.cs b/src/System.CommandLine/Argument.cs index f278477afe..7df55ce93f 100644 --- a/src/System.CommandLine/Argument.cs +++ b/src/System.CommandLine/Argument.cs @@ -19,7 +19,11 @@ public abstract class Argument : Symbol private List>>? _completionSources = null; private List>? _validators = null; - private protected Argument(string name) : base(name, allowWhitespace: true) + /// + /// Initializes a new instance of the Argument class. + /// + /// The name of the argument. This can be used to look up the parsed value and is displayed in help + protected Argument(string name) : base(name, allowWhitespace: true) { } diff --git a/src/System.CommandLine/Argument{T}.cs b/src/System.CommandLine/Argument{T}.cs index 1100b70c13..2a9dd55592 100644 --- a/src/System.CommandLine/Argument{T}.cs +++ b/src/System.CommandLine/Argument{T}.cs @@ -15,7 +15,7 @@ public class Argument : Argument /// /// Initializes a new instance of the Argument class. /// - /// The name of the argument. It's not used for parsing, only when displaying Help or creating parse errors.> + /// The name of the argument. This can be used to look up the parsed value and is displayed in help public Argument(string name) : base(name) { } diff --git a/src/System.CommandLine/Option.cs b/src/System.CommandLine/Option.cs index c9d81062e7..bac26af4a2 100644 --- a/src/System.CommandLine/Option.cs +++ b/src/System.CommandLine/Option.cs @@ -17,7 +17,12 @@ public abstract class Option : Symbol internal AliasSet? _aliases; private List>? _validators; - private protected Option(string name, string[] aliases) : base(name) + /// + /// Initializes a new instance of the class. + /// + /// The name of the option. This is used during parsing and is displayed in help. + /// Optional aliases by which the option can be specified on the command line. + protected Option(string name, string[] aliases) : base(name) { if (aliases is { Length: > 0 }) { diff --git a/src/System.CommandLine/Option{T}.cs b/src/System.CommandLine/Option{T}.cs index dc65ee9c47..4cd08d9833 100644 --- a/src/System.CommandLine/Option{T}.cs +++ b/src/System.CommandLine/Option{T}.cs @@ -14,8 +14,8 @@ public class Option : Option /// /// Initializes a new instance of the class. /// - /// The name of the option. It's used for parsing, displaying Help and creating parse errors.> - /// Optional aliases. Used for parsing, suggestions and displayed in Help. + /// The name of the option. This is used during parsing and is displayed in help. + /// Optional aliases by which the option can be specified on the command line. public Option(string name, params string[] aliases) : this(name, aliases, new Argument(name)) {