Closed
Description
We could potentially do code sharing for enums that have the same underlying type. It would fix the issue that the non-generic Enum.GetValues
currently needs to be marked AOT unfriendly, or that ASP.NET needs to do workarounds like dotnet/aspnetcore#35167 when reflection-activating Enum.TryParse<T>
.
I would explicitly not go as far as code sharing with the underlying primitive type (List<SomeEnum>
and List<int>
would not canonicalize into the same thing) because typeof(T) == typeof(byte)
and friends are often used for generic specialization in high performance code.
I'm not aware of enums being used for generic specialization in this sense, so maybe shared code for enums would be an acceptable compromise?