diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs index 1888f9a3..3fb8f06c 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs @@ -209,7 +209,6 @@ namespace Newtonsoft.Json.Tests.Serialization User user = JsonConvert.DeserializeObject("{'company':{'company_name':'Company name!'}}", new JsonSerializerSettings { ContractResolver = resolver - }); Assert.AreEqual("Company name!", user.Company.CompanyName); diff --git a/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs b/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs index edf582ae..88d86912 100644 --- a/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs +++ b/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs @@ -433,7 +433,7 @@ namespace Newtonsoft.Json.Linq.JsonPath if (_expression[_currentIndex] == '$') { - expressionPath.Add(new RootFilter()); + expressionPath.Add(RootFilter.Instance); } else if (_expression[_currentIndex] != '@') { diff --git a/Src/Newtonsoft.Json/Linq/JsonPath/RootFilter.cs b/Src/Newtonsoft.Json/Linq/JsonPath/RootFilter.cs index a91c2aa5..6ad3fb14 100644 --- a/Src/Newtonsoft.Json/Linq/JsonPath/RootFilter.cs +++ b/Src/Newtonsoft.Json/Linq/JsonPath/RootFilter.cs @@ -4,6 +4,12 @@ namespace Newtonsoft.Json.Linq.JsonPath { internal class RootFilter : PathFilter { + public static readonly RootFilter Instance = new RootFilter(); + + private RootFilter() + { + } + public override IEnumerable ExecuteFilter(JToken root, IEnumerable current, bool errorWhenNoMatch) { return root; diff --git a/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs b/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs index 5cd37c8e..93e926f4 100644 --- a/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs @@ -1065,7 +1065,7 @@ namespace Newtonsoft.Json.Utilities } // perform scaling - var index = scale & 15; + int index = scale & 15; if (index != 0) { exp -= MultExp64Power10[index - 1] - 1; @@ -1089,7 +1089,7 @@ namespace Newtonsoft.Json.Utilities } // perform scaling - var index = scale & 15; + int index = scale & 15; if (index != 0) { exp += MultExp64Power10[index - 1]; @@ -1171,7 +1171,7 @@ namespace Newtonsoft.Json.Utilities ulong b_hi = (b >> 32); 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 // (hi-parts will be always big enough, since a and b are normalized) @@ -1294,7 +1294,7 @@ namespace Newtonsoft.Json.Utilities return ParseResult.Invalid; } - var newExponent = (10 * exponent) + (c - '0'); + int newExponent = (10 * exponent) + (c - '0'); // stops updating exponent when overflowing if (exponent < newExponent) { diff --git a/Src/Newtonsoft.Json/Utilities/DateTimeUtils.cs b/Src/Newtonsoft.Json/Utilities/DateTimeUtils.cs index 29591731..693013b4 100644 --- a/Src/Newtonsoft.Json/Utilities/DateTimeUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/DateTimeUtils.cs @@ -70,7 +70,7 @@ namespace Newtonsoft.Json.Utilities case DateTimeKind.Utc: return XmlDateTimeSerializationMode.Utc; default: - throw MiscellaneousUtils.CreateArgumentOutOfRangeException("kind", kind, "Unexpected DateTimeKind value."); + throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(kind), kind, "Unexpected DateTimeKind value."); } } #else @@ -85,7 +85,7 @@ namespace Newtonsoft.Json.Utilities case DateTimeKind.Utc: return "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ"; default: - throw new Exception("Unexpected DateTimeKind value."); + throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(kind), kind, "Unexpected DateTimeKind value."); } } #endif diff --git a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index 20133f08..865f3990 100644 --- a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -170,7 +170,8 @@ namespace Newtonsoft.Json.Utilities { if (binder != null) { - string assemblyName, typeName; + string assemblyName; + string typeName; binder.BindToName(t, out assemblyName, out typeName); #if (NET20 || NET35) // for older SerializationBinder implementations that didn't have BindToName