diff --git a/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs
index 4bf4f33c..fc85baf3 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
diff --git a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
index 644bb283..fa22a7f9 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs
index c37bd2f0..ef253320 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs
index 0e4d238a..973053ed 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs
@@ -1,4 +1,4 @@
-#region License
+#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Compact.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Compact.csproj
index ee840945..f3ed4cbd 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Compact.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Compact.csproj
@@ -77,6 +77,7 @@
+
@@ -86,29 +87,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -126,6 +143,7 @@
+
@@ -151,9 +169,12 @@
+
+
+
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
index 9ec36bd5..3f4481b7 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
@@ -72,16 +72,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -93,6 +110,7 @@
+
@@ -103,6 +121,8 @@
+
+
@@ -160,6 +180,7 @@
+
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
index 2dc60595..d4fdb92d 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
@@ -83,6 +83,7 @@
+
@@ -92,29 +93,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -132,6 +149,7 @@
+
@@ -157,9 +175,12 @@
+
+
+
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
index 72dffd54..5c49108c 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
@@ -109,9 +109,19 @@
+
+
+
+
+
+
+
+
+
+
@@ -119,6 +129,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
index 1079115f..902005ca 100644
--- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
+++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -17,8 +17,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
-[assembly: AssemblyProduct("Newtonsoft Json.NET Test")]
-[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
+[assembly: AssemblyProduct("Newtonsoft Json.NET Tests")]
+[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
index cb0c870c..ae50dffc 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
@@ -332,26 +332,6 @@ keyword such as type of business.""
Assert.AreEqual(nestedTorrentsArray.Children().Count(), 19);
}
- public class JsonPropertyClass
- {
- [JsonProperty("pie")]
- public string Pie = "Yum";
-
- [JsonIgnore]
- public string pie = "No pie for you!";
-
- public string pie1 = "PieChart!";
-
- private int _sweetCakesCount;
-
- [JsonProperty("sweet_cakes_count")]
- public int SweetCakesCount
- {
- get { return _sweetCakesCount; }
- set { _sweetCakesCount = value; }
- }
- }
-
[Test]
public void JsonPropertyClassSerialize()
{
@@ -1079,72 +1059,6 @@ keyword such as type of business.""
Assert.AreEqual(json, after);
}
- public class GoogleMapGeocoderStructure
- {
- public string Name;
- public Status Status;
- public List Placemark;
- }
-
- public class Status
- {
- public string Request;
- public string Code;
- }
-
- public class Placemark
- {
- public string Address;
- public AddressDetails AddressDetails;
- public Point Point;
- }
-
- public class AddressDetails
- {
- public int Accuracy;
- public Country Country;
- }
-
- public class Country
- {
- public string CountryNameCode;
- public AdministrativeArea AdministrativeArea;
- }
-
- public class AdministrativeArea
- {
- public string AdministrativeAreaName;
- public SubAdministrativeArea SubAdministrativeArea;
- }
-
- public class SubAdministrativeArea
- {
- public string SubAdministrativeAreaName;
- public Locality Locality;
- }
-
- public class Locality
- {
- public string LocalityName;
- public Thoroughfare Thoroughfare;
- public PostalCode PostalCode;
- }
-
- public class Thoroughfare
- {
- public string ThoroughfareName;
- }
-
- public class PostalCode
- {
- public string PostalCodeNumber;
- }
-
- public class Point
- {
- public List Coordinates;
- }
-
[Test]
public void DeserializeGoogleGeoCode()
{
@@ -1191,38 +1105,14 @@ keyword such as type of business.""
GoogleMapGeocoderStructure jsonGoogleMapGeocoder = JsonConvert.DeserializeObject(json);
}
- public class Co : ICo
- {
- public String Name { get; set; }
- }
-
- public interface ICo
- {
- String Name { get; set; }
- }
-
- public interface ITest
- {
- ICo co { get; set; }
- }
-
- public class Test : ITest
- {
- public ICo co { get; set; }
-
- public Test()
- {
- }
- }
-
[Test]
- [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = @"Could not create an instance of type Newtonsoft.Json.Tests.Serialization.JsonSerializerTest+ICo. Type is an interface or abstract class and cannot be instantated.")]
+ [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = @"Could not create an instance of type Newtonsoft.Json.Tests.TestObjects.ICo. Type is an interface or abstract class and cannot be instantated.")]
public void DeserializeInterfaceProperty()
{
- Test testClass = new Test();
+ InterfacePropertyTestClass testClass = new InterfacePropertyTestClass();
testClass.co = new Co();
String strFromTest = JsonConvert.SerializeObject(testClass);
- Test testFromDe = (Test)JsonConvert.DeserializeObject(strFromTest, typeof(Test));
+ InterfacePropertyTestClass testFromDe = (InterfacePropertyTestClass)JsonConvert.DeserializeObject(strFromTest, typeof(InterfacePropertyTestClass));
}
private Person GetPerson()
@@ -1259,12 +1149,6 @@ keyword such as type of business.""
}
}
- public class LogEntry
- {
- public string Details { get; set; }
- public DateTime LogDate { get; set; }
- }
-
[Test]
public void WriteJsonDates()
{
@@ -1334,14 +1218,6 @@ keyword such as type of business.""
CollectionAssert.AreEqual(o.IDictionaryProperty.ToArray(), deserializedObject.IDictionaryProperty.ToArray());
}
- public class PropertyCase
- {
- public string firstName { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string lastName { get; set; }
- }
-
[Test]
public void DeserializeBestMatchPropertyCase()
{
@@ -1361,18 +1237,6 @@ keyword such as type of business.""
Assert.AreEqual("lastName", o.lastName);
}
- public class SuperKlass
- {
- public string SuperProp { get; set; }
- public SuperKlass() { SuperProp = "default superprop"; }
- }
-
- public class SubKlass : SuperKlass
- {
- public string SubProp { get; set; }
- public SubKlass(string subprop) { SubProp = subprop; }
- }
-
[Test]
public void DeserializePropertiesOnToNonDefaultConstructor()
{
@@ -1423,18 +1287,6 @@ keyword such as type of business.""
JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
}
- public class RequestOnly
- {
- public string Request { get; set; }
- }
-
- public class NonRequest
- {
- public Guid Sid { get; set; }
- public Guid Uid { get; set; }
- public IList FidOrder { get; set; }
- }
-
[Test]
public void PartialClassDeserialize()
{
@@ -1565,33 +1417,6 @@ keyword such as type of business.""
}
#endif
- public class DictionaryInterfaceClass
- {
- public string Name { get; set; }
- public IDictionary Dictionary { get; set; }
- public ICollection Collection { get; set; }
- public EmployeeReference Employee { get; set; }
- public object Random { get; set; }
-
- public DictionaryInterfaceClass()
- {
- Dictionary = new Dictionary
- {
- { "existing", 1 }
- };
- Collection = new List
- {
- 1,
- 2,
- 3
- };
- Employee = new EmployeeReference
- {
- Name = "EmployeeName!"
- };
- }
- }
-
[Test]
public void DeserializeDictionaryInterface()
{
@@ -1720,25 +1545,6 @@ keyword such as type of business.""
Assert.AreEqual(@"{""bar"":{""baz"":13}}", json);
}
- [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
- public class Content : IEnumerable
- {
- [JsonProperty]
- public List Children;
- [JsonProperty]
- public string Text;
-
- public IEnumerator GetEnumerator()
- {
- return Children.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return Children.GetEnumerator();
- }
- }
-
[Test]
public void SerializeEnumerableAsObject()
{
@@ -1794,25 +1600,6 @@ keyword such as type of business.""
Assert.AreEqual("Second", content.Children[1].Text);
}
- public enum RoleTransferOperation
- {
- First,
- Second
- }
-
- public enum RoleTransferDirection
- {
- First,
- Second
- }
-
- public class RoleTransfer
- {
- public RoleTransferOperation Operation { get; set; } //This is enum type
- public string RoleName { get; set; }
- public RoleTransferDirection Direction { get; set; } //This is enum type
- }
-
[Test]
public void RoleTransferTest()
{
@@ -1825,13 +1612,6 @@ keyword such as type of business.""
Assert.AreEqual(RoleTransferDirection.First, r.Direction);
}
- public class ObjectArrayPropertyTest
- {
- public string Action { get; set; }
- public string Method { get; set; }
- public object[] Data { get; set; }
- }
-
[Test]
public void PrimitiveValuesInObjectArray()
{
@@ -1975,127 +1755,8 @@ keyword such as type of business.""
Assert.AreEqual(null, c.DateTimeField);
}
- ///
- /// What types of events are there? Just sticking to a basic set of four for now.
- ///
- ///
- public enum EventType
- {
- Debug = 0,
- Info = 1,
- Warning = 2,
- Error = 3
- }
-
- public sealed class Event
- {
-
- ///
- /// If no current user is specified, returns Nothing (0 from VB)
- ///
- ///
- ///
- private static int GetCurrentUserId()
- {
- return 0;
- }
-
- ///
- /// Gets either the application path or the current stack trace.
- /// NOTE: You MUST call this from the top level entry point. Otherwise,
- /// the stack trace will be buried in Logger itself.
- ///
- ///
- ///
- private static string GetCurrentSubLocation()
- {
- return "";
- }
-
- private string _sublocation;
- private int _userId;
- private EventType _type;
- private string _summary;
- private string _details;
- private string _stackTrace;
- private string _tag;
- private DateTime _time;
-
- public Event(string summary)
- {
- _summary = summary;
- _time = DateTime.Now;
-
- if (_userId == 0) _userId = GetCurrentUserId();
- //This call only works at top level for now.
- //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
- if (_sublocation == null) _sublocation = GetCurrentSubLocation();
- }
-
- public Event(string sublocation, int userId, EventType type, string summary, string details, string stackTrace, string tag)
- {
- _sublocation = sublocation;
- _userId = userId;
- _type = type;
- _summary = summary;
- _details = details;
- _stackTrace = stackTrace;
- _tag = tag;
- _time = DateTime.Now;
-
- if (_userId == 0) _userId = GetCurrentUserId();
- //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
- if (_sublocation == null) _sublocation = GetCurrentSubLocation();
- }
-
- public override string ToString()
- {
- return string.Format("{{ sublocation = {0}, userId = {1}, type = {2}, summary = {3}, details = {4}, stackTrace = {5}, tag = {6} }}", _sublocation, _userId, _type, _summary, _details, _stackTrace, _tag);
- }
-
- public string sublocation
- {
- get { return _sublocation; }
- set { _sublocation = value; }
- }
- public int userId
- {
- get { return _userId; }
- set { _userId = value; }
- }
- public EventType type
- {
- get { return _type; }
- set { _type = value; }
- }
- public string summary
- {
- get { return _summary; }
- set { _summary = value; }
- }
- public string details
- {
- get { return _details; }
- set { _details = value; }
- }
- public string stackTrace
- {
- get { return _stackTrace; }
- set { _stackTrace = value; }
- }
- public string tag
- {
- get { return _tag; }
- set { _tag = value; }
- }
- public DateTime time
- {
- get { return _time; }
- }
- }
-
[Test]
- [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = @"Unable to determine which constructor to use for type Newtonsoft.Json.Tests.Serialization.JsonSerializerTest+Event. A class with no default constructor should have only one constructor with arguments.")]
+ [ExpectedException(typeof(JsonSerializationException), ExpectedMessage = @"Unable to determine which constructor to use for type Newtonsoft.Json.Tests.TestObjects.Event. A class with no default constructor should have only one constructor with arguments.")]
public void FailWhenClassWithNoDefaultConstructorHasMultipleConstructorsWithArguments()
{
string json = @"{""sublocation"":""AlertEmailSender.Program.Main"",""userId"":0,""type"":0,""summary"":""Loading settings variables"",""details"":null,""stackTrace"":"" at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)\r\n at System.Environment.get_StackTrace()\r\n at mr.Logging.Event..ctor(String summary) in C:\\Projects\\MRUtils\\Logging\\Event.vb:line 71\r\n at AlertEmailSender.Program.Main(String[] args) in C:\\Projects\\AlertEmailSender\\AlertEmailSender\\Program.cs:line 25"",""tag"":null,""time"":""\/Date(1249591032026-0400)\/""}";
@@ -2103,19 +1764,6 @@ keyword such as type of business.""
Event e = JsonConvert.DeserializeObject(json);
}
- public class SetOnlyPropertyClass2
- {
- private object _value;
- public object SetOnlyProperty
- {
- set { _value = value; }
- }
- public object GetValue()
- {
- return _value;
- }
- }
-
[Test]
public void DeserializeObjectSetOnlyProperty()
{
@@ -2128,29 +1776,12 @@ keyword such as type of business.""
Assert.AreEqual(5, (int)a[a.Count - 1]);
}
- [JsonObject(MemberSerialization.OptIn)]
- public class list
- {
- [JsonProperty]
- public string id { get; set; }
- [JsonProperty]
- public List items { get; set; }
-
- }
-
- [JsonObject(MemberSerialization.OptIn)]
- public class ListItem
- {
- [JsonProperty]
- public string id { get; set; }
- }
-
[Test]
public void DeserializeOptInClasses()
{
string json = @"{id: ""12"", name: ""test"", items: [{id: ""112"", name: ""testing""}]}";
- list l = JsonConvert.DeserializeObject(json);
+ ListTestClass l = JsonConvert.DeserializeObject(json);
}
[Test]
@@ -2163,5 +1794,22 @@ keyword such as type of business.""
Assert.AreEqual(null, l[1]);
Assert.AreEqual(1.1m, l[2]);
}
+
+ [Test]
+ public void DeserializeNullableListWithNullss()
+ {
+ //JavaScriptSerializer s = new JavaScriptSerializer();
+ //s.Deserialize>("[ 3.3, null, 1.1 ] ");
+
+ //DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(List));
+ //s.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes("[ 3.3, null, 1.1 ] ")));
+
+ List l = JsonConvert.DeserializeObject>("[ 3.3, null, 1.1 ] ");
+ Assert.AreEqual(3, l.Count);
+
+ Assert.AreEqual(3.3m, l[0]);
+ Assert.AreEqual(null, l[1]);
+ Assert.AreEqual(1.1m, l[2]);
+ }
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs
new file mode 100644
index 00000000..d36233f3
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs
@@ -0,0 +1,205 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Tests.TestObjects;
+using NUnit.Framework;
+
+namespace Newtonsoft.Json.Tests.Serialization
+{
+ public class SerializationErrorHandlingTests : TestFixtureBase
+ {
+ [Test]
+ public void ErrorDeserializingListHandled()
+ {
+ string json = @"[
+ {
+ ""Name"": ""Jim"",
+ ""BirthDate"": ""\/Date(978048000000)\/"",
+ ""LastModified"": ""\/Date(978048000000)\/""
+ },
+ {
+ ""Name"": ""Jim"",
+ ""BirthDate"": ""\/Date(978048000000)\/"",
+ ""LastModified"": ""\/Date(978048000000)\/""
+ }
+]";
+
+ VersionKeyedCollection c = JsonConvert.DeserializeObject(json);
+ Assert.AreEqual(1, c.Count);
+ Assert.AreEqual(1, c.Messages.Count);
+ Assert.AreEqual("Error message for member 1 = An item with the same key has already been added.", c.Messages[0]);
+ }
+
+ [Test]
+ public void ErrorSerializingListHandled()
+ {
+ VersionKeyedCollection c = new VersionKeyedCollection();
+ c.Add(new Person
+ {
+ Name = "Jim",
+ BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
+ LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
+ });
+ c.Add(new Person
+ {
+ Name = "Jimbo",
+ BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
+ LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
+ });
+ c.Add(new Person
+ {
+ Name = "Jimmy",
+ BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
+ LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
+ });
+ c.Add(new Person
+ {
+ Name = "Jim Bean",
+ BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
+ LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
+ });
+
+ string json = JsonConvert.SerializeObject(c, Formatting.Indented);
+
+ Assert.AreEqual(@"[
+ {
+ ""Name"": ""Jimbo"",
+ ""BirthDate"": ""\/Date(978048000000)\/"",
+ ""LastModified"": ""\/Date(978048000000)\/""
+ },
+ {
+ ""Name"": ""Jim Bean"",
+ ""BirthDate"": ""\/Date(978048000000)\/"",
+ ""LastModified"": ""\/Date(978048000000)\/""
+ }
+]", json);
+
+ Assert.AreEqual(2, c.Messages.Count);
+ Assert.AreEqual("Error message for member 0 = Index even: 0", c.Messages[0]);
+ Assert.AreEqual("Error message for member 2 = Index even: 2", c.Messages[1]);
+ }
+
+ [Test]
+ public void DeserializingErrorInChildObject()
+ {
+ ListErrorObjectCollection c = JsonConvert.DeserializeObject(@"[
+ {
+ ""Member"": ""Value1"",
+ ""Member2"": null
+ },
+ {
+ ""Member"": ""Value2""
+ },
+ {
+ ""ThrowError"": ""Value"",
+ ""Object"": {
+ ""Array"": [
+ 1,
+ 2
+ ]
+ }
+ },
+ {
+ ""ThrowError"": ""Handle this!"",
+ ""Member"": ""Value3""
+ }
+]");
+
+ Assert.AreEqual(3, c.Count);
+ Assert.AreEqual("Value1", c[0].Member);
+ Assert.AreEqual("Value2", c[1].Member);
+ Assert.AreEqual("Value3", c[2].Member);
+ Assert.AreEqual("Handle this!", c[2].ThrowError);
+ }
+
+ [Test]
+ public void SerializingErrorInChildObject()
+ {
+ ListErrorObjectCollection c = new ListErrorObjectCollection
+ {
+ new ListErrorObject
+ {
+ Member = "Value1",
+ ThrowError = "Handle this!",
+ Member2 = "Member1"
+ },
+ new ListErrorObject
+ {
+ Member = "Value2",
+ Member2 = "Member2"
+ },
+ new ListErrorObject
+ {
+ Member = "Value3",
+ ThrowError = "Handle that!",
+ Member2 = "Member3"
+ }
+ };
+
+ string json = JsonConvert.SerializeObject(c, Formatting.Indented);
+
+ Assert.AreEqual(@"[
+ {
+ ""Member"": ""Value1"",
+ ""ThrowError"": ""Handle this!"",
+ ""Member2"": ""Member1""
+ },
+ {
+ ""Member"": ""Value2""
+ },
+ {
+ ""Member"": ""Value3"",
+ ""ThrowError"": ""Handle that!"",
+ ""Member2"": ""Member3""
+ }
+]", json);
+ }
+
+ [Test]
+ public void DeserializingErrorInDateTimeCollection()
+ {
+ DateTimeErrorObjectCollection c = JsonConvert.DeserializeObject(@"[
+ ""2009-09-09T00:00:00Z"",
+ ""kjhkjhkjhkjh"",
+ [
+ 1
+ ],
+ ""1977-02-20T00:00:00Z"",
+ null,
+ ""2000-12-01T00:00:00Z""
+]", new IsoDateTimeConverter());
+
+ Assert.AreEqual(3, c.Count);
+ Assert.AreEqual(new DateTime(2009, 9, 9, 0, 0, 0, DateTimeKind.Utc), c[0]);
+ Assert.AreEqual(new DateTime(1977, 2, 20, 0, 0, 0, DateTimeKind.Utc), c[1]);
+ Assert.AreEqual(new DateTime(2000, 12, 1, 0, 0, 0, DateTimeKind.Utc), c[2]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs
index 3acaf37a..7a703904 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs
@@ -25,19 +25,14 @@
#if !PocketPC && !SILVERLIGHT && !NET20
using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Runtime.Serialization;
using System.Text;
-using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests;
using Newtonsoft.Json.Tests.TestObjects;
using NUnit.Framework;
using Newtonsoft.Json.Linq;
-using System.Collections;
using Newtonsoft.Json.Converters;
namespace Newtonsoft.Json.Tests.Serialization
@@ -114,254 +109,6 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual("This value was set after deserialization.", obj.Member4);
}
- public class ListErrorObject
- {
- public string Member { get; set; }
-
- private string _throwError;
- public string ThrowError
- {
- get
- {
- if (_throwError != null)
- return _throwError;
-
- throw new Exception("ListErrorObject.ThrowError get error!");
- }
- set
- {
- if (value != null && value.StartsWith("Handle"))
- {
- _throwError = value;
- return;
- }
-
- throw new Exception("ListErrorObject.ThrowError set error!");
- }
- }
-
- public string Member2 { get; set; }
- }
-
- public class ListErrorObjectCollection : Collection
- {
- [OnError]
- internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
- {
- errorContext.Handled = true;
- }
- }
-
- public class DateTimeErrorObjectCollection : Collection
- {
- [OnError]
- internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
- {
- errorContext.Handled = true;
- }
- }
-
- public class VersionKeyedCollection : KeyedCollection, IList
- {
- public List Messages { get; set; }
-
- public VersionKeyedCollection()
- {
- Messages = new List();
- }
-
- protected override string GetKeyForItem(Person item)
- {
- return item.Name;
- }
-
- [OnError]
- internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
- {
- Messages.Add("Error message for member " + errorContext.Member + " = " + errorContext.Error.Message);
- errorContext.Handled = true;
- }
-
- object IList.this[int index]
- {
- get
- {
- if (index % 2 == 0)
- throw new Exception("Index even: " + index);
-
- return this[index];
- }
- set { this[index] = (Person)value; }
- }
- }
-
- [Test]
- public void ErrorDeserializingListHandled()
- {
- string json = @"[
- {
- ""Name"": ""Jim"",
- ""BirthDate"": ""\/Date(978048000000)\/"",
- ""LastModified"": ""\/Date(978048000000)\/""
- },
- {
- ""Name"": ""Jim"",
- ""BirthDate"": ""\/Date(978048000000)\/"",
- ""LastModified"": ""\/Date(978048000000)\/""
- }
-]";
-
- VersionKeyedCollection c = JsonConvert.DeserializeObject(json);
- Assert.AreEqual(1, c.Count);
- Assert.AreEqual(1, c.Messages.Count);
- Assert.AreEqual("Error message for member 1 = An item with the same key has already been added.", c.Messages[0]);
- }
-
- [Test]
- public void ErrorSerializingListHandled()
- {
- VersionKeyedCollection c = new VersionKeyedCollection();
- c.Add(new Person
- {
- Name = "Jim",
- BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
- LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
- });
- c.Add(new Person
- {
- Name = "Jimbo",
- BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
- LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
- });
- c.Add(new Person
- {
- Name = "Jimmy",
- BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
- LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
- });
- c.Add(new Person
- {
- Name = "Jim Bean",
- BirthDate = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc),
- LastModified = new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc)
- });
-
- string json = JsonConvert.SerializeObject(c, Formatting.Indented);
-
- Assert.AreEqual(@"[
- {
- ""Name"": ""Jimbo"",
- ""BirthDate"": ""\/Date(978048000000)\/"",
- ""LastModified"": ""\/Date(978048000000)\/""
- },
- {
- ""Name"": ""Jim Bean"",
- ""BirthDate"": ""\/Date(978048000000)\/"",
- ""LastModified"": ""\/Date(978048000000)\/""
- }
-]", json);
-
- Assert.AreEqual(2, c.Messages.Count);
- Assert.AreEqual("Error message for member 0 = Index even: 0", c.Messages[0]);
- Assert.AreEqual("Error message for member 2 = Index even: 2", c.Messages[1]);
- }
-
- [Test]
- public void DeserializingErrorInChildObject()
- {
- ListErrorObjectCollection c = JsonConvert.DeserializeObject(@"[
- {
- ""Member"": ""Value1"",
- ""Member2"": null
- },
- {
- ""Member"": ""Value2""
- },
- {
- ""ThrowError"": ""Value"",
- ""Object"": {
- ""Array"": [
- 1,
- 2
- ]
- }
- },
- {
- ""ThrowError"": ""Handle this!"",
- ""Member"": ""Value3""
- }
-]");
-
- Assert.AreEqual(3, c.Count);
- Assert.AreEqual("Value1", c[0].Member);
- Assert.AreEqual("Value2", c[1].Member);
- Assert.AreEqual("Value3", c[2].Member);
- Assert.AreEqual("Handle this!", c[2].ThrowError);
- }
-
- [Test]
- public void SerializingErrorInChildObject()
- {
- ListErrorObjectCollection c = new ListErrorObjectCollection
- {
- new ListErrorObject
- {
- Member = "Value1",
- ThrowError = "Handle this!",
- Member2 = "Member1"
- },
- new ListErrorObject
- {
- Member = "Value2",
- Member2 = "Member2"
- },
- new ListErrorObject
- {
- Member = "Value3",
- ThrowError = "Handle that!",
- Member2 = "Member3"
- }
- };
-
- string json = JsonConvert.SerializeObject(c, Formatting.Indented);
-
- Assert.AreEqual(@"[
- {
- ""Member"": ""Value1"",
- ""ThrowError"": ""Handle this!"",
- ""Member2"": ""Member1""
- },
- {
- ""Member"": ""Value2""
- },
- {
- ""Member"": ""Value3"",
- ""ThrowError"": ""Handle that!"",
- ""Member2"": ""Member3""
- }
-]", json);
- }
-
- [Test]
- public void DeserializingErrorInDateTimeCollection()
- {
- DateTimeErrorObjectCollection c = JsonConvert.DeserializeObject(@"[
- ""2009-09-09T00:00:00Z"",
- ""kjhkjhkjhkjh"",
- [
- 1
- ],
- ""1977-02-20T00:00:00Z"",
- null,
- ""2000-12-01T00:00:00Z""
-]", new IsoDateTimeConverter());
-
- Assert.AreEqual(3, c.Count);
- Assert.AreEqual(new DateTime(2009, 9, 9, 0, 0, 0, DateTimeKind.Utc), c[0]);
- Assert.AreEqual(new DateTime(1977, 2, 20, 0, 0, 0, DateTimeKind.Utc), c[1]);
- Assert.AreEqual(new DateTime(2000, 12, 1, 0, 0, 0, DateTimeKind.Utc), c[2]);
- }
-
[Test]
public void ListEvents()
{
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Content.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Content.cs
new file mode 100644
index 00000000..ae8e8765
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/Content.cs
@@ -0,0 +1,49 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
+ public class Content : IEnumerable
+ {
+ [JsonProperty]
+ public List Children;
+ [JsonProperty]
+ public string Text;
+
+ public IEnumerator GetEnumerator()
+ {
+ return Children.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return Children.GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/DateTimeErrorObjectCollection.cs b/Src/Newtonsoft.Json.Tests/TestObjects/DateTimeErrorObjectCollection.cs
new file mode 100644
index 00000000..7a1b964b
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/DateTimeErrorObjectCollection.cs
@@ -0,0 +1,41 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using Newtonsoft.Json.Serialization;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class DateTimeErrorObjectCollection : Collection
+ {
+ [OnError]
+ internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
+ {
+ errorContext.Handled = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/DictionaryInterfaceClass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/DictionaryInterfaceClass.cs
new file mode 100644
index 00000000..611e4787
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/DictionaryInterfaceClass.cs
@@ -0,0 +1,57 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System.Collections.Generic;
+using Newtonsoft.Json.Tests.TestObjects;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class DictionaryInterfaceClass
+ {
+ public string Name { get; set; }
+ public IDictionary Dictionary { get; set; }
+ public ICollection Collection { get; set; }
+ public EmployeeReference Employee { get; set; }
+ public object Random { get; set; }
+
+ public DictionaryInterfaceClass()
+ {
+ Dictionary = new Dictionary
+ {
+ { "existing", 1 }
+ };
+ Collection = new List
+ {
+ 1,
+ 2,
+ 3
+ };
+ Employee = new EmployeeReference
+ {
+ Name = "EmployeeName!"
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Event.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Event.cs
new file mode 100644
index 00000000..f487e5ca
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/Event.cs
@@ -0,0 +1,148 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ ///
+ /// What types of events are there? Just sticking to a basic set of four for now.
+ ///
+ ///
+ public enum EventType
+ {
+ Debug = 0,
+ Info = 1,
+ Warning = 2,
+ Error = 3
+ }
+
+ public sealed class Event
+ {
+
+ ///
+ /// If no current user is specified, returns Nothing (0 from VB)
+ ///
+ ///
+ ///
+ private static int GetCurrentUserId()
+ {
+ return 0;
+ }
+
+ ///
+ /// Gets either the application path or the current stack trace.
+ /// NOTE: You MUST call this from the top level entry point. Otherwise,
+ /// the stack trace will be buried in Logger itself.
+ ///
+ ///
+ ///
+ private static string GetCurrentSubLocation()
+ {
+ return "";
+ }
+
+ private string _sublocation;
+ private int _userId;
+ private EventType _type;
+ private string _summary;
+ private string _details;
+ private string _stackTrace;
+ private string _tag;
+ private DateTime _time;
+
+ public Event(string summary)
+ {
+ _summary = summary;
+ _time = DateTime.Now;
+
+ if (_userId == 0) _userId = GetCurrentUserId();
+ //This call only works at top level for now.
+ //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
+ if (_sublocation == null) _sublocation = GetCurrentSubLocation();
+ }
+
+ public Event(string sublocation, int userId, EventType type, string summary, string details, string stackTrace, string tag)
+ {
+ _sublocation = sublocation;
+ _userId = userId;
+ _type = type;
+ _summary = summary;
+ _details = details;
+ _stackTrace = stackTrace;
+ _tag = tag;
+ _time = DateTime.Now;
+
+ if (_userId == 0) _userId = GetCurrentUserId();
+ //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
+ if (_sublocation == null) _sublocation = GetCurrentSubLocation();
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{{ sublocation = {0}, userId = {1}, type = {2}, summary = {3}, details = {4}, stackTrace = {5}, tag = {6} }}", _sublocation, _userId, _type, _summary, _details, _stackTrace, _tag);
+ }
+
+ public string sublocation
+ {
+ get { return _sublocation; }
+ set { _sublocation = value; }
+ }
+ public int userId
+ {
+ get { return _userId; }
+ set { _userId = value; }
+ }
+ public EventType type
+ {
+ get { return _type; }
+ set { _type = value; }
+ }
+ public string summary
+ {
+ get { return _summary; }
+ set { _summary = value; }
+ }
+ public string details
+ {
+ get { return _details; }
+ set { _details = value; }
+ }
+ public string stackTrace
+ {
+ get { return _stackTrace; }
+ set { _stackTrace = value; }
+ }
+ public string tag
+ {
+ get { return _tag; }
+ set { _tag = value; }
+ }
+ public DateTime time
+ {
+ get { return _time; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/GoogleMapGeocoderStructure.cs b/Src/Newtonsoft.Json.Tests/TestObjects/GoogleMapGeocoderStructure.cs
new file mode 100644
index 00000000..2f48bfdf
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/GoogleMapGeocoderStructure.cs
@@ -0,0 +1,95 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System.Collections.Generic;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class GoogleMapGeocoderStructure
+ {
+ public string Name;
+ public Status Status;
+ public List Placemark;
+ }
+
+ public class Status
+ {
+ public string Request;
+ public string Code;
+ }
+
+ public class Placemark
+ {
+ public string Address;
+ public AddressDetails AddressDetails;
+ public Point Point;
+ }
+
+ public class AddressDetails
+ {
+ public int Accuracy;
+ public Country Country;
+ }
+
+ public class Country
+ {
+ public string CountryNameCode;
+ public AdministrativeArea AdministrativeArea;
+ }
+
+ public class AdministrativeArea
+ {
+ public string AdministrativeAreaName;
+ public SubAdministrativeArea SubAdministrativeArea;
+ }
+
+ public class SubAdministrativeArea
+ {
+ public string SubAdministrativeAreaName;
+ public Locality Locality;
+ }
+
+ public class Locality
+ {
+ public string LocalityName;
+ public Thoroughfare Thoroughfare;
+ public PostalCode PostalCode;
+ }
+
+ public class Thoroughfare
+ {
+ public string ThoroughfareName;
+ }
+
+ public class PostalCode
+ {
+ public string PostalCodeNumber;
+ }
+
+ public class Point
+ {
+ public List Coordinates;
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/InterfacePropertyTestClass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/InterfacePropertyTestClass.cs
new file mode 100644
index 00000000..e2b104b7
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/InterfacePropertyTestClass.cs
@@ -0,0 +1,51 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class Co : ICo
+ {
+ public string Name { get; set; }
+ }
+
+ public interface ICo
+ {
+ string Name { get; set; }
+ }
+
+ public interface IInterfacePropertyTestClass
+ {
+ ICo co { get; set; }
+ }
+
+ public class InterfacePropertyTestClass : IInterfacePropertyTestClass
+ {
+ public ICo co { get; set; }
+
+ public InterfacePropertyTestClass()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/JsonPropertyClass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/JsonPropertyClass.cs
new file mode 100644
index 00000000..71eda50e
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/JsonPropertyClass.cs
@@ -0,0 +1,47 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class JsonPropertyClass
+ {
+ [JsonProperty("pie")]
+ public string Pie = "Yum";
+
+ [JsonIgnore]
+ public string pie = "No pie for you!";
+
+ public string pie1 = "PieChart!";
+
+ private int _sweetCakesCount;
+
+ [JsonProperty("sweet_cakes_count")]
+ public int SweetCakesCount
+ {
+ get { return _sweetCakesCount; }
+ set { _sweetCakesCount = value; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObject.cs b/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObject.cs
new file mode 100644
index 00000000..3ac1affb
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObject.cs
@@ -0,0 +1,58 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class ListErrorObject
+ {
+ public string Member { get; set; }
+
+ private string _throwError;
+ public string ThrowError
+ {
+ get
+ {
+ if (_throwError != null)
+ return _throwError;
+
+ throw new Exception("ListErrorObject.ThrowError get error!");
+ }
+ set
+ {
+ if (value != null && value.StartsWith("Handle"))
+ {
+ _throwError = value;
+ return;
+ }
+
+ throw new Exception("ListErrorObject.ThrowError set error!");
+ }
+ }
+
+ public string Member2 { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObjectCollection.cs b/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObjectCollection.cs
new file mode 100644
index 00000000..0d9837a2
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/ListErrorObjectCollection.cs
@@ -0,0 +1,40 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using Newtonsoft.Json.Serialization;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class ListErrorObjectCollection : Collection
+ {
+ [OnError]
+ internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
+ {
+ errorContext.Handled = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/ListTestClass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/ListTestClass.cs
new file mode 100644
index 00000000..38ca989b
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/ListTestClass.cs
@@ -0,0 +1,45 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System.Collections.Generic;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ [JsonObject(MemberSerialization.OptIn)]
+ public class ListTestClass
+ {
+ [JsonProperty]
+ public string id { get; set; }
+ [JsonProperty]
+ public List items { get; set; }
+ }
+
+ [JsonObject(MemberSerialization.OptIn)]
+ public class ListItem
+ {
+ [JsonProperty]
+ public string id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/LogEntry.cs b/Src/Newtonsoft.Json.Tests/TestObjects/LogEntry.cs
new file mode 100644
index 00000000..7f3fbcad
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/LogEntry.cs
@@ -0,0 +1,35 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class LogEntry
+ {
+ public string Details { get; set; }
+ public DateTime LogDate { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/NonRequest.cs b/Src/Newtonsoft.Json.Tests/TestObjects/NonRequest.cs
new file mode 100644
index 00000000..44f1dce7
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/NonRequest.cs
@@ -0,0 +1,37 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class NonRequest
+ {
+ public Guid Sid { get; set; }
+ public Guid Uid { get; set; }
+ public IList FidOrder { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/ObjectArrayPropertyTest.cs b/Src/Newtonsoft.Json.Tests/TestObjects/ObjectArrayPropertyTest.cs
new file mode 100644
index 00000000..a11b09f0
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/ObjectArrayPropertyTest.cs
@@ -0,0 +1,34 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class ObjectArrayPropertyTest
+ {
+ public string Action { get; set; }
+ public string Method { get; set; }
+ public object[] Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/PropertyCase.cs b/Src/Newtonsoft.Json.Tests/TestObjects/PropertyCase.cs
new file mode 100644
index 00000000..c6a463e9
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/PropertyCase.cs
@@ -0,0 +1,35 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class PropertyCase
+ {
+ public string firstName { get; set; }
+ public string FirstName { get; set; }
+ public string LastName { get; set; }
+ public string lastName { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/RequestOnly.cs b/Src/Newtonsoft.Json.Tests/TestObjects/RequestOnly.cs
new file mode 100644
index 00000000..475e05d8
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/RequestOnly.cs
@@ -0,0 +1,32 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class RequestOnly
+ {
+ public string Request { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/RoleTransfer.cs b/Src/Newtonsoft.Json.Tests/TestObjects/RoleTransfer.cs
new file mode 100644
index 00000000..b321c01e
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/RoleTransfer.cs
@@ -0,0 +1,46 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public enum RoleTransferOperation
+ {
+ First,
+ Second
+ }
+
+ public enum RoleTransferDirection
+ {
+ First,
+ Second
+ }
+
+ public class RoleTransfer
+ {
+ public RoleTransferOperation Operation { get; set; } //This is enum type
+ public string RoleName { get; set; }
+ public RoleTransferDirection Direction { get; set; } //This is enum type
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/SetOnlyPropertyClass2.cs b/Src/Newtonsoft.Json.Tests/TestObjects/SetOnlyPropertyClass2.cs
new file mode 100644
index 00000000..26ec4c4d
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/SetOnlyPropertyClass2.cs
@@ -0,0 +1,40 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class SetOnlyPropertyClass2
+ {
+ private object _value;
+ public object SetOnlyProperty
+ {
+ set { _value = value; }
+ }
+ public object GetValue()
+ {
+ return _value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/SubKlass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/SubKlass.cs
new file mode 100644
index 00000000..14ace570
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/SubKlass.cs
@@ -0,0 +1,33 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class SubKlass : SuperKlass
+ {
+ public string SubProp { get; set; }
+ public SubKlass(string subprop) { SubProp = subprop; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/SuperKlass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/SuperKlass.cs
new file mode 100644
index 00000000..810246ae
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/SuperKlass.cs
@@ -0,0 +1,33 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class SuperKlass
+ {
+ public string SuperProp { get; set; }
+ public SuperKlass() { SuperProp = "default superprop"; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/VersionKeyedCollection.cs b/Src/Newtonsoft.Json.Tests/TestObjects/VersionKeyedCollection.cs
new file mode 100644
index 00000000..24ff4216
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/TestObjects/VersionKeyedCollection.cs
@@ -0,0 +1,69 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using Newtonsoft.Json.Serialization;
+using Newtonsoft.Json.Tests.TestObjects;
+
+namespace Newtonsoft.Json.Tests.TestObjects
+{
+ public class VersionKeyedCollection : KeyedCollection, IList
+ {
+ public List Messages { get; set; }
+
+ public VersionKeyedCollection()
+ {
+ Messages = new List();
+ }
+
+ protected override string GetKeyForItem(Person item)
+ {
+ return item.Name;
+ }
+
+ [OnError]
+ internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
+ {
+ Messages.Add("Error message for member " + errorContext.Member + " = " + errorContext.Error.Message);
+ errorContext.Handled = true;
+ }
+
+ object IList.this[int index]
+ {
+ get
+ {
+ if (index % 2 == 0)
+ throw new Exception("Index even: " + index);
+
+ return this[index];
+ }
+ set { this[index] = (Person)value; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Converters/EntityKeyMemberConverter.cs b/Src/Newtonsoft.Json/Converters/EntityKeyMemberConverter.cs
index 44436639..bfa52225 100644
--- a/Src/Newtonsoft.Json/Converters/EntityKeyMemberConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/EntityKeyMemberConverter.cs
@@ -32,8 +32,17 @@ using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Converters
{
+ ///
+ /// Converts an Entity Framework EntityKey to and from JSON.
+ ///
public class EntityKeyMemberConverter : JsonConverter
{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
EntityKeyMember entityKeyMember = (EntityKeyMember) value;
@@ -77,6 +86,13 @@ namespace Newtonsoft.Json.Converters
throw new JsonSerializationException("Unexpected end.");
}
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The calling serializer.
+ /// The object value.
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
{
EntityKeyMember entityKeyMember = new EntityKeyMember();
@@ -100,6 +116,13 @@ namespace Newtonsoft.Json.Converters
return entityKeyMember;
}
+ ///
+ /// Determines whether this instance can convert the specified object type.
+ ///
+ /// Type of the object.
+ ///
+ /// true if this instance can convert the specified object type; otherwise, false.
+ ///
public override bool CanConvert(Type objectType)
{
return typeof(EntityKeyMember).IsAssignableFrom(objectType);
diff --git a/Src/Newtonsoft.Json/JsonConvert.cs b/Src/Newtonsoft.Json/JsonConvert.cs
index 6b6eb17e..9c6d4436 100644
--- a/Src/Newtonsoft.Json/JsonConvert.cs
+++ b/Src/Newtonsoft.Json/JsonConvert.cs
@@ -603,7 +603,7 @@ namespace Newtonsoft.Json
///
/// Deserializes the JSON string to the specified type.
///
- /// The object to deserialize.
+ /// The JSON to deserialize.
/// The type of the object to deserialize.
///
/// The used to deserialize the object.
@@ -628,12 +628,26 @@ namespace Newtonsoft.Json
return deserializedValue;
}
+ ///
+ /// Populates the object with values from the JSON string.
+ ///
+ /// The JSON to populate values from.
+ /// The target object to populate values onto.
public static void PopulateObject(string value, object target)
{
PopulateObject(value, target, null);
}
+ ///
+ /// Populates the object with values from the JSON string.
+ ///
+ /// The JSON to populate values from.
+ /// The target object to populate values onto.
+ ///
+ /// The used to deserialize the object.
+ /// If this is null, default serialization settings will be is used.
+ ///
public static void PopulateObject(string value, object target, JsonSerializerSettings settings)
{
StringReader sr = new StringReader(value);
diff --git a/Src/Newtonsoft.Json/Linq/JContainer.cs b/Src/Newtonsoft.Json/Linq/JContainer.cs
index 1045d191..13bf662e 100644
--- a/Src/Newtonsoft.Json/Linq/JContainer.cs
+++ b/Src/Newtonsoft.Json/Linq/JContainer.cs
@@ -97,13 +97,21 @@ namespace Newtonsoft.Json.Linq
}
#if !SILVERLIGHT
- protected virtual void OnAddingNew(AddingNewEventArgs e)
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ protected virtual void OnAddingNew(AddingNewEventArgs e)
{
AddingNewEventHandler handler = AddingNew;
if (handler != null)
handler(this, e);
}
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
protected virtual void OnListChanged(ListChangedEventArgs e)
{
ListChangedEventHandler handler = ListChanged;
diff --git a/Src/Newtonsoft.Json/Linq/JObject.cs b/Src/Newtonsoft.Json/Linq/JObject.cs
index 4d00b292..b7a36299 100644
--- a/Src/Newtonsoft.Json/Linq/JObject.cs
+++ b/Src/Newtonsoft.Json/Linq/JObject.cs
@@ -462,6 +462,10 @@ namespace Newtonsoft.Json.Linq
}
}
+ ///
+ /// Raises the event with the provided arguments.
+ ///
+ /// Name of the property.
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
@@ -469,6 +473,10 @@ namespace Newtonsoft.Json.Linq
}
#if !PocketPC && !SILVERLIGHT
+ ///
+ /// Raises the event with the provided arguments.
+ ///
+ /// Name of the property.
protected virtual void OnPropertyChanging(string propertyName)
{
if (PropertyChanging != null)
diff --git a/Src/Newtonsoft.Json/Linq/JProperty.cs b/Src/Newtonsoft.Json/Linq/JProperty.cs
index ffd79851..7996ed75 100644
--- a/Src/Newtonsoft.Json/Linq/JProperty.cs
+++ b/Src/Newtonsoft.Json/Linq/JProperty.cs
@@ -153,6 +153,12 @@ namespace Newtonsoft.Json.Linq
throw new Exception("Cannot add or remove items from {0}.".FormatWith(CultureInfo.InvariantCulture, typeof(JProperty)));
}
+ ///
+ /// Returns a collection of the child tokens of this token, in document order.
+ ///
+ ///
+ /// An of containing the child tokens of this , in document order.
+ ///
public override JEnumerable Children()
{
return new JEnumerable(ChildrenInternal());
diff --git a/Src/Newtonsoft.Json/Linq/JValue.cs b/Src/Newtonsoft.Json/Linq/JValue.cs
index f9689255..275c211f 100644
--- a/Src/Newtonsoft.Json/Linq/JValue.cs
+++ b/Src/Newtonsoft.Json/Linq/JValue.cs
@@ -365,6 +365,12 @@ namespace Newtonsoft.Json.Linq
return base.Equals(obj);
}
+ ///
+ /// Serves as a hash function for a particular type.
+ ///
+ ///
+ /// A hash code for the current .
+ ///
public override int GetHashCode()
{
if (_value == null)
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Compact.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Compact.csproj
index d9a7a5a7..7e4bb94c 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.Compact.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Compact.csproj
@@ -148,6 +148,7 @@
+
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
index 1069caf5..711475c5 100644
--- a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
+++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj
@@ -112,6 +112,7 @@
+
@@ -124,6 +125,8 @@
+
+
diff --git a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
index 96b9f689..cd29f0da 100644
--- a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
+++ b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
@@ -161,12 +161,12 @@ namespace Newtonsoft.Json.Serialization
}
#endif
-#if !PocketPC && !SILVERLIGHT && !NET20
foreach (MethodInfo method in contract.UnderlyingType.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
Type prevAttributeType = null;
ParameterInfo[] parameters = method.GetParameters();
+#if !PocketPC && !SILVERLIGHT && !NET20
if (IsValidCallback(method, parameters, typeof(OnSerializingAttribute), contract.OnSerializing, ref prevAttributeType))
{
contract.OnSerializing = method;
@@ -183,12 +183,12 @@ namespace Newtonsoft.Json.Serialization
{
contract.OnDeserialized = method;
}
+#endif
if (IsValidCallback(method, parameters, typeof(OnErrorAttribute), contract.OnError, ref prevAttributeType))
{
contract.OnError = method;
}
}
-#endif
}
///
@@ -235,7 +235,6 @@ namespace Newtonsoft.Json.Serialization
return CreateObjectContract(objectType);
}
-#if !PocketPC && !SILVERLIGHT && !NET20
private static bool IsValidCallback(MethodInfo method, ParameterInfo[] parameters, Type attributeType, MethodInfo currentCallback, ref Type prevAttributeType)
{
if (!method.IsDefined(attributeType, false))
@@ -268,7 +267,6 @@ namespace Newtonsoft.Json.Serialization
return true;
}
-#endif
internal static string GetClrTypeFullName(Type type)
{
diff --git a/Src/Newtonsoft.Json/Serialization/ErrorContext.cs b/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
index 1dff26df..2756d930 100644
--- a/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
+++ b/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
-#if !PocketPC && !SILVERLIGHT && !NET20
using System;
using System.Collections.Generic;
using System.Linq;
@@ -64,5 +63,4 @@ namespace Newtonsoft.Json.Serialization
/// true if handled; otherwise, false.
public bool Handled { get; set; }
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Serialization/JsonContract.cs b/Src/Newtonsoft.Json/Serialization/JsonContract.cs
index be3a42f6..2ab8c2b6 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonContract.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonContract.cs
@@ -46,10 +46,10 @@ namespace Newtonsoft.Json.Serialization
/// Whether this type contract is serialized as a reference.
public bool? IsReference { get; set; }
-#if !PocketPC && !SILVERLIGHT
private static readonly StreamingContext SerializationStreamingContextParameter = new StreamingContext(StreamingContextStates.All);
private static readonly object[] SerializationEventParameterValues = new object[] { SerializationStreamingContextParameter };
+#if !PocketPC && !SILVERLIGHT
///
/// Gets or sets the method called immediately after deserialization of the object.
///
@@ -70,10 +70,14 @@ namespace Newtonsoft.Json.Serialization
///
/// The method called before serialization of the object.
public MethodInfo OnSerializing { get; set; }
-
- public MethodInfo OnError { get; set; }
#endif
+ ///
+ /// Gets or sets the method called when an error is thrown during the serialization of the object.
+ ///
+ /// The method called when an error is thrown during the serialization of the object.
+ public MethodInfo OnError { get; set; }
+
internal void InvokeOnSerializing(object o)
{
#if !PocketPC && !SILVERLIGHT
@@ -106,13 +110,11 @@ namespace Newtonsoft.Json.Serialization
#endif
}
-#if !PocketPC && !SILVERLIGHT && !NET20
internal void InvokeOnError(object o, ErrorContext errorContext)
{
if (OnError != null)
OnError.Invoke(o, new object[] { SerializationStreamingContextParameter, errorContext });
}
-#endif
internal JsonContract(Type underlyingType)
{
diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs
index c3cd4feb..de9ccb04 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs
@@ -31,7 +31,6 @@ namespace Newtonsoft.Json.Serialization
{
internal abstract class JsonSerializerInternalBase
{
-#if !PocketPC && !SILVERLIGHT && !NET20
private ErrorContext _currentErrorContext;
protected ErrorContext GetErrorContext(object originalObject, object member, Exception error)
@@ -52,6 +51,5 @@ namespace Newtonsoft.Json.Serialization
_currentErrorContext = null;
}
-#endif
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs
index 0d03ef31..53cde677 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs
@@ -465,14 +465,12 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(dictionary.UnderlyingDictionary, keyValue, ex);
contract.InvokeOnError(dictionary.UnderlyingDictionary, errorContext);
if (errorContext.Handled)
HandleError(reader, initialDepth);
else
-#endif
throw;
}
break;
@@ -498,9 +496,9 @@ namespace Newtonsoft.Json.Serialization
#if !PocketPC && !SILVERLIGHT
if (contract.OnSerializing != null && isTemporaryListReference)
throw new JsonSerializationException("Cannot call OnSerializing on an array or readonly list: {0}".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
+#endif
if (contract.OnError != null && isTemporaryListReference)
throw new JsonSerializationException("Cannot call OnError on an array or readonly list: {0}".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
-#endif
PopulateList(CollectionUtils.CreateCollectionWrapper(l), reader, reference, contract);
});
@@ -536,14 +534,12 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(list, wrappedList.Count, ex);
contract.InvokeOnError(list, errorContext);
if (errorContext.Handled)
HandleError(reader, initialDepth);
else
-#endif
throw;
}
break;
@@ -682,14 +678,12 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(newObject, memberName, ex);
contract.InvokeOnError(newObject, errorContext);
if (errorContext.Handled)
HandleError(reader, initialDepth);
else
-#endif
throw;
}
break;
@@ -734,7 +728,6 @@ namespace Newtonsoft.Json.Serialization
}
}
-#if !PocketPC && !SILVERLIGHT && !NET20
private void HandleError(JsonReader reader, int initialDepth)
{
ClearErrorContext();
@@ -744,6 +737,5 @@ namespace Newtonsoft.Json.Serialization
reader.Read();
}
}
-#endif
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs
index d3e92b05..1dd24ee8 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs
@@ -296,14 +296,12 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(value, property.Member.Name, ex);
contract.InvokeOnError(value, errorContext);
if (errorContext.Handled)
HandleError(writer, initialDepth);
else
-#endif
throw;
}
}
@@ -403,15 +401,13 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(values, i, ex);
contract.InvokeOnError(values, errorContext);
if (errorContext.Handled)
HandleError(writer, initialDepth);
else
-#endif
- throw;
+ throw;
}
}
@@ -472,15 +468,13 @@ namespace Newtonsoft.Json.Serialization
}
catch (Exception ex)
{
-#if !PocketPC && !SILVERLIGHT && !NET20
ErrorContext errorContext = GetErrorContext(values, propertyName, ex);
contract.InvokeOnError(values, errorContext);
if (errorContext.Handled)
HandleError(writer, initialDepth);
else
-#endif
- throw;
+ throw;
}
}
@@ -490,7 +484,6 @@ namespace Newtonsoft.Json.Serialization
contract.InvokeOnSerialized(values);
}
-#if !PocketPC && !SILVERLIGHT && !NET20
private void HandleError(JsonWriter writer, int initialDepth)
{
ClearErrorContext();
@@ -500,6 +493,5 @@ namespace Newtonsoft.Json.Serialization
writer.WriteEnd();
}
}
-#endif
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Serialization/OnErrorAttribute.cs b/Src/Newtonsoft.Json/Serialization/OnErrorAttribute.cs
index bbb8b77d..3948fa38 100644
--- a/Src/Newtonsoft.Json/Serialization/OnErrorAttribute.cs
+++ b/Src/Newtonsoft.Json/Serialization/OnErrorAttribute.cs
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
-#if !PocketPC && !SILVERLIGHT && !NET20
using System;
namespace Newtonsoft.Json.Serialization
@@ -35,5 +34,4 @@ namespace Newtonsoft.Json.Serialization
public sealed class OnErrorAttribute : Attribute
{
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/StreamingContext.cs b/Src/Newtonsoft.Json/StreamingContext.cs
new file mode 100644
index 00000000..3bede1d0
--- /dev/null
+++ b/Src/Newtonsoft.Json/StreamingContext.cs
@@ -0,0 +1,64 @@
+#if PocketPC || SILVERLIGHT
+#pragma warning disable 1591
+
+// This class is... borrowed from .NET and Microsoft for a short time.
+// Hopefully Microsoft will add DateTimeOffset to the compact framework
+// or I will rewrite a striped down version of this file myself
+
+namespace System.Runtime.Serialization
+{
+ public enum StreamingContextStates
+ {
+ All = 255,
+ Clone = 64,
+ CrossAppDomain = 128,
+ CrossMachine = 2,
+ CrossProcess = 1,
+ File = 4,
+ Other = 32,
+ Persistence = 8,
+ Remoting = 16
+ }
+
+ public struct StreamingContext
+ {
+ internal object m_additionalContext;
+ internal StreamingContextStates m_state;
+ public StreamingContext(StreamingContextStates state)
+ : this(state, null)
+ {
+ }
+
+ public StreamingContext(StreamingContextStates state, object additional)
+ {
+ this.m_state = state;
+ this.m_additionalContext = additional;
+ }
+
+ public object Context
+ {
+ get
+ {
+ return this.m_additionalContext;
+ }
+ }
+ public override bool Equals(object obj)
+ {
+ return ((obj is StreamingContext) && ((((StreamingContext)obj).m_additionalContext == this.m_additionalContext) && (((StreamingContext)obj).m_state == this.m_state)));
+ }
+
+ public override int GetHashCode()
+ {
+ return (int)this.m_state;
+ }
+
+ public StreamingContextStates State
+ {
+ get
+ {
+ return this.m_state;
+ }
+ }
+ }
+}
+#endif
\ No newline at end of file