Ensure `GetCorElementType` returns value type for enums on Mono runtime (#72685)
authormathieubourgeois <mathieu.bourgeois@gameloft.com>
Mon, 25 Jul 2022 13:16:29 +0000 (09:16 -0400)
committerGitHub <noreply@github.com>
Mon, 25 Jul 2022 13:16:29 +0000 (09:16 -0400)
commita1468ed70bc03626c31af5e0b0630ef98000c78f
tree219d6fc6839dd30dfcd1e4e8f7ad73dc32abf2ab
parent98d38413991ca37a7ea5aafab3872794522a5d9f
Ensure `GetCorElementType` returns value type for enums on Mono runtime (#72685)

`Type.GetTypeCode` on Mono was calling `GetCorElementType`, which, when invoked on an enum nested in a generic class, would return `TypeCode.Object` instead of `TypeCode.Int32`. Matching to CoreClr, we change `GetCorElementType` to return `VALUETYPE` for enums to fix the issue. The original issue would also provoke Enum parsing to trigger an assert in a debug runtime and go through a slower, rare path for parsing as well.

Fixes https://github.com/dotnet/runtime/issues/72543
src/libraries/System.Runtime/tests/System/Type/TypeTests.cs
src/mono/mono/metadata/icall.c