-
Notifications
You must be signed in to change notification settings - Fork 15
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
Generator for enum values #4
Comments
Hi @CollinAlpert |
Hi! I'm glad you enjoy the library. And thanks for chiming in. I can definitely add a generator for this. It could consider And what would a fitting attribute name be? |
@CollinAlpert
The attribute name could be |
Available in v2.3.0 |
I am working on a generator which is supposed to generate a static property or method called
Values
which would return an enum's members. This would alleviate the need of the reflection-basedEnum.GetValues()
approach and would also be statically typed.However, I am running into design issues. Enums can't be partial which means the source generator couldn't simply plug in and add a static property. I also thought about extension method, but this would require a specific enum field and I want to add a static property on the enum type.
The best I can currently come up with is the following:
The generator would then produce the following code:
But from a users's standpoint, that design is less than ideal. Please leave a comment here if you are interested in this feature and if so, what design would work best for you.
The text was updated successfully, but these errors were encountered: