Skip to content

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

@koddek

Description

@koddek

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions