-Minor code cleanup

-Fixed CA warning
This commit is contained in:
James Newton-King
2017-01-09 16:46:11 +13:00
parent 6c7e41537b
commit de82488549
4 changed files with 37 additions and 40 deletions
@@ -70,8 +70,8 @@ namespace Newtonsoft.Json.Tests
#if DEBUG
public int Iterations = 1;
#else
//public int Iterations = 100;
public int Iterations = 10000;
public int Iterations = 100;
//public int Iterations = 10000;
#endif
#region Data
+2 -2
View File
@@ -140,7 +140,7 @@ namespace Newtonsoft.Json.Linq
case JTokenType.Property:
return null;
default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", c.Type, "Unexpected JContainer type.");
throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(c.Type), c.Type, "Unexpected JContainer type.");
}
}
@@ -234,7 +234,7 @@ namespace Newtonsoft.Json.Linq
SetToken(JsonToken.String, SafeToString(((JValue)token).Value));
break;
default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", token.Type, "Unexpected JTokenType.");
throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(token.Type), token.Type, "Unexpected JTokenType.");
}
}
+2 -2
View File
@@ -392,7 +392,7 @@ namespace Newtonsoft.Json.Linq
return ts1.CompareTo(ts2);
default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("valueType", valueType, "Unexpected value type: {0}".FormatWith(CultureInfo.InvariantCulture, valueType));
throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(valueType), valueType, "Unexpected value type: {0}".FormatWith(CultureInfo.InvariantCulture, valueType));
}
}
@@ -823,7 +823,7 @@ namespace Newtonsoft.Json.Linq
return;
}
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("TokenType", _valueType, "Unexpected token type.");
throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(Type), _valueType, "Unexpected token type.");
}
internal override int GetDeepHashCode()
@@ -140,38 +140,6 @@ namespace Newtonsoft.Json.Utilities
return false;
}
private static int FirstCharToEscape(string s, bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling)
{
for (int i = 0; i != s.Length; i++)
{
char c = s[i];
if (c < charEscapeFlags.Length)
{
if (charEscapeFlags[c])
{
return i;
}
}
else if (stringEscapeHandling == StringEscapeHandling.EscapeNonAscii)
{
return i;
}
else
{
switch (c)
{
case '\u0085':
case '\u2028':
case '\u2029':
return i;
}
}
}
return -1;
}
public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters,
bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, IArrayPool<char> bufferPool, ref char[] writeBuffer)
{
@@ -349,6 +317,37 @@ namespace Newtonsoft.Json.Utilities
}
#if !(NET20 || NET35 || NET40 || PORTABLE40)
private static int FirstCharToEscape(string s, bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling)
{
for (int i = 0; i != s.Length; i++)
{
char c = s[i];
if (c < charEscapeFlags.Length)
{
if (charEscapeFlags[c])
{
return i;
}
}
else if (stringEscapeHandling == StringEscapeHandling.EscapeNonAscii)
{
return i;
}
else
{
switch (c)
{
case '\u0085':
case '\u2028':
case '\u2029':
return i;
}
}
}
return -1;
}
public static Task WriteEscapedJavaScriptStringAsync(TextWriter writer, string s, char delimiter, bool appendDelimiters, bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, JsonTextWriter client, char[] writeBuffer, CancellationToken cancellationToken = default(CancellationToken))
{
@@ -521,8 +520,6 @@ namespace Newtonsoft.Json.Utilities
await writer.WriteAsync(writeBuffer, 0, length, cancellationToken).ConfigureAwait(false);
}
}
#endif
}
}