Discord-Net-Labs / Discord.Net-Labs

An experimental fork of Discord.Net that implements the newest discord features for testing and development to eventually get merged into Discord.Net
https://labs.discordnet.dev
MIT License
156 stars 42 forks source link

Display name support for enum type converter #407

Closed XenotropicDev closed 2 years ago

XenotropicDev commented 2 years ago

This PR adds basic support for enum's that have been decorated with the DisplayAttribute from System.ComponentModel.DataAnnotations.

I went with DisplayAttribute over other options because a lot of peoples enums might already be using this attribute from things like MVC, and it has support for localization. However doing so requires changing the project references to include the annotations library for the net461, and netstandard tagets (support is included in the core.app package for net5+). So if it would be better to use a custom attribute to avoid adding this package please let me know and I can modify the pull request.

Cenngo commented 2 years ago

not sure if adding a dependency just to use one attribute is ideal. I think creating a custom attribute for this is better.

XenotropicDev commented 2 years ago

not sure if adding a dependency just to use one attribute is ideal. I think creating a custom attribute for this is better.

Sounds good to me, I will update the PR with a custom attribute class instead.

XenotropicDev commented 2 years ago

I updated the PR to no longer include any new dependencies, and added an internal attribute ChoiceDisplayAttribute.

Please re-review.