Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Kanamori <AtsushiKan@users.noreply.github.com>2017-05-09 20:57:10 +0300
committerGitHub <noreply@github.com>2017-05-09 20:57:10 +0300
commit767741623bf4613cb7b1d25ce0fa097aa2742bae (patch)
tree22006a9a8a9917b4f4fcbda43a47956f7501b0ae /src/System.Private.CoreLib
parenta951141e08c7a1a9bcde21dc6583bb74f1909286 (diff)
Fix more CoreFx on ILC tests (#3559)
- Make Enum.Parse() throw OverflowException when it's supposed to. - Now that we support all the multidim array ranks that the full framework did, throw the same exception it does when you go outside that allowance.
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/src/System/Enum.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/src/System/Enum.cs b/src/System.Private.CoreLib/src/System/Enum.cs
index d25cca112..5e4adf1b5 100644
--- a/src/System.Private.CoreLib/src/System/Enum.cs
+++ b/src/System.Private.CoreLib/src/System/Enum.cs
@@ -1003,6 +1003,12 @@ namespace System
if (TryParseAsInteger(enumEEType, value, firstNonWhitespaceIndex, out result))
return true;
+ if (StillLooksLikeInteger(value, firstNonWhitespaceIndex))
+ {
+ exception = new OverflowException();
+ return false;
+ }
+
// Parse as string. Now (and only now) do we look for metadata information.
EnumInfo enumInfo = RuntimeAugments.Callbacks.GetEnumInfoIfAvailable(enumType);
if (enumInfo == null)
@@ -1175,6 +1181,31 @@ namespace System
}
}
+ private static bool StillLooksLikeInteger(String value, int index)
+ {
+ if (index != value.Length && (value[index] == '-' || value[index] == '+'))
+ {
+ index++;
+ }
+
+ if (index == value.Length || !char.IsDigit(value[index]))
+ return false;
+
+ index++;
+
+ while (index != value.Length && char.IsDigit(value[index]))
+ {
+ index++;
+ }
+
+ while (index != value.Length && char.IsWhiteSpace(value[index]))
+ {
+ index++;
+ }
+
+ return index == value.Length;
+ }
+
[Conditional("BIGENDIAN")]
private static unsafe void AdjustForEndianness(ref byte* pValue, EETypePtr enumEEType)
{