You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding is that there is currently DehumanizeTo extension that is intended to work exactly in reverse of Humanize.
At the same time, it is not necessarily what I expect as a user of the library.
publicenumExampleEnum{[Display(Name ="The foo", Description ="something about what effect Foo makes")]Foo,[Display(Name ="The bar", Description ="something about what effect Bar makes")]Bar,}
I don't expect to parse input string in the format of description.
I expect the input script to be the best approximation of a parseable name.
And so, I think the reasonable string-to-value dictionary may consist of normalized strings taken from ToString value, display name, description, whatever else can be located in the attributes...
Current implementation prioritizes Description and takes only one string:
I don't understand the utility of this. It breaks valid usage scenarios.
And it seems that for a workaround I have to reimplement a custom dehumanizer from scratch.
By extension, if I need the Humanize function - I will face the same issue - I don't necessarily need the description - I may prefer to:
use Name attribute if it is available;
or humanize ToString value.
To resolve both problems, alternative implementation to current EnumCache and extensions might be conceived, probably in parallel to the existing one to avoid breaking change.
It may be not exactly what I expect it to be to solve each direction issue, but I'd like this to be a started for a discussion at least.
Seems like Humanizer might've been around before System.ComponentModel.DataAnnotations.DisplayAttribute and is still based on more limited assumptions.
My understanding is that there is currently
DehumanizeTo
extension that is intended to work exactly in reverse ofHumanize
.At the same time, it is not necessarily what I expect as a user of the library.
I don't expect to parse input string in the format of description.
I expect the input script to be the best approximation of a parseable name.
And so, I think the reasonable string-to-value dictionary may consist of normalized strings taken from
ToString
value, display name, description, whatever else can be located in the attributes...Current implementation prioritizes Description and takes only one string:
Humanizer/src/Humanizer/EnumCache.cs
Lines 64 to 73 in 3d80235
I don't understand the utility of this. It breaks valid usage scenarios.
And it seems that for a workaround I have to reimplement a custom dehumanizer from scratch.
This is probably related to #700.
By extension, if I need the
Humanize
function - I will face the same issue - I don't necessarily need the description - I may prefer to:ToString
value.To resolve both problems, alternative implementation to current
EnumCache
and extensions might be conceived, probably in parallel to the existing one to avoid breaking change.It may be not exactly what I expect it to be to solve each direction issue, but I'd like this to be a started for a discussion at least.
Seems like Humanizer might've been around before
System.ComponentModel.DataAnnotations.DisplayAttribute
and is still based on more limited assumptions.From DisplayAttribute.cs:
Name
ShortName
Description
Prompt
GroupName
Of those, I only really see
Name
andShortName
as well suitable for de/humanization.The text was updated successfully, but these errors were encountered: