Skip to content

Improve Enum Parsing #326

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

Open
jkodroff opened this issue Jun 20, 2016 · 1 comment
Open

Improve Enum Parsing #326

jkodroff opened this issue Jun 20, 2016 · 1 comment

Comments

@jkodroff
Copy link

jkodroff commented Jun 20, 2016

Enum parsing is currently case-sensitive, which makes sense because C# is case-sensitive, but I think we might be able to make the parsing less particular about case and make things a little more intuitive. I'd be willing to do a PR if the powers that be are cool with it. I can think of 2 options off the top of my head:

  1. Allow all lower case values to be parsed.
  2. Allow the user to explicitly specify which parameter values get mapped to which enum members, e.g.
public enum MyEnum 
{
  [ParseArgument("valueone", "VALUEONE")]
  ValueOne
}

While there's nothing stopping someone from defining 2 enum members which only differ by case, it's probably a dumb thing to do so. In either case, it's difficult to 100% guarantee that the parsing will work for all cases b/c of case-sensitivity, but it should improve things for the overwhelming majority of use cases.

Let me know if either of these designs (or a combination of both) are appealing.

@nemec
Copy link
Collaborator

nemec commented Jun 20, 2016

Can you try the latest source code? This should have been fixed in #289.

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