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
AsString() Enums support added #1307
Conversation
@@ -203,6 +203,9 @@ private void AddDefaultToStringTranslations() | |||
{ | |||
AddMethodTranslator(typeof(object), "ToString", new PrimitiveToStringTranslator(), 0); | |||
AddMethodTranslator(typeof(Convert), "ToString", new PrimitiveToStringTranslator(), 1, true); | |||
AddMethodTranslator(typeof(ReflectionUtils), "ToEnumString", parameterCount: 1, translator: new GenericMethodCompiler( | |||
args => args[1].Clone() |
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.
args => args[1].Clone() | |
args => args[1] |
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.
Looks good to me.
@@ -503,7 +494,7 @@ public static string GetTypeHash(this Type type) | |||
return name; | |||
} | |||
|
|||
internal static class EnumInfo<T> where T: struct, Enum | |||
internal static class EnumInfo<T> where T: Enum |
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.
The struct is rather important here to avoid using EnumInfo<T>
on the Enum type itself
After a short coding session with @tomasherceg, enums support was added to .AsString() method.
Solution is not ideal and need further discussion.