-
Notifications
You must be signed in to change notification settings - Fork 48
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
add support for System.ComponentModel.DescriptionAttribute
#15
Comments
That seems reasonable to me! As in #11, I'm not entirely sure what the support should look like. Should it only affect |
I don't really have an opinion on that topic, but what I'm regularly using is a combination of custom extension methods to parse forth and back. (e.g. |
I have always used => value switch
{
Colour.Red => "The red description"
Colour.Blue => "The blue description"
Colour.Green => nameof(Colour.Green), // when not having the attribute,
_ => value.ToString()
} |
I don't think it's a good idea to return the string GetDescription(Color color) => color switch
{
Color.Red => "The red description",
Color.Blue => "The blue description",
_ => string.Empty,
}; Or: bool GetDescription(Color color, out string description)
{
switch (color)
{
case Color.Red:
description = "The red description";
return true;
case Color.Blue:
description = "The blue description";
return true;
default:
description = string.Empty;
return false;
}
} |
Similar to #11 it would be nice to add support for the
System.ComponentModel.DescriptionAttribute
.At least I use it far more often than the
System.ComponentModel.DataAnnotations.DisplayAttribute
.example:
The text was updated successfully, but these errors were encountered: