Skip to content

Implement EnumMetadataGenerator and Registry; remove EnumHelper class#321

Merged
shibayan merged 1 commit intomasterfrom
enum-source-generator
Feb 26, 2026
Merged

Implement EnumMetadataGenerator and Registry; remove EnumHelper class#321
shibayan merged 1 commit intomasterfrom
enum-source-generator

Conversation

@shibayan
Copy link
Copy Markdown
Owner

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:

  • Added the EnumMetadataGenerator source generator, which analyzes enum declarations at compile time and generates code to register their values and display names in EnumMetadataRegistry. This eliminates the need for runtime reflection and manual ordering.
  • Introduced the EnumMetadataRegistry static class, which stores enum metadata and provides methods for registering and retrieving enum values and their display names.

Removal of legacy reflection-based code:

  • Removed the 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:

  • Updated SelectOptions<T> and MultiSelectOptions<T> to use EnumMetadataRegistry for retrieving enum values and display names, replacing the old reflection-based approach. [1] [2]

Cleanup:

  • Removed unnecessary using Sharprompt.Internal; statements from files after eliminating the EnumHelper dependency. [1] [2]

… enum metadata handling; remove obsolete EnumHelper class
@shibayan shibayan self-assigned this Feb 26, 2026
@shibayan shibayan merged commit 313434f into master Feb 26, 2026
3 checks passed
@shibayan shibayan deleted the enum-source-generator branch February 26, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant