-Clean up

This commit is contained in:
James Newton-King
2016-10-02 20:42:42 +13:00
parent 17f87f5321
commit 7388358e0a
6 changed files with 15 additions and 9 deletions
@@ -209,7 +209,6 @@ namespace Newtonsoft.Json.Tests.Serialization
User user = JsonConvert.DeserializeObject<User>("{'company':{'company_name':'Company name!'}}", new JsonSerializerSettings User user = JsonConvert.DeserializeObject<User>("{'company':{'company_name':'Company name!'}}", new JsonSerializerSettings
{ {
ContractResolver = resolver ContractResolver = resolver
}); });
Assert.AreEqual("Company name!", user.Company.CompanyName); Assert.AreEqual("Company name!", user.Company.CompanyName);
+1 -1
View File
@@ -433,7 +433,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
if (_expression[_currentIndex] == '$') if (_expression[_currentIndex] == '$')
{ {
expressionPath.Add(new RootFilter()); expressionPath.Add(RootFilter.Instance);
} }
else if (_expression[_currentIndex] != '@') else if (_expression[_currentIndex] != '@')
{ {
@@ -4,6 +4,12 @@ namespace Newtonsoft.Json.Linq.JsonPath
{ {
internal class RootFilter : PathFilter internal class RootFilter : PathFilter
{ {
public static readonly RootFilter Instance = new RootFilter();
private RootFilter()
{
}
public override IEnumerable<JToken> ExecuteFilter(JToken root, IEnumerable<JToken> current, bool errorWhenNoMatch) public override IEnumerable<JToken> ExecuteFilter(JToken root, IEnumerable<JToken> current, bool errorWhenNoMatch)
{ {
return root; return root;
@@ -1065,7 +1065,7 @@ namespace Newtonsoft.Json.Utilities
} }
// perform scaling // perform scaling
var index = scale & 15; int index = scale & 15;
if (index != 0) if (index != 0)
{ {
exp -= MultExp64Power10[index - 1] - 1; exp -= MultExp64Power10[index - 1] - 1;
@@ -1089,7 +1089,7 @@ namespace Newtonsoft.Json.Utilities
} }
// perform scaling // perform scaling
var index = scale & 15; int index = scale & 15;
if (index != 0) if (index != 0)
{ {
exp += MultExp64Power10[index - 1]; exp += MultExp64Power10[index - 1];
@@ -1171,7 +1171,7 @@ namespace Newtonsoft.Json.Utilities
ulong b_hi = (b >> 32); ulong b_hi = (b >> 32);
uint b_lo = (uint)b; uint b_lo = (uint)b;
var result = a_hi * b_hi; ulong result = a_hi * b_hi;
// save some multiplications if lo-parts aren't big enough to produce carry // save some multiplications if lo-parts aren't big enough to produce carry
// (hi-parts will be always big enough, since a and b are normalized) // (hi-parts will be always big enough, since a and b are normalized)
@@ -1294,7 +1294,7 @@ namespace Newtonsoft.Json.Utilities
return ParseResult.Invalid; return ParseResult.Invalid;
} }
var newExponent = (10 * exponent) + (c - '0'); int newExponent = (10 * exponent) + (c - '0');
// stops updating exponent when overflowing // stops updating exponent when overflowing
if (exponent < newExponent) if (exponent < newExponent)
{ {
@@ -70,7 +70,7 @@ namespace Newtonsoft.Json.Utilities
case DateTimeKind.Utc: case DateTimeKind.Utc:
return XmlDateTimeSerializationMode.Utc; return XmlDateTimeSerializationMode.Utc;
default: default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("kind", kind, "Unexpected DateTimeKind value."); throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(kind), kind, "Unexpected DateTimeKind value.");
} }
} }
#else #else
@@ -85,7 +85,7 @@ namespace Newtonsoft.Json.Utilities
case DateTimeKind.Utc: case DateTimeKind.Utc:
return "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ"; return "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ";
default: default:
throw new Exception("Unexpected DateTimeKind value."); throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(kind), kind, "Unexpected DateTimeKind value.");
} }
} }
#endif #endif
@@ -170,7 +170,8 @@ namespace Newtonsoft.Json.Utilities
{ {
if (binder != null) if (binder != null)
{ {
string assemblyName, typeName; string assemblyName;
string typeName;
binder.BindToName(t, out assemblyName, out typeName); binder.BindToName(t, out assemblyName, out typeName);
#if (NET20 || NET35) #if (NET20 || NET35)
// for older SerializationBinder implementations that didn't have BindToName // for older SerializationBinder implementations that didn't have BindToName