@@ -57,11 +57,13 @@ static CommandLineApplication()
5757 private readonly ConventionContext _conventionContext ;
5858 private readonly List < IConvention > _conventions = new List < IConvention > ( ) ;
5959
60+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
6061 /// <summary>
6162 /// Initializes a new instance of <see cref="CommandLineApplication"/>.
6263 /// </summary>
6364 /// <param name="throwOnUnexpectedArg">Initial value for <see cref="ThrowOnUnexpectedArgument"/>.</param>
6465 public CommandLineApplication ( bool throwOnUnexpectedArg = true )
66+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
6567 : this ( null , DefaultHelpTextGenerator . Singleton , new DefaultCommandLineContext ( ) , throwOnUnexpectedArg )
6668 {
6769 }
@@ -470,6 +472,7 @@ private void AssertCommandNameIsUnique(string? name, CommandLineApplication? com
470472 }
471473 }
472474
475+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
473476 /// <summary>
474477 /// Adds a subcommand.
475478 /// </summary>
@@ -478,6 +481,7 @@ private void AssertCommandNameIsUnique(string? name, CommandLineApplication? com
478481 /// <param name="throwOnUnexpectedArg"></param>
479482 /// <returns></returns>
480483 public CommandLineApplication Command ( string name , Action < CommandLineApplication > configuration ,
484+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
481485 bool throwOnUnexpectedArg = true )
482486 {
483487 var command = new CommandLineApplication ( this , name , throwOnUnexpectedArg ) ;
@@ -489,6 +493,7 @@ public CommandLineApplication Command(string name, Action<CommandLineApplication
489493 return command ;
490494 }
491495
496+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
492497 /// <summary>
493498 /// Adds a subcommand with model of type <typeparamref name="TModel" />.
494499 /// </summary>
@@ -498,6 +503,7 @@ public CommandLineApplication Command(string name, Action<CommandLineApplication
498503 /// <typeparam name="TModel">The model type of the subcommand.</typeparam>
499504 /// <returns></returns>
500505 public CommandLineApplication < TModel > Command < TModel > ( string name , Action < CommandLineApplication < TModel > > configuration ,
506+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
501507 bool throwOnUnexpectedArg = true )
502508 where TModel : class
503509 {
@@ -592,6 +598,7 @@ public CommandOption<T> Option<T>(string template, string description, CommandOp
592598 return option ;
593599 }
594600
601+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
595602 /// <summary>
596603 /// Adds a command line argument
597604 /// </summary>
@@ -600,8 +607,10 @@ public CommandOption<T> Option<T>(string template, string description, CommandOp
600607 /// <param name="multipleValues"></param>
601608 /// <returns></returns>
602609 public CommandArgument Argument ( string name , string description , bool multipleValues = false )
610+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
603611 => Argument ( name , description , _ => { } , multipleValues ) ;
604612
613+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
605614 /// <summary>
606615 /// Adds a command line argument.
607616 /// </summary>
@@ -611,6 +620,7 @@ public CommandArgument Argument(string name, string description, bool multipleVa
611620 /// <param name="multipleValues"></param>
612621 /// <returns></returns>
613622 public CommandArgument Argument ( string name , string description , Action < CommandArgument > configuration , bool multipleValues = false )
623+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
614624 {
615625 var argument = new CommandArgument
616626 {
@@ -623,6 +633,7 @@ public CommandArgument Argument(string name, string description, Action<CommandA
623633 return argument ;
624634 }
625635
636+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
626637 /// <summary>
627638 /// Adds a command line argument with values that should be parsable into <typeparamref name="T" />.
628639 /// </summary>
@@ -633,6 +644,7 @@ public CommandArgument Argument(string name, string description, Action<CommandA
633644 /// <typeparam name="T">The type of the values on the option</typeparam>
634645 /// <returns></returns>
635646 public CommandArgument < T > Argument < T > ( string name , string description , Action < CommandArgument > configuration , bool multipleValues = false )
647+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
636648 {
637649 var parser = ValueParsers . GetParser < T > ( ) ;
638650
@@ -801,6 +813,7 @@ public int Execute(params string[] args)
801813 return ExecuteAsync ( args ) . GetAwaiter ( ) . GetResult ( ) ;
802814 }
803815
816+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
804817 /// <summary>
805818 /// Parses an array of strings using <see cref="Parse(string[])"/>.
806819 /// <para>
@@ -820,6 +833,7 @@ public int Execute(params string[] args)
820833 /// <param name="cancellationToken"></param>
821834 /// <returns>The return code from <see cref="Invoke"/>.</returns>
822835 public async Task < int > ExecuteAsync ( string [ ] args , CancellationToken cancellationToken = default )
836+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
823837 {
824838 var parseResult = Parse ( args ) ;
825839 var command = parseResult . SelectedCommand ;
@@ -900,6 +914,7 @@ public CommandOption HelpOption(string template, bool inherited)
900914 return OptionHelp ;
901915 }
902916
917+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
903918 /// <summary>
904919 /// Helper method that adds a version option from known versions strings.
905920 /// </summary>
@@ -908,6 +923,7 @@ public CommandOption HelpOption(string template, bool inherited)
908923 /// <param name="longFormVersion"></param>
909924 /// <returns></returns>
910925 public CommandOption VersionOption ( string template ,
926+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
911927 string ? shortFormVersion ,
912928 string ? longFormVersion = null )
913929 {
@@ -921,6 +937,7 @@ public CommandOption VersionOption(string template,
921937 }
922938 }
923939
940+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
924941 /// <summary>
925942 /// Helper method that adds a version option.
926943 /// </summary>
@@ -929,6 +946,7 @@ public CommandOption VersionOption(string template,
929946 /// <param name="longFormVersionGetter"></param>
930947 /// <returns></returns>
931948 public CommandOption VersionOption ( string template ,
949+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
932950 Func < string ? > ? shortFormVersionGetter ,
933951 Func < string ? > ? longFormVersionGetter = null )
934952 {
@@ -995,7 +1013,9 @@ public void ShowHelp(bool usePager)
9951013 [ Obsolete ( "This method has been marked as obsolete and will be removed in a future version. " +
9961014 "The recommended replacement is ShowHelp()" ) ]
9971015 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
1016+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
9981017 public void ShowHelp ( string ? commandName = null )
1018+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
9991019 {
10001020 if ( commandName == null )
10011021 {
0 commit comments