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

Allow to add new Enumeration #683

Open
alajaber-th opened this issue Sep 20, 2022 · 3 comments
Open

Allow to add new Enumeration #683

alajaber-th opened this issue Sep 20, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@alajaber-th
Copy link

as you allowed me to add a defined new Function to power-fx, Like this:
var config = new PowerFxConfig(); config.AddFunction(new HelpFunction()); var engine = new RecalcEngine(config);

I want to allowed me to defined new Enumeration for example:
{ EnumConstants.GenderEnumString, "%s[Male:\"male\", Female:\"female\", Other:\"other\"]" }

@MikeStall
Copy link
Contributor

@alajaber-th
Copy link
Author

I think that will help me to create new Enum, but it's limited because it takes Only KeyPair<string, string> and I need to be for example KeyPair<string, int>

@lesaltzm
Copy link
Contributor

Yes, that's intended. The current Enum implementation is not something we'd like to expand, it's not as type safe as Option Sets, and we'd prefer that any uses without back-compat considerations build on the safer option.

Do you have a use case where the stringified ints as the "logical" names wouldn't be sufficient? Given that it's typesafe, if you have a custom function that expects an option set value of your option set, you should be able to safely call int.TryParse on the value.

@MikeStall MikeStall added the enhancement New feature or request label Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants