Skip to content

Commit 57240a5

Browse files
committed
Revert "Merge pull request #90 from yatagarasu25/params_arguments_patch"
This reverts commit 4a19ccb.
1 parent 4a19ccb commit 57240a5

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

src/ConsoleAppFramework/CommandHelpBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,24 +305,24 @@ internal CommandHelpDefinition CreateCommandHelpDefinition(CommandDescriptor des
305305
var isFlag = item.ParameterType == typeof(bool);
306306

307307
var defaultValue = default(string);
308-
if (item.HasDefaultValue())
308+
if (item.HasDefaultValue)
309309
{
310310
if (option?.DefaultValue != null)
311311
{
312312
defaultValue = option.DefaultValue;
313313
}
314314
else
315315
{
316-
defaultValue = (item.DefaultValue()?.ToString() ?? "null");
316+
defaultValue = (item.DefaultValue?.ToString() ?? "null");
317317
}
318318
if (isFlag)
319319
{
320-
if (item.DefaultValue() is true)
320+
if (item.DefaultValue is true)
321321
{
322322
// bool option with true default value is not flag.
323323
isFlag = false;
324324
}
325-
else if (item.DefaultValue() is false)
325+
else if (item.DefaultValue is false)
326326
{
327327
// false default value should be omitted for flag.
328328
defaultValue = null;

src/ConsoleAppFramework/ConsoleAppEngine.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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,20 +346,13 @@ bool TryGetInvokeArguments(ParameterInfo[] parameters, string?[] args, int argsO
346346
var elemType = UnwrapCollectionElementType(parameters[i].ParameterType);
347347
if (elemType == typeof(string))
348348
{
349-
if (parameters.Length == i + 1)
350-
{
351-
v = "[" + string.Join(",", optionByIndex.Skip(parameters[i].Position).Select(x => "\"" + x.Value + "\"")) + "]";
349+
if (!(v.StartsWith("\"") && v.EndsWith("\"")))
350+
{
351+
v = "[" + string.Join(",", v.Split(' ', ',').Select(x => "\"" + x + "\"")) + "]";
352352
}
353353
else
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-
}
354+
{
355+
v = "[" + v + "]";
363356
}
364357
}
365358
else
@@ -408,9 +401,9 @@ bool TryGetInvokeArguments(ParameterInfo[] parameters, string?[] args, int argsO
408401
}
409402
}
410403

411-
if (item.HasDefaultValue())
404+
if (item.HasDefaultValue)
412405
{
413-
invokeArgs[i] = item.DefaultValue();
406+
invokeArgs[i] = item.DefaultValue;
414407
}
415408
else if (item.ParameterType == typeof(bool))
416409
{

src/ConsoleAppFramework/ParameterInfoExtensions.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)