private static bool TryParseByName(RuntimeType enumType, ReadOnlySpan<char> value, bool ignoreCase, bool throwOnFailure, out ulong result)
{
+ ReadOnlySpan<char> originalValue = value;
+
// Find the field. Let's assume that these are always static classes because the class is an enum.
EnumInfo enumInfo = GetEnumInfo(enumType);
string[] enumNames = enumInfo.Names;
if (throwOnFailure)
{
- throw new ArgumentException(SR.Format(SR.Arg_EnumValueNotFound, value.ToString()));
+ throw new ArgumentException(SR.Format(SR.Arg_EnumValueNotFound, originalValue.ToString()));
}
result = 0;
}
[Theory]
+ [InlineData("Yellow")]
+ [InlineData("Yellow,Orange")]
+ public static void Parse_NonExistentValue_IncludedInErrorMessage(string value)
+ {
+ ArgumentException e = Assert.Throws<ArgumentException>(() => Enum.Parse(typeof(SimpleEnum), value));
+ Assert.Contains(value, e.Message);
+ }
+
+ [Theory]
[InlineData(SByteEnum.Min, "Min")]
[InlineData(SByteEnum.One, "One")]
[InlineData(SByteEnum.Two, "Two")]