Implement EnumMetadataGenerator and Registry; remove EnumHelper class#321
Merged
Implement EnumMetadataGenerator and Registry; remove EnumHelper class#321
Conversation
… enum metadata handling; remove obsolete EnumHelper class
This was referenced Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new source generator for enum metadata and refactors how enum values and their display names are handled throughout the codebase. The main improvement is replacing runtime reflection-based enum metadata extraction with a compile-time approach, improving performance and maintainability. It also updates the option classes to utilize the new registry for enum display names and ordering.
Enum metadata generation and registration:
EnumMetadataGeneratorsource generator, which analyzes enum declarations at compile time and generates code to register their values and display names inEnumMetadataRegistry. This eliminates the need for runtime reflection and manual ordering.EnumMetadataRegistrystatic class, which stores enum metadata and provides methods for registering and retrieving enum values and their display names.Removal of legacy reflection-based code:
EnumHelper<TEnum>class, which previously used reflection to extract enum metadata at runtime. This is now handled by the source generator and registry.Integration with option classes:
SelectOptions<T>andMultiSelectOptions<T>to useEnumMetadataRegistryfor retrieving enum values and display names, replacing the old reflection-based approach. [1] [2]Cleanup:
using Sharprompt.Internal;statements from files after eliminating theEnumHelperdependency. [1] [2]