Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -598,17 +598,7 @@ namespace System.Json
private static bool TryGuidParse (string value, out Guid guid)
{
#if NET_4_0
return Guid.TryParse (value, out guid);
#else
try {
guid = new Guid (value);
return true;
} catch (Exception) {
guid = Guid.Empty;
return false;
}
#endif
}
private static ConvertResult StringToGuid(string valueString)
@@ -940,9 +930,7 @@ namespace System.Json
}
sb.Append(val, startIndex, count);
#if NET_4_0
Contract.Assert(i < val.Length, "Found that a '\' was the last character in a string, which is invalid JSON. Verify the calling method uses a valid JSON string as the input parameter of this method.");
#endif
switch (val[i])
{
case '"':
@@ -967,9 +955,7 @@ namespace System.Json
sb.Append('\t');
break;
case 'u':
#if NET_4_0
Contract.Assert((i + 3) < val.Length, String.Format(CultureInfo.CurrentCulture, "Unexpected char {0} at position {1}. The unicode escape sequence should be followed by 4 digits.", val[i], i));
#endif
sb.Append(ParseChar(val.Substring(i + 1, 4), NumberStyles.HexNumber));
i += 4;
break;
@@ -1067,9 +1053,7 @@ namespace System.Json
if (jsonType == JsonType.String)
{
string str = UnescapeJsonString(ToString());
#if NET_4_0
Contract.Assert(str.Length >= 2 && str.StartsWith("\"", StringComparison.Ordinal) && str.EndsWith("\"", StringComparison.Ordinal), "The unescaped string must begin and end with quotes.");
#endif
str = str.Substring(1, str.Length - 2);
if (stringConverters.ContainsKey(type))