public sealed override Array GetEnumValues()
{
if (!IsEnum)
{
throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
}
Array values = Enum.GetEnumInfo(this).ValuesAsUnderlyingType;
int count = values.Length;
// Without universal shared generics, chances are slim that we'll have the appropriate
// array type available. Offer an escape hatch that avoids a MissingMetadataException
// at the cost of a small appcompat risk.
Array result;
if (AppContext.TryGetSwitch("Switch.System.Enum.RelaxedGetValues", out bool isRelaxed) && isRelaxed)
{
result = Array.CreateInstance(Enum.InternalGetUnderlyingType(this), count);
}
else
{
result = Array.CreateInstance(this, count);
}
Array.Copy(values, result, values.Length);
return(result);
}