-Changed ISerializable serialization to require SerializableAttribute
This commit is contained in:
@@ -125,6 +125,15 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(JsonContractType.Serializable, contract.ContractType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResolveSerializableWithoutAttributeContract()
|
||||
{
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver();
|
||||
JsonContract contract = contractResolver.ResolveContract(typeof(ISerializableWithoutAttributeTestObject));
|
||||
|
||||
Assert.AreEqual(JsonContractType.Object, contract.ContractType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResolveObjectContractWithFieldsSerialization()
|
||||
{
|
||||
|
||||
@@ -152,6 +152,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40) || NETSTANDARD1_3 || NETSTANDARD2_0
|
||||
[Serializable]
|
||||
public class MainClass : ISerializable
|
||||
{
|
||||
public ChildClass Child { get; set; }
|
||||
@@ -162,6 +163,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ChildClass : ISerializable
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -29,6 +29,7 @@ using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class ISerializableTestObject : ISerializable
|
||||
{
|
||||
internal string _stringValue;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class ISerializableWithoutAttributeTestObject : ISerializable
|
||||
{
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,13 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(PORTABLE || PORTABLE40 || DNXCORE50) || NETSTANDARD1_3 || NETSTANDARD2_0
|
||||
[Serializable]
|
||||
public class PreserveReferencesCallbackTestObject : ISerializable
|
||||
{
|
||||
internal string _stringValue;
|
||||
|
||||
@@ -30,6 +30,7 @@ using System.Runtime.Serialization;
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(DNXCORE50) || NETSTANDARD1_3 || NETSTANDARD2_0
|
||||
[Serializable]
|
||||
public struct Ratio : IConvertible, IFormattable, ISerializable
|
||||
{
|
||||
private readonly int _numerator;
|
||||
|
||||
Reference in New Issue
Block a user