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 one parameter to specify members for int based enums #127

Closed
SteveDunn opened this issue Apr 27, 2024 · 1 comment
Closed

Allow one parameter to specify members for int based enums #127

SteveDunn opened this issue Apr 27, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@SteveDunn
Copy link
Owner

SteveDunn commented Apr 27, 2024

Describe the feature

Taken from this feature request: SteveDunn/Vogen#562

Instances of ints should allow just one parameter to describe members; the values of which start at zero and increment, just like normal enums

@SteveDunn
Copy link
Owner Author

This has now been implemented on a branch and will be merged shortly.
The syntax is:

[Members("Standard, Gold, Platinum")]
public partial class CustomerType;

I tried to extend the feature to take names and values, e.g.

[Members(("Standard", 100), ("Gold", 200), ("Platinum", 300)]

... but there is a restriction on parameters in attributes as described here: dotnet/csharplang#1979

The new 'params collections' in C# 13 won't help either as it's not possible to use IEnumerable<T>

@SteveDunn SteveDunn changed the title Allow one parameter for string instances Allow one parameter to specify members for int based enums Jun 4, 2024
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

1 participant