Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when adding key-value arguments #1

Open
bambuk6 opened this issue Feb 27, 2021 · 1 comment
Open

Exception when adding key-value arguments #1

bambuk6 opened this issue Feb 27, 2021 · 1 comment

Comments

@bambuk6
Copy link

bambuk6 commented Feb 27, 2021

I believe the below code is valid but it throws an exception.

public static void Main(string[] args)
  {
    var extra = new Dictionary<string, string>();
    string configFile;

    var p = new OptionSet{
        {"c|config", v => configFile = v},
        {"p|pair", (string key, string val) => extra.Add(key, val)}
    };

    p.Parse(args);
  }

Exception:

Unhandled exception. System.InvalidOperationException: Invalid ValueType with MaximumParameterCount of 2, expecting Optional or Required.
   at NConsole.Options.Option.VerifyMaximumParameterCount()
   at NConsole.Options.Option..ctor(String prototype, String description)
   at NConsole.Options.InvokableActionOption`1..ctor(String prototype, String description, TCallback callback)
   at NConsole.Options.KeyValueActionOption`2..ctor(String prototype, String description, OptionCallback`2 callback)
   at NConsole.Options.OptionSet.<>c__DisplayClass22_0`2.<Add>b__0()
   at NConsole.Options.OptionSet.Add(Delegate callback, Func`1 optionFactory)
   at NConsole.Options.OptionSet.Add[TKey,TValue](String prototype, String description, OptionCallback`2 callback)
   at NConsole.Options.OptionSet.Add(String prototype, String description, OptionCallback`2 callback)
   at NConsole.Options.OptionSet.Add(String prototype, OptionCallback`2 callback)
   at Program.Main(String[] args) in C:\Users\Alex\Projects\CSProbe\Program.cs:line 208

@mwpowellhtx
Copy link
Owner

@bambuk6 Thanks for the report. It is probably a bug in the Option class. That said, I am not actively maintaining it, so feel free to troubleshoot and submit a PR. I'll consider that and repackage as appropriate. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants