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

[REQ] Add Method to Retrieve Enum Field Description #73

Open
koddek opened this issue Jan 21, 2025 · 0 comments
Open

[REQ] Add Method to Retrieve Enum Field Description #73

koddek opened this issue Jan 21, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@koddek
Copy link

koddek commented Jan 21, 2025

Description:

Please consider implementing a new method that allows retrieving the description of an enum field when using the [Description] attribute. This feature is particularly useful when you do not have control over the API, and thus cannot switch from using [Description] to [Label] attributes for enum descriptions.

Example Use Case:

enum Company
{
    [Description("Apple, Inc.")]
    Apple = 0,
}

// Proposed new method usage
var description = Company.Apple.GetEnumDescription();  // Should return "Apple, Inc."

Request Details:

  • Functionality: Add a method named GetEnumDescription or similar to FastEnum which returns the string value of the [Description] attribute associated with an enum value.

  • Purpose: To enable developers to easily access enum descriptions even when they cannot modify the enum definition to use alternative attributes like [Label].

Implementation Considerations:

  • The method should handle cases where no [Description] attribute is present, perhaps by returning the enum name or null.

  • Ensure the method works across different .NET versions if applicable.

Thank you.

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

2 participants