Closed
Description
Reproduction:
var opt = new Option<bool>(new[] { "-b" }, "Some description");
var cmd = new RootCommand
{
opt
};
var res = cmd.Parse("-b");
Assert.True((bool)res.GetValueForOption((Option)opt));
It works if you pass "true", e.g. -b true
, or if you use the generic method directly.
I ended up adding this code to work around the issue:
// Here I only know that opt is some Option<>
if (opt.GetType() == typeof(Option<>).MakeGenericType(typeof(bool)))
{
res = bindingContext.ParseResult.GetValueForOption((Option<bool>)opt);
}