Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new API GetEnumValuesAsUnderlyingType #73057

Merged
merged 18 commits into from
Aug 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove ifdefd
  • Loading branch information
LakshanF committed Aug 2, 2022
commit bb27de59b09834130964cece3a8f43daa935ef0a
36 changes: 0 additions & 36 deletions src/libraries/System.Private.CoreLib/src/System/RuntimeType.cs
Original file line number Diff line number Diff line change
@@ -158,18 +158,10 @@ public override Array GetEnumValuesAsUnderlyingType()
// Get all of the values
ulong[] values = Enum.InternalGetValues(this);

#if MONO
switch (RuntimeTypeHandle.GetCorElementType(Enum.InternalGetUnderlyingType(this)))
LakshanF marked this conversation as resolved.
Show resolved Hide resolved
#else
switch (RuntimeTypeHandle.GetCorElementType(this))
#endif
{

#if MONO
case TypeCode.Byte:
#else
case CorElementType.ELEMENT_TYPE_U1:
#endif
{
var ret = new byte[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -179,11 +171,7 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.UInt16:
#else
case CorElementType.ELEMENT_TYPE_U2:
#endif
{
var ret = new ushort[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -193,11 +181,7 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.UInt32:
#else
case CorElementType.ELEMENT_TYPE_U4:
#endif
{
var ret = new uint[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -207,20 +191,12 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.UInt64:
#else
case CorElementType.ELEMENT_TYPE_U8:
#endif
{
return (Array)values.Clone();
}

#if MONO
case TypeCode.SByte:
#else
case CorElementType.ELEMENT_TYPE_I1:
#endif
{
var ret = new sbyte[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -230,11 +206,7 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.Int16:
#else
case CorElementType.ELEMENT_TYPE_I2:
#endif
{
var ret = new short[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -244,11 +216,7 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.Int32:
#else
case CorElementType.ELEMENT_TYPE_I4:
#endif
{
var ret = new int[values.Length];
for (int i = 0; i < values.Length; i++)
@@ -258,11 +226,7 @@ public override Array GetEnumValuesAsUnderlyingType()
return ret;
}

#if MONO
case TypeCode.Int64:
#else
case CorElementType.ELEMENT_TYPE_I8:
#endif
{
var ret = new long[values.Length];
for (int i = 0; i < values.Length; i++)