diff --git a/src/Compilers/Core/Portable/InternalUtilities/EnumUtilties.cs b/src/Compilers/Core/Portable/InternalUtilities/EnumUtilties.cs index 19ec5006b946988fe46dd686c3309bb3b0fc532c..9e10478fb923c931a0483ee7ae324203218f28b1 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/EnumUtilties.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/EnumUtilties.cs @@ -25,20 +25,30 @@ internal static ulong ConvertEnumUnderlyingTypeToUInt64(object value, SpecialTyp unchecked { - return specialType switch + switch (specialType) { - SpecialType.System_SByte => (ulong)(sbyte)value, - SpecialType.System_Int16 => (ulong)(short)value, - SpecialType.System_Int32 => (ulong)(int)value, - SpecialType.System_Int64 => (ulong)(long)value, - SpecialType.System_Byte => (byte)value, - SpecialType.System_UInt16 => (ushort)value, - SpecialType.System_UInt32 => (uint)value, - SpecialType.System_UInt64 => (ulong)value, - // not using ExceptionUtilities.UnexpectedValue() because this is used by the Services layer - // which doesn't have those utilities. - _ => throw new InvalidOperationException(string.Format("{0} is not a valid underlying type for an enum", specialType)), - }; + case SpecialType.System_SByte: + return (ulong)(sbyte)value; + case SpecialType.System_Int16: + return (ulong)(short)value; + case SpecialType.System_Int32: + return (ulong)(int)value; + case SpecialType.System_Int64: + return (ulong)(long)value; + case SpecialType.System_Byte: + return (byte)value; + case SpecialType.System_UInt16: + return (ushort)value; + case SpecialType.System_UInt32: + return (uint)value; + case SpecialType.System_UInt64: + return (ulong)value; + + default: + // not using ExceptionUtilities.UnexpectedValue() because this is used by the Services layer + // which doesn't have those utilities. + throw new InvalidOperationException(string.Format("{0} is not a valid underlying type for an enum", specialType)); + } } }