-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
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
GetEnumDescriptionor 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 ornull. -
Ensure the method works across different .NET versions if applicable.
Thank you.