Skip to content
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

Merged
merged 7 commits into from May 20, 2022
Merged

AsString() Enums support added #1307

merged 7 commits into from May 20, 2022

Conversation

Duzij
Copy link
Contributor

@Duzij Duzij commented Feb 22, 2022

After a short coding session with @tomasherceg, enums support was added to .AsString() method.
Solution is not ideal and need further discussion.

@@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args => args[1].Clone()
args => args[1]

@exyi exyi added this to the Version 4.1 milestone Mar 24, 2022
Copy link
Contributor

@quigamdev quigamdev left a 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
Copy link
Member

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

@exyi exyi merged commit 3406162 into riganti:main May 20, 2022
@acizmarik acizmarik mentioned this pull request Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants