-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
_nameFunc = () => name; | ||
} | ||
|
||
public EnumGroupAndName(string group, Func<string> name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't decide if we should Obsolete
the old constructor. My instinct was no, to allow people to do the simple thing if they didn't need anything complex, but I fear that will lead to ignoring the new constructor and getting us right back into the same spot.
Also, going back to add comments to this and any new public methods now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not sure if it needs to be obsoleted. If the docs just said precisely what it did and didn't do, that would seem to be fine.
I'll take reviewing this one. |
When submitting the final commit, please update the description to avoid the implication that |
/// </summary> | ||
/// <param name="group">The group name.</param> | ||
/// <param name="name">A function which returns the name. (Necessary for proper localization.)</param> | ||
public EnumGroupAndName(string group, Func<string> name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should [Obsolete]
the old constructor and file a 2.0 bug about removing it.
What bug number? Do we have anything tracking the bug or either of the gaps mentioned in the description? Not sure about doing the three separate pieces in one PR. I'm not confident the added tests are covering each bit sufficiently. |
⌚ |
5b2a912
to
ae50929
Compare
🆙📅 I started to split this up into three separate PR's but they're connected enough that it was going to take more time than I though was really prudent to spend on it. Are there any specific test case you feel are missing? |
/// <summary> | ||
/// Initializes a new instance of the EnumGroupAndName structure. | ||
/// Initializes a new instance of the EnumGroupAndName structure. Should not be used if localization is in use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "in use" mean? This method should not be used in any site where users may choose multiple locales.
public void CreateDisplayMetadata_EnumGroupedDisplayNamesAndValues_NameWithIStringLocalizer() | ||
{ | ||
// Arrange & Act | ||
var enumNameAndGroup = GetLocalizedEnumGroupedDisplayNamesAndValues(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enumGroupAndName
⌚ mainly for |
@@ -728,6 +779,46 @@ public void CreateDisplayMetadata_IsFlagsEnum_ReflectsModelType(Type type, bool | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateDisplayMetadata_EnumGroupedDisplayNamesAndValues_ReflectsModelType
fails with our new EnumGroupAndName.Equals because all the EnumGroupAndName's in the MemberData don't use FieldInfo
(and thus _displayattribute). Would it be enough for this test to check that the Name and group values on EnumGroupedDisplayNamesAndValues
are what they should be? Because changing the MemberData to use the FieldInfo's would be basically testing that it equals itself, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, best to check Name
and Group
in that test. Might want to create a EnumGroupAndNameComparer
if that needs to be done in more than one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈 this comment thread is no longer relevant.
🆙📅 Good idea on the comparer, made it much cleaner than the silly foreach zip I had started trying to do. |
🆙📅 |
/// Initializes a new instance of the EnumGroupAndName structure. | ||
/// </summary> | ||
/// <param name="group">The group name.</param> | ||
/// <param name="name">A func which will return the name</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End w/ a period.
⌚ for some cleanup |
🆙📅 |
public static string DisplayAttribute_Description { get; } = Resources.DisplayAttribute_Description; | ||
public static string Type_Three_Name => "type three name " + CultureInfo.CurrentCulture; | ||
public static string Type_Three_Description => "type three description " + CultureInfo.CurrentCulture; | ||
public static string Type_Three_Prompt => "type three prompt " + CultureInfo.CurrentCulture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double-check that [ReplaceCulture]
or using (new CultureReplacer(...))
is used in all tests referencing the CurrentCulture
properties from this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, didn't notice Type_Three_Description
and Type_Three_Prompt
aren't referenced. Remove those two.
⌚ for the last couple of wrinkles to be ironed out. |
69c912b
to
a02f29f
Compare
🆙📅 |
w/ one removal and a better commit description. Also mention the relevant bugs. |
@dougbu are you talking about the actual commit message or about the Pull Request description? Because I already added the # for the 3 bugs and removed (to my eyes) the implication that it's only about localization on the Pull Request description. |
a02f29f
to
68bc79e
Compare
This PR addresses a bug and a couple missing features.
The bug (#5198) is that Enum display values would previously store the first value that was used and always use that. By passing a function which returns a Name value to the constructor of EnumGroupAndName and executing that when we need the name we avoid this.
One missing feature is #5197, that
GetEnumSelectList
was checking the DisplayAttributes for values to display, but it wasn't localizing those values like other uses of DisplayAttributes do.The other missing feature was #4215. It boils down to that
Html.DisplayFor
didn't pay attention to DisplayAttributes on enums, and consequently didn't localize them.