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

Replace EnumUtils with a source generator #568

Open
Meir017 opened this issue Aug 7, 2024 · 1 comment · May be fixed by #585
Open

Replace EnumUtils with a source generator #568

Meir017 opened this issue Aug 7, 2024 · 1 comment · May be fixed by #585
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Meir017
Copy link
Contributor

Meir017 commented Aug 7, 2024

Feature request type

enhancement

Is your feature request related to a problem? Please describe

The logic in the EnumUtils is heavily relying on Dictionaries for optimizing the performance of converting the description attribute of an enum value to the enum and back

Describe the solution you'd like

We could do better and have a source generator generate static methods that have a fast switch-case that will perform better than looking up in a dictionary (and in some flows having additional logic)

Describe alternatives you've considered

No response

Additional context

we could use https://github.com/andrewlock/NetEscapades.EnumGenerators (see https://andrewlock.net/netescapades-enumgenerators-a-source-generator-for-enum-performance/) which also support the Description attribute

or maybe https://www.nuget.org/packages/Microsoft.Extensions.EnumStrings but it's not clear what the state of this is due to dotnet/extensions#4639

@Meir017
Copy link
Contributor Author

Meir017 commented Aug 7, 2024

I tried the following POC for this https://gist.github.com/Meir017/076cc5d2a96e2b1b12c190f3a48befc9

it still doesn't support Flags (ex: KeySpecificationFlags.RW | KeySpecificationFlags.Access)

@darrenge darrenge added the enhancement New feature or request label Aug 8, 2024
@badrishc badrishc added the help wanted Extra attention is needed label Aug 9, 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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants