diff --git a/Src/Newtonsoft.Json.TestConsole/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.TestConsole/Properties/AssemblyInfo.cs index b63ecd14..0c50d011 100644 --- a/Src/Newtonsoft.Json.TestConsole/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.TestConsole/Properties/AssemblyInfo.cs @@ -57,4 +57,4 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("7.0.0.0")] -[assembly: AssemblyFileVersion("7.0.1.18216")] +[assembly: AssemblyFileVersion("7.0.1.18304")] diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index 4fd54f38..4cdfcbb0 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -76,4 +76,4 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("7.0.0.0")] -[assembly: AssemblyFileVersion("7.0.1.18216")] +[assembly: AssemblyFileVersion("7.0.1.18304")] diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs index ee6a4db1..e28b54e5 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs @@ -344,7 +344,9 @@ namespace Newtonsoft.Json.Tests.Schema public class CustomDirectoryInfoMapper : DefaultContractResolver { public CustomDirectoryInfoMapper() +#pragma warning disable 612 : base(true) +#pragma warning restore 612 { } diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs index c0308997..feb0550d 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs @@ -57,7 +57,9 @@ namespace Newtonsoft.Json.Tests.Serialization private readonly char _startingWithChar; public DynamicContractResolver(char startingWithChar) +#pragma warning disable 612 : base(false) +#pragma warning restore 612 { _startingWithChar = startingWithChar; } diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index c3ec43e9..960447c3 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -4167,7 +4167,7 @@ Path '', line 1, position 1."); string json = JsonConvert.SerializeObject(value, new JsonSerializerSettings { - ContractResolver = new DefaultContractResolver(false) + ContractResolver = new DefaultContractResolver { IgnoreSerializableInterface = true } @@ -4177,7 +4177,7 @@ Path '', line 1, position 1."); value = JsonConvert.DeserializeObject("{booleanValue:true}", new JsonSerializerSettings { - ContractResolver = new DefaultContractResolver(false) + ContractResolver = new DefaultContractResolver { IgnoreSerializableInterface = true } @@ -7060,8 +7060,8 @@ Path '', line 1, position 1."); where T : class { var stringWriter = new StringWriter(); - var serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.ContractResolver = new DefaultContractResolver(false) + var serializer = new JsonSerializer(); + serializer.ContractResolver = new DefaultContractResolver { IgnoreSerializableAttribute = false }; @@ -7073,9 +7073,9 @@ Path '', line 1, position 1."); private T Deserialize(string json) where T : class { - var jsonReader = new Newtonsoft.Json.JsonTextReader(new StringReader(json)); - var serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.ContractResolver = new DefaultContractResolver(false) + var jsonReader = new JsonTextReader(new StringReader(json)); + var serializer = new JsonSerializer(); + serializer.ContractResolver = new DefaultContractResolver { IgnoreSerializableAttribute = false }; diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index 665d9ff3..3626d992 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -92,5 +92,5 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("7.0.0.0")] -[assembly: AssemblyFileVersion("7.0.1.18216")] +[assembly: AssemblyFileVersion("7.0.1.18304")] [assembly: CLSCompliant(true)] diff --git a/Src/Newtonsoft.Json/Serialization/CamelCasePropertyNamesContractResolver.cs b/Src/Newtonsoft.Json/Serialization/CamelCasePropertyNamesContractResolver.cs index bbeb23de..2658c0aa 100644 --- a/Src/Newtonsoft.Json/Serialization/CamelCasePropertyNamesContractResolver.cs +++ b/Src/Newtonsoft.Json/Serialization/CamelCasePropertyNamesContractResolver.cs @@ -37,7 +37,9 @@ namespace Newtonsoft.Json.Serialization /// Initializes a new instance of the class. /// public CamelCasePropertyNamesContractResolver() +#pragma warning disable 612 : base(true) +#pragma warning restore 612 { } diff --git a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs index 36aadf43..797bfa52 100644 --- a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs +++ b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs @@ -94,7 +94,9 @@ namespace Newtonsoft.Json.Serialization /// public class DefaultContractResolver : IContractResolver { +#pragma warning disable 612 private static readonly IContractResolver _instance = new DefaultContractResolver(true); +#pragma warning restore 612 internal static IContractResolver Instance { @@ -187,8 +189,15 @@ namespace Newtonsoft.Json.Serialization /// Initializes a new instance of the class. /// public DefaultContractResolver() - : this(false) { +#if !NETFX_CORE +#pragma warning disable 618 + DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance; +#pragma warning restore 618 +#endif +#if !(NETFX_CORE || PORTABLE || PORTABLE40) + IgnoreSerializableAttribute = true; +#endif } /// @@ -200,17 +209,10 @@ namespace Newtonsoft.Json.Serialization /// happen once. This setting can cause unexpected behavior if different instances of the resolver are suppose to produce different /// results. When set to false it is highly recommended to reuse instances with the . /// + [ObsoleteAttribute("DefaultContractResolver(bool) is obsolete. Use the parameterless constructor and cache instances of the contract resolver within your application for optimal performance.")] public DefaultContractResolver(bool shareCache) + : this() { -#if !NETFX_CORE -#pragma warning disable 618 - DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance; -#pragma warning restore 618 -#endif -#if !(NETFX_CORE || PORTABLE || PORTABLE40) - IgnoreSerializableAttribute = true; -#endif - _sharedCache = shareCache; }