@@ -106,7 +106,7 @@ public async Task RunAsync()
106106 if ( commandDescriptor . CommandType == CommandType . DefaultCommand && args . Length == 0 )
107107 {
108108 var p = commandDescriptor . MethodInfo . GetParameters ( ) ;
109- if ( p . Any ( x => ! ( x . ParameterType == typeof ( ConsoleAppContext ) || isService . IsService ( x . ParameterType ) || x . HasDefaultValue ) ) )
109+ if ( p . Any ( x => ! ( x . ParameterType == typeof ( ConsoleAppContext ) || isService . IsService ( x . ParameterType ) || x . HasDefaultValue ( ) ) ) )
110110 {
111111 options . CommandDescriptors . TryGetHelpMethod ( out commandDescriptor ) ;
112112 }
@@ -294,7 +294,7 @@ bool TryGetInvokeArguments(ParameterInfo[] parameters, string?[] args, int argsO
294294 {
295295 if ( optionByIndex . Count <= option . Index )
296296 {
297- if ( ! item . HasDefaultValue )
297+ if ( ! item . HasDefaultValue ( ) )
298298 {
299299 throw new InvalidOperationException ( $ "Required argument { option . Index } was not found in specified arguments.") ;
300300 }
@@ -346,13 +346,20 @@ bool TryGetInvokeArguments(ParameterInfo[] parameters, string?[] args, int argsO
346346 var elemType = UnwrapCollectionElementType ( parameters [ i ] . ParameterType ) ;
347347 if ( elemType == typeof ( string ) )
348348 {
349- if ( ! ( v . StartsWith ( " \" " ) && v . EndsWith ( " \" " ) ) )
350- {
351- v = "[" + string . Join ( "," , v . Split ( ' ' , ',' ) . Select ( x => "\" " + x + "\" " ) ) + "]" ;
349+ if ( parameters . Length == i + 1 )
350+ {
351+ v = "[" + string . Join ( "," , optionByIndex . Skip ( parameters [ i ] . Position ) . Select ( x => "\" " + x . Value + "\" " ) ) + "]" ;
352352 }
353353 else
354- {
355- v = "[" + v + "]" ;
354+ {
355+ if ( ! ( v . StartsWith ( "\" " ) && v . EndsWith ( "\" " ) ) )
356+ {
357+ v = "[" + string . Join ( "," , v . Split ( ' ' , ',' ) . Select ( x => "\" " + x + "\" " ) ) + "]" ;
358+ }
359+ else
360+ {
361+ v = "[" + v + "]" ;
362+ }
356363 }
357364 }
358365 else
@@ -401,9 +408,9 @@ bool TryGetInvokeArguments(ParameterInfo[] parameters, string?[] args, int argsO
401408 }
402409 }
403410
404- if ( item . HasDefaultValue )
411+ if ( item . HasDefaultValue ( ) )
405412 {
406- invokeArgs [ i ] = item . DefaultValue ;
413+ invokeArgs [ i ] = item . DefaultValue ( ) ;
407414 }
408415 else if ( item . ParameterType == typeof ( bool ) )
409416 {
0 commit comments