Merged conflict

This commit is contained in:
James Newton-King
2013-04-12 12:23:13 +12:00
127 changed files with 2054 additions and 1175 deletions
@@ -102,7 +102,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = o.ToString();
}
#if !(NETFX_CORE || PORTABLE)
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void MemberSearchFlags()
{
@@ -177,7 +177,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}", json);
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
[Test]
public void DynamicCamelCasePropertyNames()
{
@@ -25,6 +25,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
#if !NETFX_CORE
using NUnit.Framework;
@@ -67,6 +68,14 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
public class EscapedPropertiesContractResolver : DefaultContractResolver
{
protected internal override string ResolvePropertyName(string propertyName)
{
return base.ResolvePropertyName(propertyName + @"-'-""-");
}
}
public class Book
{
public string BookName { get; set; }
@@ -87,18 +96,39 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
#if !NET20
public class AddressWithDataMember
{
#if !NET20
[DataMember(Name = "CustomerAddress1")]
public string AddressLine1 { get; set; }
}
#endif
public string AddressLine1 { get; set; }
}
[TestFixture]
public class ContractResolverTests : TestFixtureBase
{
[Test]
public void SerializeWithEscapedPropertyName()
{
string json = JsonConvert.SerializeObject(
new AddressWithDataMember
{
AddressLine1 = "value!"
},
new JsonSerializerSettings
{
ContractResolver = new EscapedPropertiesContractResolver()
});
Assert.AreEqual(@"{""AddressLine1-'-\""-"":""value!""}", json);
JsonTextReader reader = new JsonTextReader(new StringReader(json));
reader.Read();
reader.Read();
Assert.AreEqual(@"AddressLine1-'-""-", reader.Value);
}
#if !NET20
[Test]
public void DeserializeDataMemberClassWithNoDataContract()
@@ -182,7 +212,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}", startingWithB);
}
#if !(NETFX_CORE || PORTABLE)
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void SerializeCompilerGeneratedMembers()
{
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
using System;
using System.Collections;
using System.Collections.Generic;
@@ -100,7 +100,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(dynamicObject.ChildObject.Text, d.ChildObject.Text);
}
#if !PORTABLE
#if !(PORTABLE || PORTABLE40)
[Test]
public void SerializeDynamicObjectWithObjectTracking()
{
@@ -121,8 +121,8 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json);
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full);
string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full);
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full, null);
string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full, null);
Assert.AreEqual(@"{
""$type"": """ + expandoObjectTypeName + @""",
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(NET35 || NET20 || SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(NET35 || NET20 || SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
using System;
using System.Collections.Generic;
using System.Data;
@@ -158,6 +158,249 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(@"{""selectList"":[{""Value"":""Hello""}]}", json);
}
#if !NET20
[DataContract]
public class BaseDataContractWithHidden
{
[DataMember(Name = "virtualMember")]
public virtual string VirtualMember { get; set; }
[DataMember(Name = "nonVirtualMember")]
public string NonVirtualMember { get; set; }
public virtual object NewMember { get; set; }
}
public class ChildDataContractWithHidden : BaseDataContractWithHidden
{
[DataMember(Name = "NewMember")]
public virtual new string NewMember { get; set; }
public override string VirtualMember { get; set; }
public string AddedMember { get; set; }
}
[Test]
public void ChildDataContractTestWithHidden()
{
var cc = new ChildDataContractWithHidden
{
VirtualMember = "VirtualMember!",
NonVirtualMember = "NonVirtualMember!",
NewMember = "NewMember!"
};
string result = JsonConvert.SerializeObject(cc);
Assert.AreEqual(@"{""NewMember"":""NewMember!"",""virtualMember"":""VirtualMember!"",""nonVirtualMember"":""NonVirtualMember!""}", result);
}
// ignore hiding members compiler warning
#pragma warning disable 108,114
[DataContract]
public class BaseWithContract
{
[DataMember(Name = "VirtualWithDataMemberBase")]
public virtual string VirtualWithDataMember { get; set; }
[DataMember]
public virtual string Virtual { get; set; }
[DataMember(Name = "WithDataMemberBase")]
public string WithDataMember { get; set; }
[DataMember]
public string JustAProperty { get; set; }
}
[DataContract]
public class BaseWithoutContract
{
[DataMember(Name = "VirtualWithDataMemberBase")]
public virtual string VirtualWithDataMember { get; set; }
[DataMember]
public virtual string Virtual { get; set; }
[DataMember(Name = "WithDataMemberBase")]
public string WithDataMember { get; set; }
[DataMember]
public string JustAProperty { get; set; }
}
[DataContract]
public class SubWithoutContractNewProperties : BaseWithContract
{
[DataMember(Name = "VirtualWithDataMemberSub")]
public string VirtualWithDataMember { get; set; }
public string Virtual { get; set; }
[DataMember(Name = "WithDataMemberSub")]
public string WithDataMember { get; set; }
public string JustAProperty { get; set; }
}
[DataContract]
public class SubWithoutContractVirtualProperties : BaseWithContract
{
public override string VirtualWithDataMember { get; set; }
[DataMember(Name = "VirtualSub")]
public override string Virtual { get; set; }
}
[DataContract]
public class SubWithContractNewProperties : BaseWithContract
{
[DataMember(Name = "VirtualWithDataMemberSub")]
public string VirtualWithDataMember { get; set; }
[DataMember(Name = "Virtual2")]
public string Virtual { get; set; }
[DataMember(Name = "WithDataMemberSub")]
public string WithDataMember { get; set; }
[DataMember(Name = "JustAProperty2")]
public string JustAProperty { get; set; }
}
[DataContract]
public class SubWithContractVirtualProperties : BaseWithContract
{
[DataMember(Name = "VirtualWithDataMemberSub")]
public virtual string VirtualWithDataMember { get; set; }
}
#pragma warning restore 108,114
[Test]
public void SubWithoutContractNewPropertiesTest()
{
BaseWithContract baseWith = new SubWithoutContractNewProperties
{
JustAProperty = "JustAProperty!",
Virtual = "Virtual!",
VirtualWithDataMember = "VirtualWithDataMember!",
WithDataMember = "WithDataMember!"
};
baseWith.JustAProperty = "JustAProperty2!";
baseWith.Virtual = "Virtual2!";
baseWith.VirtualWithDataMember = "VirtualWithDataMember2!";
baseWith.WithDataMember = "WithDataMember2!";
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualWithDataMemberSub"": ""VirtualWithDataMember!"",
""WithDataMemberBase"": ""WithDataMember2!"",
""WithDataMemberSub"": ""WithDataMember!""
}", json);
}
[Test]
public void SubWithoutContractVirtualPropertiesTest()
{
BaseWithContract baseWith = new SubWithoutContractVirtualProperties
{
JustAProperty = "JustAProperty!",
Virtual = "Virtual!",
VirtualWithDataMember = "VirtualWithDataMember!",
WithDataMember = "WithDataMember!"
};
baseWith.JustAProperty = "JustAProperty2!";
baseWith.Virtual = "Virtual2!";
baseWith.VirtualWithDataMember = "VirtualWithDataMember2!";
baseWith.WithDataMember = "WithDataMember2!";
string json = JsonConvert.SerializeObject(baseWith, Formatting.Indented);
Console.WriteLine(json);
Assert.AreEqual(@"{
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualSub"": ""Virtual2!"",
""WithDataMemberBase"": ""WithDataMember2!"",
""JustAProperty"": ""JustAProperty2!""
}", json);
}
[Test]
public void SubWithContractNewPropertiesTest()
{
BaseWithContract baseWith = new SubWithContractNewProperties
{
JustAProperty = "JustAProperty!",
Virtual = "Virtual!",
VirtualWithDataMember = "VirtualWithDataMember!",
WithDataMember = "WithDataMember!"
};
baseWith.JustAProperty = "JustAProperty2!";
baseWith.Virtual = "Virtual2!";
baseWith.VirtualWithDataMember = "VirtualWithDataMember2!";
baseWith.WithDataMember = "WithDataMember2!";
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""JustAProperty2"": ""JustAProperty!"",
""Virtual"": ""Virtual2!"",
""Virtual2"": ""Virtual!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualWithDataMemberSub"": ""VirtualWithDataMember!"",
""WithDataMemberBase"": ""WithDataMember2!"",
""WithDataMemberSub"": ""WithDataMember!""
}", json);
}
[Test]
public void SubWithContractVirtualPropertiesTest()
{
BaseWithContract baseWith = new SubWithContractVirtualProperties
{
JustAProperty = "JustAProperty!",
Virtual = "Virtual!",
VirtualWithDataMember = "VirtualWithDataMember!",
WithDataMember = "WithDataMember!"
};
baseWith.JustAProperty = "JustAProperty2!";
baseWith.Virtual = "Virtual2!";
baseWith.VirtualWithDataMember = "VirtualWithDataMember2!";
baseWith.WithDataMember = "WithDataMember2!";
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualWithDataMemberSub"": ""VirtualWithDataMember!"",
""WithDataMemberBase"": ""WithDataMember2!""
}", json);
}
private string AssertSerializeDeserializeEqual(object o)
{
MemoryStream ms = new MemoryStream();
DataContractJsonSerializer s = new DataContractJsonSerializer(o.GetType());
s.WriteObject(ms, o);
var data = ms.ToArray();
JObject dataContractJson = JObject.Parse(Encoding.UTF8.GetString(data, 0, data.Length));
dataContractJson = new JObject(dataContractJson.Properties().OrderBy(p => p.Name));
JObject jsonNetJson = JObject.Parse(JsonConvert.SerializeObject(o));
jsonNetJson = new JObject(jsonNetJson.Properties().OrderBy(p => p.Name));
Console.WriteLine("Results for " + o.GetType().Name);
Console.WriteLine("DataContractJsonSerializer: " + dataContractJson);
Console.WriteLine("JsonDotNetSerializer : " + jsonNetJson);
Assert.AreEqual(dataContractJson.Count, jsonNetJson.Count);
foreach (KeyValuePair<string, JToken> property in dataContractJson)
{
Assert.IsTrue(JToken.DeepEquals(jsonNetJson[property.Key], property.Value), "Property not equal: " + property.Key);
}
return jsonNetJson.ToString();
}
#endif
[Test]
public void PersonTypedObjectDeserialization()
{
@@ -826,7 +1069,7 @@ keyword such as type of business.""
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
Assert.AreEqual("string", c.String);
Assert.AreEqual(double.MaxValue, c.Double);
#if !(NETFX_CORE || PORTABLE)
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
Assert.AreEqual(DBNull.Value, c.DBNull);
#endif
}
@@ -1645,7 +1888,7 @@ keyword such as type of business.""
Assert.AreEqual("titleId", n.FidOrder[n.FidOrder.Count - 1]);
}
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE || PORTABLE40)
[MetadataType(typeof(OptInClassMetadata))]
public class OptInClass
{
@@ -2196,7 +2439,7 @@ Path '', line 1, position 1.",
});
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
[Test]
public void CannotDeserializeArrayIntoDynamic()
{
@@ -2313,7 +2556,7 @@ Path '', line 1, position 2.",
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -2332,7 +2575,7 @@ Path '', line 1, position 2.",
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -2350,9 +2593,9 @@ Path '', line 1, position 2.",
JsonConvert.DeserializeObject<MemoryStream>("{ReadTimeout:''}", new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
});
@@ -2370,7 +2613,7 @@ Path '', line 1, position 2.",
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -3041,7 +3284,7 @@ Path '', line 1, position 2.",
Assert.AreEqual("value", newModelStateDictionary["key"]);
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
public class ISerializableTestObject : ISerializable
{
internal string _stringValue;
@@ -3538,7 +3781,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !(NET20 || SILVERLIGHT)
#if !(NET20 || SILVERLIGHT || PORTABLE40)
[Test]
public void SerializeDeserializeXNodeProperties()
{
@@ -3569,7 +3812,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void SerializeDeserializeXmlNodeProperties()
{
@@ -4425,7 +4668,7 @@ To fix this error either change the environment to be fully trusted, change the
}", json);
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
[Test]
public void SerializeExpandoObject()
{
@@ -5112,6 +5355,7 @@ To fix this error either change the environment to be fully trusted, change the
};
string result = JsonConvert.SerializeObject(cc);
Console.WriteLine(result);
Assert.AreEqual(@"{""differentVirtualMember"":""VirtualMember!"",""nonVirtualMember"":""NonVirtualMember!""}", result);
}
@@ -5430,7 +5674,7 @@ To fix this error either change the environment to be fully trusted, change the
}
}
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void SerializeException1()
{
@@ -5560,7 +5804,7 @@ To fix this error either change the environment to be fully trusted, change the
}
}
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE || PORTABLE40)
[Test]
public void DeserializeConcurrentDictionary()
{
@@ -6508,7 +6752,7 @@ Parameter name: value",
Assert.AreEqual("", s);
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void SerializeAndDeserializeWithAttributes()
{
@@ -6674,7 +6918,7 @@ Parameter name: value",
});
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void DeserializeException()
{
@@ -6712,7 +6956,7 @@ Parameter name: value",
}
#endif
[Test]
[Test]
public void AdditionalContentAfterFinish()
{
ExceptionAssert.Throws<JsonException>(
@@ -6930,7 +7174,7 @@ Parameter name: value",
Assert.AreEqual("[1.1,0.0,0.0]", json);
}
#if !(NET20 || NET35 || NET40 || SILVERLIGHT)
#if !(NET20 || NET35 || NET40 || SILVERLIGHT || PORTABLE40)
#if !PORTABLE
[Test]
public void DeserializeReadOnlyListWithBigInteger()
@@ -6992,7 +7236,7 @@ Parameter name: value",
obj = JsonConvert.DeserializeObject<MyTuple<int>>(json);
};
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
doStuff();
Assert.AreEqual(500, obj.Item1);
#else
@@ -7025,7 +7269,7 @@ Parameter name: value",
}
#endif
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || NET35 || NET20)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || NET35 || NET20 || PORTABLE40)
[Test]
public void SerializeTupleWithSerializableAttribute()
{
@@ -7052,6 +7296,134 @@ Parameter name: value",
}
#endif
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE40)
public class PopulateReadOnlyTestClass
{
public IList<int> NonReadOnlyList { get; set; }
public IDictionary<string, int> NonReadOnlyDictionary { get; set; }
public IList<int> Array { get; set; }
public IList<int> List { get; set; }
public IDictionary<string, int> Dictionary { get; set; }
public IReadOnlyCollection<int> IReadOnlyCollection { get; set; }
public ReadOnlyCollection<int> ReadOnlyCollection { get; set; }
public IReadOnlyList<int> IReadOnlyList { get; set; }
public IReadOnlyDictionary<string, int> IReadOnlyDictionary { get; set; }
public ReadOnlyDictionary<string, int> ReadOnlyDictionary { get; set; }
public PopulateReadOnlyTestClass()
{
NonReadOnlyList = new List<int> { 1 };
NonReadOnlyDictionary = new Dictionary<string, int> { { "first", 2 } };
Array = new[] {3};
List = new ReadOnlyCollection<int>(new[] { 4 });
Dictionary = new ReadOnlyDictionary<string, int>(new Dictionary<string, int> { { "first", 5 } });
IReadOnlyCollection = new ReadOnlyCollection<int>(new[] { 6 });
ReadOnlyCollection = new ReadOnlyCollection<int>(new[] { 7 });
IReadOnlyList = new ReadOnlyCollection<int>(new[] { 8 });
IReadOnlyDictionary = new ReadOnlyDictionary<string, int>(new Dictionary<string, int> { { "first", 9 } });
ReadOnlyDictionary = new ReadOnlyDictionary<string, int>(new Dictionary<string, int> { { "first", 10 } });
}
}
[Test]
public void SerializeReadOnlyCollections()
{
PopulateReadOnlyTestClass c1 = new PopulateReadOnlyTestClass();
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
""NonReadOnlyList"": [
1
],
""NonReadOnlyDictionary"": {
""first"": 2
},
""Array"": [
3
],
""List"": [
4
],
""Dictionary"": {
""first"": 5
},
""IReadOnlyCollection"": [
6
],
""ReadOnlyCollection"": [
7
],
""IReadOnlyList"": [
8
],
""IReadOnlyDictionary"": {
""first"": 9
},
""ReadOnlyDictionary"": {
""first"": 10
}
}", json);
}
[Test]
public void PopulateReadOnlyCollections()
{
string json = @"{
""NonReadOnlyList"": [
11
],
""NonReadOnlyDictionary"": {
""first"": 12
},
""Array"": [
13
],
""List"": [
14
],
""Dictionary"": {
""first"": 15
},
""IReadOnlyCollection"": [
16
],
""ReadOnlyCollection"": [
17
],
""IReadOnlyList"": [
18
],
""IReadOnlyDictionary"": {
""first"": 19
},
""ReadOnlyDictionary"": {
""first"": 20
}
}";
var c2 = JsonConvert.DeserializeObject<PopulateReadOnlyTestClass>(json);
Assert.AreEqual(1, c2.NonReadOnlyDictionary.Count);
Assert.AreEqual(12, c2.NonReadOnlyDictionary["first"]);
Assert.AreEqual(2, c2.NonReadOnlyList.Count);
Assert.AreEqual(1, c2.NonReadOnlyList[0]);
Assert.AreEqual(11, c2.NonReadOnlyList[1]);
Assert.AreEqual(1, c2.Array.Count);
Assert.AreEqual(13, c2.Array[0]);
}
#endif
[Test]
public void SerializeArray2D()
{
@@ -7713,7 +8085,7 @@ Parameter name: value",
}", json);
}
#if !(PORTABLE || NET35 || NET20 || SILVERLIGHT)
#if !(PORTABLE || NET35 || NET20 || SILVERLIGHT || PORTABLE40)
[Test]
public void ReadTooLargeInteger()
{
@@ -7807,7 +8179,7 @@ Parameter name: value",
}
#endif
#if !(PORTABLE || NET20 || NET35)
#if !(NET20 || NET35 || PORTABLE40)
[Test]
public void HashSetInterface()
{
@@ -7880,7 +8252,7 @@ Parameter name: value",
Assert.AreEqual(1234567890.123456m, d);
}
#if !(PORTABLE || SILVERLIGHT || NETFX_CORE || WINDOWS_PHONE)
#if !(PORTABLE || SILVERLIGHT || NETFX_CORE || WINDOWS_PHONE || PORTABLE40)
[Test]
public void DontSerializeStaticFields()
{
@@ -7914,7 +8286,7 @@ Parameter name: value",
Assert.AreEqual("string!", l[0]);
}
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE || PORTABLE40)
[Test]
public void SerializeBigInteger()
{
@@ -7928,7 +8300,7 @@ Parameter name: value",
}
#endif
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE40)
[Test]
public void DeserializeReadOnlyListInterface()
{
@@ -149,7 +149,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}", json);
}
#if !(PORTABLE || SILVERLIGHT || NETFX_CORE)
#if !(PORTABLE || SILVERLIGHT || NETFX_CORE || PORTABLE40)
public class MainClass : ISerializable
{
public ChildClass Child { get; set; }
@@ -210,7 +210,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
#endif
#if !(NET20 || NET35)
#if !(NET20 || NET35 || PORTABLE40)
public class DictionaryDynamicObject : DynamicObject
{
public IDictionary<string, object> Values { get; private set; }
@@ -612,7 +612,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(@"Unexpected end when deserializing object. Path 'events2.code', line 1, position 49.", errors[1]);
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
[Test]
public void ErrorHandlingEndOfContentDynamic()
{
@@ -34,7 +34,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[TestFixture]
public class TraceWriterTests : TestFixtureBase
{
#if !(SILVERLIGHT || PORTABLE || NETFX_CORE)
#if !(SILVERLIGHT || PORTABLE || NETFX_CORE || PORTABLE40)
[Test]
public void DiagnosticsTraceWriterTest()
{
@@ -458,7 +458,7 @@ Newtonsoft.Json Error: 0 : Error!
Assert.AreEqual("Finished deserializing System.Collections.Generic.List`1[System.Object]. Path '$values', line 17, position 4.", traceWriter.TraceRecords[9].Message);
}
#if !(NETFX_CORE || PORTABLE || SILVERLIGHT)
#if !(NETFX_CORE || PORTABLE || SILVERLIGHT || PORTABLE40)
[Test]
public void DeserializeISerializable()
{
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PORTABLE
#if !(PORTABLE || PORTABLE40)
#if !(NET35 || NET20 || PORTABLE)
using System.Dynamic;
#endif
@@ -165,7 +165,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void WriteTypeNameForObjects()
{
string employeeRef = ReflectionUtils.GetTypeName(typeof (EmployeeReference), FormatterAssemblyStyle.Simple);
string employeeRef = ReflectionUtils.GetTypeName(typeof(EmployeeReference), FormatterAssemblyStyle.Simple, null);
EmployeeReference employee = new EmployeeReference();
@@ -185,7 +185,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void DeserializeTypeName()
{
string employeeRef = ReflectionUtils.GetTypeName(typeof (EmployeeReference), FormatterAssemblyStyle.Simple);
string employeeRef = ReflectionUtils.GetTypeName(typeof(EmployeeReference), FormatterAssemblyStyle.Simple, null);
string json = @"{
""$id"": ""1"",
@@ -207,7 +207,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void DeserializeTypeNameFromGacAssembly()
{
string cookieRef = ReflectionUtils.GetTypeName(typeof (Cookie), FormatterAssemblyStyle.Simple);
string cookieRef = ReflectionUtils.GetTypeName(typeof (Cookie), FormatterAssemblyStyle.Simple, null);
string json = @"{
""$id"": ""1"",
@@ -493,7 +493,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void WriteObjectTypeNameForProperty()
{
string typeNamePropertyRef = ReflectionUtils.GetTypeName(typeof (TypeNameProperty), FormatterAssemblyStyle.Simple);
string typeNamePropertyRef = ReflectionUtils.GetTypeName(typeof (TypeNameProperty), FormatterAssemblyStyle.Simple, null);
TypeNameProperty typeNameProperty = new TypeNameProperty
{
@@ -527,7 +527,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void WriteListTypeNameForProperty()
{
string listRef = ReflectionUtils.GetTypeName(typeof (List<int>), FormatterAssemblyStyle.Simple);
string listRef = ReflectionUtils.GetTypeName(typeof (List<int>), FormatterAssemblyStyle.Simple, null);
TypeNameProperty typeNameProperty = new TypeNameProperty
{
@@ -709,9 +709,9 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = sw.ToString();
string contentSubClassRef = ReflectionUtils.GetTypeName(typeof (ContentSubClass), FormatterAssemblyStyle.Simple);
string dictionaryRef = ReflectionUtils.GetTypeName(typeof (Dictionary<int, IList<ContentBaseClass>>), FormatterAssemblyStyle.Simple);
string listRef = ReflectionUtils.GetTypeName(typeof (List<ContentBaseClass>), FormatterAssemblyStyle.Simple);
string contentSubClassRef = ReflectionUtils.GetTypeName(typeof (ContentSubClass), FormatterAssemblyStyle.Simple, null);
string dictionaryRef = ReflectionUtils.GetTypeName(typeof (Dictionary<int, IList<ContentBaseClass>>), FormatterAssemblyStyle.Simple, null);
string listRef = ReflectionUtils.GetTypeName(typeof (List<ContentBaseClass>), FormatterAssemblyStyle.Simple, null);
string expected = @"{
""TestMember"": {
@@ -816,7 +816,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
});
string urlStatusTypeName = ReflectionUtils.GetTypeName(typeof (UrlStatus), FormatterAssemblyStyle.Simple);
string urlStatusTypeName = ReflectionUtils.GetTypeName(typeof (UrlStatus), FormatterAssemblyStyle.Simple, null);
Assert.AreEqual(@"{
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"",
@@ -867,7 +867,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[Test]
public void SerializingIEnumerableOfTShouldRetainGenericTypeInfo()
{
string productClassRef = ReflectionUtils.GetTypeName(typeof(CustomEnumerable<Product>), FormatterAssemblyStyle.Simple);
string productClassRef = ReflectionUtils.GetTypeName(typeof(CustomEnumerable<Product>), FormatterAssemblyStyle.Simple, null);
CustomEnumerable<Product> products = new CustomEnumerable<Product>();
@@ -951,7 +951,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string output = JsonConvert.SerializeObject(testerObject, Formatting.Indented, jsonSettings);
string carClassRef = ReflectionUtils.GetTypeName(typeof (Car), FormatterAssemblyStyle.Simple);
string carClassRef = ReflectionUtils.GetTypeName(typeof (Car), FormatterAssemblyStyle.Simple, null);
Assert.AreEqual(output, @"{
""$type"": """ + carClassRef + @""",
@@ -1445,7 +1445,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(1, (int)j["MyProperty"]);
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
[Test]
public void PropertyItemTypeNameHandlingDynamic()
{
@@ -1651,7 +1651,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public TypeNameHandlingTestObject Data { get; set; }
}
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE40)
public class PropertyItemTypeNameHandlingDynamic
{
[JsonProperty(ItemTypeNameHandling = TypeNameHandling.All)]
@@ -59,7 +59,7 @@ namespace Newtonsoft.Json.Tests.Serialization
nonSerializedField = "Error"
};
#if !(SILVERLIGHT || NETFX_CORE || NET20 || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || NET20 || PORTABLE || PORTABLE40)
MemoryStream ms = new MemoryStream();
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(SerializableType));
dataContractJsonSerializer.WriteObject(ms, serializableType);
@@ -74,17 +74,17 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(serializableType, new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
IgnoreSerializableAttribute = false
#endif
}
}
});
Assert.AreEqual(expected, json);
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[Test]
public void SerializeInheritedType()
{
@@ -114,7 +114,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[Serializable]
#else
[JsonObject(MemberSerialization.Fields)]
@@ -144,7 +144,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
[NonSerialized]
#else
[JsonIgnore]