-
Notifications
You must be signed in to change notification settings - Fork 481
Enums are not case insensitive #198
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
Comments
If you configure your own parser settings you can set
|
This didn't seem to have any effect. Maybe I'm doing it wrong but... |
Same issue here, CaseInsensitiveEnumValues has no effect |
Also experiencing the same issue using the latest v2.2.0 package. Setting CaseInsensitiveEnumValues = true has no effect. |
Also, I just upgraded from version 1.9.71 where CaseInsensitiveEnumValues used to be true by default. It appears that the new version (2.2.1) changes the default to be false... is this intentional? I think it would be more convenient to continue having the same default behavior as before. |
… and help text formatting (commandlineparser#236) bugs. ----- 1. Added ignoreValueCase param to methods in InstanceChooser.cs. Passed this arg through call stack. 2. Modified Parser.cs to use settings.CaseInsensitiveEnumValues. 3. Added NewLine before UsageHeadingText in HelpText.cs. 4. Commented-out Trim method call in HelpText.cs.
I'm running into the same issue, any chance the fix in #231 could be merged? |
Same here with version 2.2.1, the |
Can you provide a code sample that isn't working for you? I just tested the following in 2.2.1 and the case insensitive setting works as advertised. void Main()
{
var parser = new Parser(cfg => cfg.CaseInsensitiveEnumValues = true);
var results = parser.ParseArguments<Options>("-t two".Split())
.WithParsed<Options>(opts => opts.Dump())
.WithNotParsed<Options>((errs) => { });
}
public class Options
{
[Option('t', "test")]
public Test Test { get; set; }
}
public enum Test
{
One,
TWO
} |
@nemec Hello, thank you for your answer. I can confirm that the issue is still present, and that it is only happening when using the Consider this example: public enum SomeEnum
{
Hello,
World
}
public class SomeOptions
{
[Option('f')]
public SomeEnum Foo { get; set; }
}
[Verb("verb")]
public class SomeVerb : SomeOptions { }
[Verb("otherverb")]
public class SomeOtherVerb : SomeOptions { } The following snippet fails with a "BadFormatConversionError" error: var test = new[] { "verb", "-f", "world" };
var parser = new Parser(settings => settings.CaseInsensitiveEnumValues = true);
var result = parser.ParseArguments<SomeVerb, SomeOtherVerb>(test); Hope this helps! 😄 |
Having the same issue as @Sergio0694 . I think the default should be set to true. |
It would be nice if you merge this PR after so many months. |
Yeah, it's still not explained on wiki that the default value for this setting is actually false. |
First off: great job, guys!
Small issue: it looks like even though the wiki states that option properties bound to enum values are case insensitive:
unfortunately, they are not. I have a program that for a line like this:
where -t is bound to an
enum SettingType {Int, String, ...}
, I get an error:But if I enter the command like this:
all is good.
The text was updated successfully, but these errors were encountered: