-Obsolete DefaultContractResolver(bool)

This commit is contained in:
James Newton-King
2015-03-04 20:34:21 +13:00
parent 376ab4dbb5
commit b1184ef6b5
8 changed files with 28 additions and 20 deletions
@@ -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")]
@@ -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")]
@@ -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
{
}
@@ -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;
}
@@ -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<ISerializableTestObject>("{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<T>(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
};
@@ -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)]
@@ -37,7 +37,9 @@ namespace Newtonsoft.Json.Serialization
/// Initializes a new instance of the <see cref="CamelCasePropertyNamesContractResolver"/> class.
/// </summary>
public CamelCasePropertyNamesContractResolver()
#pragma warning disable 612
: base(true)
#pragma warning restore 612
{
}
@@ -94,7 +94,9 @@ namespace Newtonsoft.Json.Serialization
/// </summary>
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 <see cref="DefaultContractResolver"/> class.
/// </summary>
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
}
/// <summary>
@@ -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 <see cref="DefaultContractResolver"/> instances with the <see cref="JsonSerializer"/>.
/// </param>
[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;
}