Skip to content

Conversation

@jkotas
Copy link
Member

@jkotas jkotas commented Jul 9, 2022

No description provided.

@ghost ghost assigned jkotas Jul 9, 2022
@ghost
Copy link

ghost commented Jul 9, 2022

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: jkotas
Assignees: jkotas
Labels:

area-System.Reflection

Milestone: -

@jkotas
Copy link
Member Author

jkotas commented Jul 9, 2022

This makes Enum.GetUnderlyingType about 6x faster.

@jkotas jkotas force-pushed the GetUnderlyingType branch 2 times, most recently from 7443c81 to 9ae0a8d Compare July 9, 2022 06:19
@jkotas jkotas requested a review from marek-safar as a code owner July 9, 2022 06:48
@jkotas jkotas force-pushed the GetUnderlyingType branch from d305f74 to 139088e Compare July 9, 2022 11:34
@jkotas
Copy link
Member Author

jkotas commented Jul 9, 2022

I am going to revert the change for IsEnum. It is behavior change for generic variables. We do not have a test coverage for it. The test coverage needs to be fixed first.

@jkotas jkotas added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 9, 2022
@jkotas
Copy link
Member Author

jkotas commented Jul 9, 2022

For example, this prints true currently, but it would print false with this change:

Type param = typeof(MyG<>).GetGenericArguments()[0];
Console.WriteLine(param.IsEnum);

class MyG<T> where T: Enum
{
}

@jkotas
Copy link
Member Author

jkotas commented Jul 9, 2022

And this fails with Internal CLR error. currently:

Type param = typeof(MyG<>).GetGenericArguments()[0];
Console.WriteLine(Enum.GetUnderlyingType(param));

class MyG<T> where T: Enum
{
}

@jkotas jkotas force-pushed the GetUnderlyingType branch from 139088e to b7c0fa2 Compare July 9, 2022 18:42
@jkotas
Copy link
Member Author

jkotas commented Jul 9, 2022

And this fails with Internal CLR error. currently:

Opened #71884

@jkotas jkotas removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 9, 2022
@jkotas jkotas merged commit ef29389 into dotnet:main Jul 10, 2022
@jkotas jkotas deleted the GetUnderlyingType branch July 10, 2022 01:01
@EgorBo
Copy link
Member

EgorBo commented Jul 14, 2022

Improvements on win-arm64: dotnet/perf-autofiling-issues#6757

@dakersnar
Copy link
Contributor

Improvements on ubuntu arm64: dotnet/perf-autofiling-issues#6982

@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants