Skip to content

Consider supporting shared code over enums #1400

Closed
@MichalStrehovsky

Description

@MichalStrehovsky

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions