adamabdelhamed / PowerArgs

The ultimate .NET Standard command line argument parser
MIT License
568 stars 56 forks source link

bool reviver not working #166

Open brandonh-msft opened 11 months ago

brandonh-msft commented 11 months ago

I have a property of type bool with the following attributes on it already:

    [ArgIgnoreCase]
    [ArgShortcut(ArgShortcutPolicy.NoShortcut)]
    [ArgRequired(IfNot = nameof(Suffix), PromptIfMissing = true)]
    [ArgDescription("Overwrites source files when modified. Defaults to false if unspecified. This or `-suffix` must be given.")]

However when I am prompted to enter a value (because I left it off the arguments), I enter true and am met with an exception:

System.Reflection.TargetException
  HResult=0x80131603
  Message=Object does not match target type.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Reflection.RuntimeMethodInfo.InvokePropertySetter(Object obj, BindingFlags invokeAttr, Binder binder, Object parameter, CultureInfo culture) in System.Reflection\RuntimeMethodInfo.cs:line 342

  This exception was originally thrown at this call stack:

Here is more stack trace detail:

>   PowerArgs.dll!PowerArgs.ArgRequiredConditionalHook.TryPreventExceptionWithPrompt(PowerArgs.ArgHook.HookContext context) Line 108    C#
    PowerArgs.dll!PowerArgs.ArgRequiredConditionalHook.Evaluate(PowerArgs.ArgHook.HookContext context, string expressionText, bool not) Line 54 C#
    PowerArgs.dll!PowerArgs.ArgRequiredConditionalHook.AfterPopulateProperties(PowerArgs.ArgHook.HookContext context) Line 35   C#
    PowerArgs.dll!PowerArgs.ArgHook.HookContext.RunAfterPopulateProperties.AnonymousMethod__39_1(PowerArgs.ArgHook h) Line 212  C#
    PowerArgs.dll!PowerArgs.ArgHook.HookContext.RunHook(System.Func<PowerArgs.ArgHook, int> orderby, System.Action<PowerArgs.ArgHook> hookAction) Line 187  C#
    PowerArgs.dll!PowerArgs.ArgHook.HookContext.RunAfterPopulateProperties() Line 213   C#
    PowerArgs.dll!PowerArgs.Args.ParseInternal(PowerArgs.CommandLineArgumentsDefinition definition, string[] input) Line 511    C#
    PowerArgs.dll!PowerArgs.Args.ParseAction.AnonymousMethod__0() Line 170  C#
    PowerArgs.dll!PowerArgs.Args.Execute<PowerArgs.ArgAction>(System.Func<PowerArgs.ArgAction> argsProcessingCode) Line 363 C#
    PowerArgs.dll!PowerArgs.Args.ParseAction(PowerArgs.CommandLineArgumentsDefinition definition, string[] args) Line 167   C#

I'm using PA v4.0.3