Skip to content

Commit

Permalink
AOT: fix enum usage (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
scgm0 authored Jan 25, 2024
1 parent 60cbc25 commit da39b1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Jint/Native/JsNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal override bool ToBoolean()

internal static JsNumber Create(object value)
{
var underlyingType = System.Type.GetTypeCode(Enum.GetUnderlyingType(value.GetType()));
var underlyingType = System.Type.GetTypeCode(value.GetType());
return underlyingType switch
{
TypeCode.Int64 => Create(Convert.ToInt64(value, CultureInfo.InvariantCulture)),
Expand Down
5 changes: 4 additions & 1 deletion Jint/Runtime/Interop/TypeReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ private static ReflectionAccessor ResolveMemberAccessor(Engine engine, Type type
{
var memberNameComparer = typeResolver.MemberNameComparer;
var typeResolverMemberNameCreator = typeResolver.MemberNameCreator;

#if NET7_0_OR_GREATER
var enumValues = type.GetEnumValuesAsUnderlyingType();
#else
var enumValues = Enum.GetValues(type);
#endif
var enumNames = Enum.GetNames(type);

for (var i = 0; i < enumValues.Length; i++)
Expand Down

0 comments on commit da39b1d

Please sign in to comment.