-Code reformat

This commit is contained in:
James Newton-King
2013-10-20 15:08:39 +13:00
parent d03963016e
commit bcd6982419
466 changed files with 71645 additions and 71598 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{620042D9-2753-48F5-BEDE-3905248781D2}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{620042D9-2753-48F5-BEDE-3905248781D2}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
Lib\NUnit\DotNet\nunit.framework.dll = Lib\NUnit\DotNet\nunit.framework.dll Lib\NUnit\DotNet\nunit.framework.dll = Lib\NUnit\DotNet\nunit.framework.dll
@@ -47,6 +47,7 @@ using System.Globalization;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Bson namespace Newtonsoft.Json.Tests.Bson
@@ -35,6 +35,7 @@ using System.Text;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -28,6 +28,7 @@ using System.Collections.Generic;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -169,7 +169,6 @@ namespace Newtonsoft.Json.Tests.Converters
}", json); }", json);
Assert.IsNotNull(deserializedDs); Assert.IsNotNull(deserializedDs);
} }
[Test] [Test]
@@ -455,4 +454,5 @@ namespace Newtonsoft.Json.Tests.Converters
} }
} }
} }
#endif #endif
@@ -303,4 +303,5 @@ namespace Newtonsoft.Json.Tests.Converters
} }
} }
} }
#endif #endif
@@ -183,7 +183,6 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(null, c.Expando); Assert.AreEqual(null, c.Expando);
} }
} }
} }
@@ -273,7 +273,6 @@ namespace Newtonsoft.Json.Tests.Converters
// } // }
Console.WriteLine(jsonText); Console.WriteLine(jsonText);
} }
} }
} }
@@ -220,6 +220,7 @@ namespace Newtonsoft.Json.Tests.Converters
{ {
public object Object1 { get; set; } public object Object1 { get; set; }
public object Object2 { get; set; } public object Object2 { get; set; }
[JsonConverter(typeof(DateIntConverter))] [JsonConverter(typeof(DateIntConverter))]
public object ObjectNotHandled { get; set; } public object ObjectNotHandled { get; set; }
} }
@@ -23,6 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if NETFX_CORE #if NETFX_CORE
using System; using System;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
@@ -28,6 +28,7 @@ using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -43,6 +44,7 @@ namespace Newtonsoft.Json.Tests.Converters
{ {
[JsonProperty("_id")] [JsonProperty("_id")]
public BsonObjectId Id { get; set; } public BsonObjectId Id { get; set; }
[JsonProperty("test")] [JsonProperty("test")]
public string Test { get; set; } public string Test { get; set; }
} }
@@ -27,6 +27,7 @@ using System;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -39,10 +40,10 @@ namespace Newtonsoft.Json.Tests.Converters
{ {
public VersionClass(string version1, string version2) public VersionClass(string version1, string version2)
{ {
this.StringProperty1 = "StringProperty1"; StringProperty1 = "StringProperty1";
this.Version1 = new Version(version1); Version1 = new Version(version1);
this.Version2 = new Version(version2); Version2 = new Version(version2);
this.StringProperty2 = "StringProperty2"; StringProperty2 = "StringProperty2";
} }
public VersionClass() public VersionClass()
@@ -43,6 +43,7 @@ using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
#if !NET20 #if !NET20
using System.Xml.Linq; using System.Xml.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Converters namespace Newtonsoft.Json.Tests.Converters
@@ -524,10 +525,7 @@ namespace Newtonsoft.Json.Tests.Converters
{ {
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"XmlNodeConverter can only convert JSON that begins with an object.", "XmlNodeConverter can only convert JSON that begins with an object.",
() => () => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"[1]"); });
{
XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"[1]");
});
} }
[Test] [Test]
@@ -535,10 +533,7 @@ namespace Newtonsoft.Json.Tests.Converters
{ {
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.", "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.",
() => () => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"{Prop1:1,Prop2:2}"); });
{
XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"{Prop1:1,Prop2:2}");
});
} }
[Test] [Test]
@@ -656,10 +651,7 @@ namespace Newtonsoft.Json.Tests.Converters
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.", "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.",
() => () => { JsonConvert.DeserializeXmlNode(json); });
{
JsonConvert.DeserializeXmlNode(json);
});
} }
#if !NET20 #if !NET20
@@ -670,10 +662,7 @@ namespace Newtonsoft.Json.Tests.Converters
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.", "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.",
() => () => { JsonConvert.DeserializeXNode(json); });
{
JsonConvert.DeserializeXNode(json);
});
} }
#endif #endif
@@ -1136,10 +1125,7 @@ namespace Newtonsoft.Json.Tests.Converters
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"XmlNodeConverter cannot convert JSON with an empty property name to XML.", "XmlNodeConverter cannot convert JSON with an empty property name to XML.",
() => () => { DeserializeXmlNode(json); });
{
DeserializeXmlNode(json);
});
} }
[Test] [Test]
@@ -1925,4 +1911,5 @@ namespace Newtonsoft.Json.Tests.Converters
#endif #endif
} }
} }
#endif #endif
@@ -170,8 +170,8 @@ namespace Newtonsoft.Json.Tests.Documentation
""Name"": ""Mike Manager"" ""Name"": ""Mike Manager""
} }
]", json); ]", json);
}
}
}
}
}
}
#endif #endif
@@ -177,7 +177,7 @@ namespace Newtonsoft.Json.Tests.Documentation
//} //}
#endregion #endregion
} }
}
}
}
}
#endif #endif
@@ -181,4 +181,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -319,7 +319,8 @@ namespace Newtonsoft.Json.Tests.Documentation
var categories = var categories =
from c in rss["channel"]["item"].Children()["category"].Values<string>() from c in rss["channel"]["item"].Children()["category"].Values<string>()
group c by c into g group c by c
into g
orderby g.Count() descending orderby g.Count() descending
select new { Category = g.Key, Count = g.Count() }; select new { Category = g.Key, Count = g.Count() };
@@ -457,4 +458,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -218,4 +218,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -147,4 +147,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -54,7 +54,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
var categories = var categories =
from c in rss["channel"]["item"].Children()["category"].Values<string>() from c in rss["channel"]["item"].Children()["category"].Values<string>()
group c by c into g group c by c
into g
orderby g.Count() descending orderby g.Count() descending
select new { Category = g.Key, Count = g.Count() }; select new { Category = g.Key, Count = g.Count() };
@@ -12,6 +12,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
public class DynamicContractResolver : DefaultContractResolver public class DynamicContractResolver : DefaultContractResolver
{ {
private readonly char _startingWithChar; private readonly char _startingWithChar;
public DynamicContractResolver(char startingWithChar) public DynamicContractResolver(char startingWithChar)
{ {
_startingWithChar = startingWithChar; _startingWithChar = startingWithChar;
@@ -18,6 +18,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
[DataMember] [DataMember]
public string Name { get; set; } public string Name { get; set; }
[DataMember] [DataMember]
public int Size { get; set; } public int Size { get; set; }
} }
@@ -16,6 +16,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
public string Name { get; set; } public string Name { get; set; }
public int Age { get; set; } public int Age { get; set; }
public List<string> Roles public List<string> Roles
{ {
get get
@@ -27,6 +28,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
} }
set { _roles = value; } set { _roles = value; }
} }
public string Title { get; set; } public string Title { get; set; }
[OnError] [OnError]
@@ -17,6 +17,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
[JsonProperty] [JsonProperty]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty] [JsonProperty]
public int Size { get; set; } public int Size { get; set; }
} }
@@ -15,6 +15,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
// appear last // appear last
[JsonProperty(Order = 1)] [JsonProperty(Order = 1)]
public bool Deleted { get; set; } public bool Deleted { get; set; }
[JsonProperty(Order = 2)] [JsonProperty(Order = 2)]
public DateTime DeletedDate { get; set; } public DateTime DeletedDate { get; set; }
@@ -12,6 +12,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{ {
public string FullName { get; set; } public string FullName { get; set; }
public string EmailAddress { get; set; } public string EmailAddress { get; set; }
[JsonIgnore] [JsonIgnore]
public string PasswordHash { get; set; } public string PasswordHash { get; set; }
} }
@@ -271,6 +271,7 @@ namespace Newtonsoft.Json.Tests.Documentation
public string Name { get; set; } public string Name { get; set; }
public int Age { get; set; } public int Age { get; set; }
public List<string> Roles public List<string> Roles
{ {
get get
@@ -282,6 +283,7 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
set { _roles = value; } set { _roles = value; }
} }
public string Title { get; set; } public string Title { get; set; }
[OnError] [OnError]
@@ -624,6 +626,7 @@ namespace Newtonsoft.Json.Tests.Documentation
// included in JSON // included in JSON
[DataMember] [DataMember]
public string Name { get; set; } public string Name { get; set; }
[DataMember] [DataMember]
public decimal SalePrice { get; set; } public decimal SalePrice { get; set; }
@@ -692,6 +695,7 @@ namespace Newtonsoft.Json.Tests.Documentation
// customize default values // customize default values
[DefaultValue(30)] [DefaultValue(30)]
public int FollowUpDays { get; set; } public int FollowUpDays { get; set; }
[DefaultValue("")] [DefaultValue("")]
public string FollowUpEmailAddress { get; set; } public string FollowUpEmailAddress { get; set; }
} }
@@ -738,6 +742,7 @@ namespace Newtonsoft.Json.Tests.Documentation
public class DynamicContractResolver : DefaultContractResolver public class DynamicContractResolver : DefaultContractResolver
{ {
private readonly char _startingWithChar; private readonly char _startingWithChar;
public DynamicContractResolver(char startingWithChar) public DynamicContractResolver(char startingWithChar)
{ {
_startingWithChar = startingWithChar; _startingWithChar = startingWithChar;
@@ -908,4 +913,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -171,4 +171,5 @@ namespace Newtonsoft.Json.Tests.Documentation
} }
} }
} }
#endif #endif
@@ -27,6 +27,7 @@ using System;
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -25,6 +25,7 @@
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
+2 -4
View File
@@ -40,6 +40,7 @@ using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -405,10 +406,7 @@ now brown cow?", '"', true);
public void ToStringInvalid() public void ToStringInvalid()
{ {
ExceptionAssert.Throws<ArgumentException>("Unsupported type: System.Version. Use the JsonSerializer class to get the object's JSON representation.", ExceptionAssert.Throws<ArgumentException>("Unsupported type: System.Version. Use the JsonSerializer class to get the object's JSON representation.",
() => () => { JsonConvert.ToString(new Version(1, 0)); });
{
JsonConvert.ToString(new Version(1, 0));
});
} }
[Test] [Test]
+41 -138
View File
@@ -67,10 +67,7 @@ namespace Newtonsoft.Json.Tests
Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
ExceptionAssert.Throws<JsonReaderException>("Unexpected content while parsing JSON. Path 'u', line 1, position 27.", ExceptionAssert.Throws<JsonReaderException>("Unexpected content while parsing JSON. Path 'u', line 1, position 27.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -407,10 +404,7 @@ Nice froob armor.. but ugleh!
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Additional text encountered after finished reading JSON content: c. Path '', line 5, position 2.", "Additional text encountered after finished reading JSON content: c. Path '', line 5, position 2.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -661,10 +655,7 @@ Nice froob armor.. but ugleh!
ExceptionAssert.Throws<ArgumentNullException>( ExceptionAssert.Throws<ArgumentNullException>(
@"Value cannot be null. @"Value cannot be null.
Parameter name: reader", Parameter name: reader",
() => () => { new JsonTextReader(null); });
{
new JsonTextReader(null);
});
} }
[Test] [Test]
@@ -674,10 +665,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unterminated string. Expected delimiter: '. Path '', line 1, position 3.", "Unterminated string. Expected delimiter: '. Path '', line 1, position 3.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -935,10 +923,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end while parsing unicode character. Path '', line 1, position 4.", "Unexpected end while parsing unicode character. Path '', line 1, position 4.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -948,10 +933,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unterminated string. Expected delimiter: '. Path '', line 1, position 3.", "Unterminated string. Expected delimiter: '. Path '', line 1, position 3.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -961,10 +943,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading bytes. Unexpected token: Boolean. Path '', line 1, position 4.", "Error reading bytes. Unexpected token: Boolean. Path '', line 1, position 4.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
[Test] [Test]
@@ -977,10 +956,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unterminated string. Expected delimiter: '. Path '', line 1, position 17.", "Unterminated string. Expected delimiter: '. Path '', line 1, position 17.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
[Test] [Test]
@@ -1001,10 +977,7 @@ Parameter name: reader",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end while parsing unquoted property name. Path '', line 1, position 4.", "Unexpected end while parsing unquoted property name. Path '', line 1, position 4.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -1230,7 +1203,6 @@ bye", reader.Value);
JsonTextReader reader = new JsonTextReader(new StringReader(json)); JsonTextReader reader = new JsonTextReader(new StringReader(json));
while (reader.Read()) while (reader.Read())
{ {
} }
} }
@@ -1526,10 +1498,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
@"Invalid character after parsing property name. Expected ':' but got: "". Path 'A', line 3, position 9.", @"Invalid character after parsing property name. Expected ':' but got: "". Path 'A', line 3, position 9.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -1641,10 +1610,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected character encountered while parsing value: }. Path '', line 1, position 1.", "Unexpected character encountered while parsing value: }. Path '', line 1, position 1.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -1672,10 +1638,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end when reading bytes. Path '', line 1, position 1.", "Unexpected end when reading bytes. Path '', line 1, position 1.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
#if !NET20 #if !NET20
@@ -1696,10 +1659,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading decimal. Unexpected token: StartConstructor. Path '', line 1, position 9.", "Error reading decimal. Unexpected token: StartConstructor. Path '', line 1, position 9.",
() => () => { reader.ReadAsDecimal(); });
{
reader.ReadAsDecimal();
});
} }
[Test] [Test]
@@ -1709,10 +1669,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading bytes. Unexpected token: StartConstructor. Path '', line 1, position 9.", "Error reading bytes. Unexpected token: StartConstructor. Path '', line 1, position 9.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
#if !NET20 #if !NET20
@@ -1723,10 +1680,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading date. Unexpected token: StartConstructor. Path '', line 1, position 9.", "Error reading date. Unexpected token: StartConstructor. Path '', line 1, position 9.",
() => () => { reader.ReadAsDateTimeOffset(); });
{
reader.ReadAsDateTimeOffset();
});
} }
#endif #endif
@@ -1748,10 +1702,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end when reading bytes. Path '[0]', line 1, position 2.", "Unexpected end when reading bytes. Path '[0]', line 1, position 2.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
[Test] [Test]
@@ -1761,10 +1712,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected token when reading bytes: Float. Path '[0]', line 1, position 4.", "Unexpected token when reading bytes: Float. Path '[0]', line 1, position 4.",
() => () => { reader.ReadAsBytes(); });
{
reader.ReadAsBytes();
});
} }
[Test] [Test]
@@ -1875,10 +1823,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Could not convert string to DateTimeOffset: blablahbla. Path 'Offset', line 1, position 22.", "Could not convert string to DateTimeOffset: blablahbla. Path 'Offset', line 1, position 22.",
() => () => { reader.ReadAsDateTimeOffset(); });
{
reader.ReadAsDateTimeOffset();
});
} }
[Test] [Test]
@@ -2032,10 +1977,7 @@ bye", reader.Value);
ExceptionAssert.Throws<FormatException>( ExceptionAssert.Throws<FormatException>(
"Input string was not in a correct format.", "Input string was not in a correct format.",
() => () => { reader.ReadAsInt32(); });
{
reader.ReadAsInt32();
});
} }
[Test] [Test]
@@ -2045,10 +1987,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error parsing null value. Path '', line 0, position 0.", "Error parsing null value. Path '', line 0, position 0.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2058,10 +1997,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error parsing null value. Path '', line 0, position 0.", "Error parsing null value. Path '', line 0, position 0.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2071,10 +2007,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error parsing null value. Path '', line 1, position 4.", "Error parsing null value. Path '', line 1, position 4.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2084,10 +2017,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end while parsing comment. Path '', line 1, position 6.", "Unexpected end while parsing comment. Path '', line 1, position 6.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2097,10 +2027,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error parsing comment. Expected: *, got s. Path '', line 1, position 1.", "Error parsing comment. Expected: *, got s. Path '', line 1, position 1.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2286,10 +2213,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end while parsing constructor. Path '', line 1, position 7.", "Unexpected end while parsing constructor. Path '', line 1, position 7.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2300,10 +2224,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected character while parsing constructor: !. Path '', line 1, position 9.", "Unexpected character while parsing constructor: !. Path '', line 1, position 9.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2351,10 +2272,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error parsing boolean value. Path '', line 1, position 4.", "Error parsing boolean value. Path '', line 1, position 4.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2378,10 +2296,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected character while parsing constructor: ,. Path '', line 1, position 8.", "Unexpected character while parsing constructor: ,. Path '', line 1, position 8.",
() => () => { Assert.IsTrue(reader.Read()); });
{
Assert.IsTrue(reader.Read());
});
} }
[Test] [Test]
@@ -2544,10 +2459,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Additional text encountered after finished reading JSON content: }. Path '', line 1, position 2.", "Additional text encountered after finished reading JSON content: }. Path '', line 1, position 2.",
() => () => { reader.Read(); });
{
reader.Read();
});
} }
[Test] [Test]
@@ -2632,10 +2544,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"The reader's MaxDepth of 1 has been exceeded. Path '[0]', line 1, position 2.", "The reader's MaxDepth of 1 has been exceeded. Path '[0]', line 1, position 2.",
() => () => { Assert.IsTrue(reader.Read()); });
{
Assert.IsTrue(reader.Read());
});
} }
[Test] [Test]
@@ -2653,10 +2562,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"The reader's MaxDepth of 1 has been exceeded. Path '[0]', line 1, position 2.", "The reader's MaxDepth of 1 has been exceeded. Path '[0]', line 1, position 2.",
() => () => { Assert.IsTrue(reader.Read()); });
{
Assert.IsTrue(reader.Read());
});
Assert.AreEqual(1, reader.Depth); Assert.AreEqual(1, reader.Depth);
Assert.IsTrue(reader.Read()); Assert.IsTrue(reader.Read());
@@ -2676,10 +2582,7 @@ bye", reader.Value);
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"The reader's MaxDepth of 1 has been exceeded. Path '[1]', line 1, position 9.", "The reader's MaxDepth of 1 has been exceeded. Path '[1]', line 1, position 9.",
() => () => { Assert.IsTrue(reader.Read()); });
{
Assert.IsTrue(reader.Read());
});
Assert.AreEqual(1, reader.Depth); Assert.AreEqual(1, reader.Depth);
Assert.IsTrue(reader.Read()); Assert.IsTrue(reader.Read());
@@ -2928,14 +2831,14 @@ bye", reader.Value);
public class SlowStream : Stream public class SlowStream : Stream
{ {
byte[] bytes; private byte[] bytes;
int totalBytesRead; private int totalBytesRead;
int bytesPerRead; private int bytesPerRead;
public SlowStream(byte[] content, int bytesPerRead) public SlowStream(byte[] content, int bytesPerRead)
{ {
this.bytes = content; bytes = content;
this.totalBytesRead = 0; totalBytesRead = 0;
this.bytesPerRead = bytesPerRead; this.bytesPerRead = bytesPerRead;
} }
@@ -2976,14 +2879,14 @@ bye", reader.Value);
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
{ {
int toReturn = Math.Min(count, this.bytesPerRead); int toReturn = Math.Min(count, bytesPerRead);
toReturn = Math.Min(toReturn, this.bytes.Length - this.totalBytesRead); toReturn = Math.Min(toReturn, bytes.Length - totalBytesRead);
if (toReturn > 0) if (toReturn > 0)
{ {
Array.Copy(this.bytes, this.totalBytesRead, buffer, offset, toReturn); Array.Copy(bytes, totalBytesRead, buffer, offset, toReturn);
} }
this.totalBytesRead += toReturn; totalBytesRead += toReturn;
return toReturn; return toReturn;
} }
@@ -1578,10 +1578,7 @@ namespace Newtonsoft.Json.Tests
IList<ValidationEventArgs> validationEventArgs = new List<ValidationEventArgs>(); IList<ValidationEventArgs> validationEventArgs = new List<ValidationEventArgs>();
JsonValidatingReader reader = new JsonValidatingReader(new JsonTextReader(new StringReader(json))); JsonValidatingReader reader = new JsonValidatingReader(new JsonTextReader(new StringReader(json)));
reader.ValidationEventHandler += (sender, args) => reader.ValidationEventHandler += (sender, args) => { validationEventArgs.Add(args); };
{
validationEventArgs.Add(args);
};
reader.Schema = JsonSchema.Parse(schema); reader.Schema = JsonSchema.Parse(schema);
while (reader.Read()) while (reader.Read())
@@ -72,4 +72,5 @@ namespace Newtonsoft.Json.Tests.Linq.ComponentModel
} }
} }
} }
#endif #endif
@@ -84,4 +84,5 @@ namespace Newtonsoft.Json.Tests.Linq.ComponentModel
} }
} }
} }
#endif #endif
@@ -846,4 +846,5 @@ namespace Newtonsoft.Json.Tests.Linq
} }
} }
} }
#endif #endif
+12 -45
View File
@@ -38,6 +38,7 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
@@ -119,7 +120,6 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(3, (int)a[3]); Assert.AreEqual(3, (int)a[3]);
Assert.AreEqual(null, a[4]); Assert.AreEqual(null, a[4]);
} }
[Test] [Test]
@@ -130,10 +130,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<ArgumentNullException>( ExceptionAssert.Throws<ArgumentNullException>(
@"Value cannot be null. @"Value cannot be null.
Parameter name: array", Parameter name: array",
() => () => { ((ICollection<JToken>)j).CopyTo(null, 0); });
{
((ICollection<JToken>) j).CopyTo(null, 0);
});
} }
[Test] [Test]
@@ -144,10 +141,7 @@ Parameter name: array",
ExceptionAssert.Throws<ArgumentOutOfRangeException>( ExceptionAssert.Throws<ArgumentOutOfRangeException>(
@"arrayIndex is less than 0. @"arrayIndex is less than 0.
Parameter name: arrayIndex", Parameter name: arrayIndex",
() => () => { ((ICollection<JToken>)j).CopyTo(new JToken[1], -1); });
{
((ICollection<JToken>) j).CopyTo(new JToken[1], -1);
});
} }
[Test] [Test]
@@ -157,10 +151,7 @@ Parameter name: arrayIndex",
ExceptionAssert.Throws<ArgumentException>( ExceptionAssert.Throws<ArgumentException>(
@"arrayIndex is equal to or greater than the length of array.", @"arrayIndex is equal to or greater than the length of array.",
() => () => { ((ICollection<JToken>)j).CopyTo(new JToken[1], 1); });
{
((ICollection<JToken>) j).CopyTo(new JToken[1], 1);
});
} }
[Test] [Test]
@@ -173,10 +164,7 @@ Parameter name: arrayIndex",
ExceptionAssert.Throws<ArgumentException>( ExceptionAssert.Throws<ArgumentException>(
@"The number of elements in the source JObject is greater than the available space from arrayIndex to the end of the destination array.", @"The number of elements in the source JObject is greater than the available space from arrayIndex to the end of the destination array.",
() => () => { ((ICollection<JToken>)j).CopyTo(new JToken[3], 1); });
{
((ICollection<JToken>)j).CopyTo(new JToken[3], 1);
});
} }
[Test] [Test]
@@ -255,10 +243,7 @@ Parameter name: arrayIndex",
ExceptionAssert.Throws<ArgumentOutOfRangeException>( ExceptionAssert.Throws<ArgumentOutOfRangeException>(
@"Index is equal to or greater than Count. @"Index is equal to or greater than Count.
Parameter name: index", Parameter name: index",
() => () => { j.RemoveAt(0); });
{
j.RemoveAt(0);
});
} }
[Test] [Test]
@@ -269,10 +254,7 @@ Parameter name: index",
ExceptionAssert.Throws<ArgumentOutOfRangeException>( ExceptionAssert.Throws<ArgumentOutOfRangeException>(
@"Index is less than 0. @"Index is less than 0.
Parameter name: index", Parameter name: index",
() => () => { j.RemoveAt(-1); });
{
j.RemoveAt(-1);
});
} }
[Test] [Test]
@@ -353,10 +335,7 @@ Parameter name: index",
ExceptionAssert.Throws<ArgumentOutOfRangeException>( ExceptionAssert.Throws<ArgumentOutOfRangeException>(
@"Index was out of range. Must be non-negative and less than the size of the collection. @"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index", Parameter name: index",
() => () => { j.Insert(-1, new JValue(1)); });
{
j.Insert(-1, new JValue(1));
});
} }
[Test] [Test]
@@ -367,10 +346,7 @@ Parameter name: index",
ExceptionAssert.Throws<ArgumentOutOfRangeException>( ExceptionAssert.Throws<ArgumentOutOfRangeException>(
@"Index must be within the bounds of the List. @"Index must be within the bounds of the List.
Parameter name: index", Parameter name: index",
() => () => { j.Insert(2, new JValue(1)); });
{
j.Insert(2, new JValue(1));
});
} }
[Test] [Test]
@@ -402,10 +378,7 @@ Parameter name: index",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.", "Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.",
() => () => { JArray.Parse(json); });
{
JArray.Parse(json);
});
} }
public class ListItemFields public class ListItemFields
@@ -547,10 +520,7 @@ Parameter name: index",
{ {
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Unexpected end of content while loading JArray. Path '[0]', line 1, position 2.", "Unexpected end of content while loading JArray. Path '[0]', line 1, position 2.",
() => () => { JArray.Parse("[1"); });
{
JArray.Parse("[1");
});
} }
[Test] [Test]
@@ -576,10 +546,7 @@ Parameter name: index",
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Additional text encountered after finished reading JSON content: ,. Path '', line 5, position 2.", "Additional text encountered after finished reading JSON content: ,. Path '', line 5, position 2.",
() => () => { JArray.Parse(json); });
{
JArray.Parse(json);
});
} }
[Test] [Test]
@@ -38,6 +38,7 @@ using System.IO;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
@@ -442,13 +442,10 @@ Parameter name: arrayIndex",
{ {
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Invalid property identifier character: ]. Path 'name', line 3, position 5.", "Invalid property identifier character: ]. Path 'name', line 3, position 5.",
() => () => { JObject.Parse(@"{
{
JObject.Parse(@"{
""name"": ""James"", ""name"": ""James"",
]!#$THIS IS: BAD JSON![{}}}}] ]!#$THIS IS: BAD JSON![{}}}}]
}"); }"); });
});
} }
[Test] [Test]
@@ -1637,10 +1634,7 @@ Parameter name: arrayIndex",
public void ParseIncomplete() public void ParseIncomplete()
{ {
ExceptionAssert.Throws<Exception>("Unexpected end of content while loading JObject. Path 'foo', line 1, position 6.", ExceptionAssert.Throws<Exception>("Unexpected end of content while loading JObject. Path 'foo', line 1, position 6.",
() => () => { JObject.Parse("{ foo:"); });
{
JObject.Parse("{ foo:");
});
} }
[Test] [Test]
+11 -40
View File
@@ -37,6 +37,7 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
@@ -88,10 +89,7 @@ namespace Newtonsoft.Json.Tests.Linq
{ {
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
@"Unexpected character while parsing path indexer: [", @"Unexpected character while parsing path indexer: [",
() => () => { new JPath("Blah[[0]].Two.Three[1].Four"); });
{
new JPath("Blah[[0]].Two.Three[1].Four");
});
} }
[Test] [Test]
@@ -99,10 +97,7 @@ namespace Newtonsoft.Json.Tests.Linq
{ {
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
@"Path ended with open indexer. Expected ]", @"Path ended with open indexer. Expected ]",
() => () => { new JPath("Blah[0"); });
{
new JPath("Blah[0");
});
} }
[Test] [Test]
@@ -131,10 +126,7 @@ namespace Newtonsoft.Json.Tests.Linq
{ {
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Empty path indexer.", "Empty path indexer.",
() => () => { new JPath("[]"); });
{
new JPath("[]");
});
} }
[Test] [Test]
@@ -142,10 +134,7 @@ namespace Newtonsoft.Json.Tests.Linq
{ {
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Unexpected character while parsing path: ]", "Unexpected character while parsing path: ]",
() => () => { new JPath("]"); });
{
new JPath("]");
});
} }
[Test] [Test]
@@ -164,10 +153,7 @@ namespace Newtonsoft.Json.Tests.Linq
{ {
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Unexpected character following indexer: B", "Unexpected character following indexer: B",
() => () => { new JPath("[1]Blah"); });
{
new JPath("[1]Blah");
});
} }
[Test] [Test]
@@ -210,10 +196,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
@"Index 1 not valid on JObject.", @"Index 1 not valid on JObject.",
() => () => { o.SelectToken("[1]", true); });
{
o.SelectToken("[1]", true);
});
} }
[Test] [Test]
@@ -232,10 +215,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
@"Property 'BlahBlah' not valid on JArray.", @"Property 'BlahBlah' not valid on JArray.",
() => () => { a.SelectToken("BlahBlah", true); });
{
a.SelectToken("BlahBlah", true);
});
} }
[Test] [Test]
@@ -245,10 +225,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
@"Index 1 outside the bounds of JConstructor.", @"Index 1 outside the bounds of JConstructor.",
() => () => { c.SelectToken("[1]", true); });
{
c.SelectToken("[1]", true);
});
} }
[Test] [Test]
@@ -259,10 +236,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Property 'Missing' does not exist on JObject.", "Property 'Missing' does not exist on JObject.",
() => () => { o.SelectToken("Missing", true); });
{
o.SelectToken("Missing", true);
});
} }
[Test] [Test]
@@ -281,10 +255,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Index 1000 outside the bounds of JArray.", "Index 1000 outside the bounds of JArray.",
() => () => { a.SelectToken("[1000].Ha", true); });
{
a.SelectToken("[1000].Ha", true);
});
} }
[Test] [Test]
@@ -96,10 +96,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Cannot add or remove items from Newtonsoft.Json.Linq.JProperty.", "Cannot add or remove items from Newtonsoft.Json.Linq.JProperty.",
() => () => { l.Clear(); });
{
l.Clear();
});
} }
[Test] [Test]
@@ -110,10 +107,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Newtonsoft.Json.Linq.JProperty cannot have multiple values.", "Newtonsoft.Json.Linq.JProperty cannot have multiple values.",
() => () => { l.Add(null); });
{
l.Add(null);
});
} }
[Test] [Test]
@@ -124,10 +118,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Cannot add or remove items from Newtonsoft.Json.Linq.JProperty.", "Cannot add or remove items from Newtonsoft.Json.Linq.JProperty.",
() => () => { l.Remove(p.Value); });
{
l.Remove(p.Value);
});
} }
[Test] [Test]
@@ -176,10 +167,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonException>( ExceptionAssert.Throws<JsonException>(
"Newtonsoft.Json.Linq.JProperty cannot have multiple values.", "Newtonsoft.Json.Linq.JProperty cannot have multiple values.",
() => () => { t.Add(1); });
{
t.Add(1);
});
} }
} }
} }
@@ -139,10 +139,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Could not convert string to DateTimeOffset: blablahbla. Path 'Offset', line 1, position 22.", "Could not convert string to DateTimeOffset: blablahbla. Path 'Offset', line 1, position 22.",
() => () => { reader.ReadAsDateTimeOffset(); });
{
reader.ReadAsDateTimeOffset();
});
} }
[Test] [Test]
@@ -162,10 +159,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading date. Unexpected token: Boolean. Path 'Offset', line 1, position 14.", "Error reading date. Unexpected token: Boolean. Path 'Offset', line 1, position 14.",
() => () => { reader.ReadAsDateTimeOffset(); });
{
reader.ReadAsDateTimeOffset();
});
} }
[Test] [Test]
@@ -497,10 +491,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Could not convert string to integer: hi. Path 'Name', line 1, position 12.", "Could not convert string to integer: hi. Path 'Name', line 1, position 12.",
() => () => { reader.ReadAsInt32(); });
{
reader.ReadAsInt32();
});
} }
[Test] [Test]
@@ -520,10 +511,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading integer. Unexpected token: Boolean. Path 'Name', line 1, position 12.", "Error reading integer. Unexpected token: Boolean. Path 'Name', line 1, position 12.",
() => () => { reader.ReadAsInt32(); });
{
reader.ReadAsInt32();
});
} }
[Test] [Test]
@@ -564,10 +552,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Could not convert string to decimal: blah. Path 'Name', line 1, position 14.", "Could not convert string to decimal: blah. Path 'Name', line 1, position 14.",
() => () => { reader.ReadAsDecimal(); });
{
reader.ReadAsDecimal();
});
} }
[Test] [Test]
@@ -587,10 +572,7 @@ namespace Newtonsoft.Json.Tests.Linq
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
"Error reading decimal. Unexpected token: Boolean. Path 'Name', line 1, position 12.", "Error reading decimal. Unexpected token: Boolean. Path 'Name', line 1, position 12.",
() => () => { reader.ReadAsDecimal(); });
{
reader.ReadAsDecimal();
});
} }
[Test] [Test]
@@ -44,6 +44,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#endif #endif
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
@@ -43,6 +43,7 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Linq namespace Newtonsoft.Json.Tests.Linq
@@ -483,7 +483,8 @@ keyword such as type of business.""
var categories = var categories =
from c in rss["channel"]["item"].Children()["category"].Values<string>() from c in rss["channel"]["item"].Children()["category"].Values<string>()
group c by c into g group c by c
into g
orderby g.Count() descending orderby g.Count() descending
select new { Category = g.Key, Count = g.Count() }; select new { Category = g.Key, Count = g.Count() };
@@ -612,7 +613,8 @@ keyword such as type of business.""
[Test] [Test]
public void DateTimeOffset() public void DateTimeOffset()
{ {
List<DateTimeOffset> testDates = new List<DateTimeOffset> { List<DateTimeOffset> testDates = new List<DateTimeOffset>
{
new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)), new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)),
new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero), new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero),
new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.FromHours(13)), new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.FromHours(13)),
@@ -679,7 +681,8 @@ keyword such as type of business.""
{ "title", "James Newton-King" }, { "title", "James Newton-King" },
{ "link", "http://james.newtonking.com" }, { "link", "http://james.newtonking.com" },
{ "description", "James Newton-King's blog." }, { "description", "James Newton-King's blog." },
{ "item", {
"item",
(from p in posts (from p in posts
orderby p.Title orderby p.Title
select new select new
@@ -39,6 +39,7 @@ namespace Newtonsoft.Json.Tests.LinqToSql
{ {
[JsonConverter(typeof(GuidByteArrayConverter))] [JsonConverter(typeof(GuidByteArrayConverter))]
public Guid RoleId { get; set; } public Guid RoleId { get; set; }
[JsonIgnore] [JsonIgnore]
public EntitySet<PersonRole> PersonRoles { get; set; } public EntitySet<PersonRole> PersonRoles { get; set; }
} }
+4 -13
View File
@@ -69,7 +69,6 @@ namespace Newtonsoft.Json.Tests
//private const int Iterations = 5000; //private const int Iterations = 5000;
#region Data #region Data
private const string BsonHex = private const string BsonHex =
@"A9-01-00-00-04-73-74-72-69-6E-67-73-00-2B-00-00-00-0A-30-00-02-31-00-19-00-00-00-4D-61-72-6B-75-73-20-65-67-67-65-72-20-5D-3E-3C-5B-2C-20-28-32-6E-64-29-00-0A-32-00-00-03-64-69-63-74-69-6F-6E-61-72-79-00-37-00-00-00-10-56-61-6C-20-26-20-61-73-64-31-00-01-00-00-00-10-56-61-6C-32-20-26-20-61-73-64-31-00-03-00-00-00-10-56-61-6C-33-20-26-20-61-73-64-31-00-04-00-00-00-00-02-4E-61-6D-65-00-05-00-00-00-52-69-63-6B-00-09-4E-6F-77-00-EF-BD-69-EC-25-01-00-00-01-42-69-67-4E-75-6D-62-65-72-00-E7-7B-CC-26-96-C7-1F-42-03-41-64-64-72-65-73-73-31-00-47-00-00-00-02-53-74-72-65-65-74-00-0B-00-00-00-66-66-66-20-53-74-72-65-65-74-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-FF-31-53-26-01-00-00-00-04-41-64-64-72-65-73-73-65-73-00-A2-00-00-00-03-30-00-4B-00-00-00-02-53-74-72-65-65-74-00-0F-00-00-00-1F-61-72-72-61-79-3C-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-73-0C-E7-25-01-00-00-00-03-31-00-4C-00-00-00-02-53-74-72-65-65-74-00-10-00-00-00-61-72-72-61-79-20-32-20-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-17-E6-E1-25-01-00-00-00-00-00"; @"A9-01-00-00-04-73-74-72-69-6E-67-73-00-2B-00-00-00-0A-30-00-02-31-00-19-00-00-00-4D-61-72-6B-75-73-20-65-67-67-65-72-20-5D-3E-3C-5B-2C-20-28-32-6E-64-29-00-0A-32-00-00-03-64-69-63-74-69-6F-6E-61-72-79-00-37-00-00-00-10-56-61-6C-20-26-20-61-73-64-31-00-01-00-00-00-10-56-61-6C-32-20-26-20-61-73-64-31-00-03-00-00-00-10-56-61-6C-33-20-26-20-61-73-64-31-00-04-00-00-00-00-02-4E-61-6D-65-00-05-00-00-00-52-69-63-6B-00-09-4E-6F-77-00-EF-BD-69-EC-25-01-00-00-01-42-69-67-4E-75-6D-62-65-72-00-E7-7B-CC-26-96-C7-1F-42-03-41-64-64-72-65-73-73-31-00-47-00-00-00-02-53-74-72-65-65-74-00-0B-00-00-00-66-66-66-20-53-74-72-65-65-74-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-FF-31-53-26-01-00-00-00-04-41-64-64-72-65-73-73-65-73-00-A2-00-00-00-03-30-00-4B-00-00-00-02-53-74-72-65-65-74-00-0F-00-00-00-1F-61-72-72-61-79-3C-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-73-0C-E7-25-01-00-00-00-03-31-00-4C-00-00-00-02-53-74-72-65-65-74-00-10-00-00-00-61-72-72-61-79-20-32-20-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-17-E6-E1-25-01-00-00-00-00-00";
@@ -100,7 +99,6 @@ namespace Newtonsoft.Json.Tests
DataContractSerializer, DataContractSerializer,
DataContractJsonSerializer DataContractJsonSerializer
} }
#endregion #endregion
[Test] [Test]
@@ -451,7 +449,6 @@ If attributes are not mentioned, default values are used in each case.
} }
#region Serialize #region Serialize
private static readonly byte[] Buffer = new byte[4096]; private static readonly byte[] Buffer = new byte[4096];
public void BenchmarkSerializeMethod(SerializeMethod method, object value) public void BenchmarkSerializeMethod(SerializeMethod method, object value)
@@ -700,11 +697,9 @@ If attributes are not mentioned, default values are used in each case.
//json = BitConverter.ToString(ms.ToArray(), 0, (int)ms.Position); //json = BitConverter.ToString(ms.ToArray(), 0, (int)ms.Position);
return json; return json;
} }
#endregion #endregion
#region Deserialize #region Deserialize
public void BenchmarkDeserializeMethod<T>(SerializeMethod method, object json) public void BenchmarkDeserializeMethod<T>(SerializeMethod method, object json)
{ {
Deserialize<T>(method, json); Deserialize<T>(method, json);
@@ -899,11 +894,8 @@ If attributes are not mentioned, default values are used in each case.
BinaryFormatter formatter = new BinaryFormatter(); BinaryFormatter formatter = new BinaryFormatter();
return (T)formatter.Deserialize(new MemoryStream(bytes)); return (T)formatter.Deserialize(new MemoryStream(bytes));
} }
#endregion #endregion
[Test] [Test]
public void SerializeLargeObject() public void SerializeLargeObject()
{ {
@@ -1045,7 +1037,6 @@ If attributes are not mentioned, default values are used in each case.
} }
#region Classes #region Classes
[Serializable] [Serializable]
[DataContract] [DataContract]
public class TestClass public class TestClass
@@ -1087,7 +1078,6 @@ If attributes are not mentioned, default values are used in each case.
private Address _Address1 = new Address(); private Address _Address1 = new Address();
[DataMember] [DataMember]
public List<Address> Addresses public List<Address> Addresses
{ {
@@ -1097,9 +1087,11 @@ If attributes are not mentioned, default values are used in each case.
private List<Address> _Addresses = new List<Address>(); private List<Address> _Addresses = new List<Address>();
[DataMember] public List<string> strings = new List<string>(); [DataMember]
public List<string> strings = new List<string>();
[DataMember] public Dictionary<string, int> dictionary = new Dictionary<string, int>(); [DataMember]
public Dictionary<string, int> dictionary = new Dictionary<string, int>();
} }
[Serializable] [Serializable]
@@ -1150,7 +1142,6 @@ If attributes are not mentioned, default values are used in each case.
[DataMember] [DataMember]
public int[] Scores { get; set; } public int[] Scores { get; set; }
} }
#endregion #endregion
} }
@@ -46,6 +46,7 @@ using System.Security;
#elif NET40 #elif NET40
[assembly: AssemblyTitle("Json.NET Tests .NET 4.0")] [assembly: AssemblyTitle("Json.NET Tests .NET 4.0")]
#else #else
[assembly: AssemblyTitle("Json.NET Tests")] [assembly: AssemblyTitle("Json.NET Tests")]
#endif #endif
@@ -60,9 +61,11 @@ using System.Security;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0be3d72b-d2ef-409c-985c-d3ede89a25f1")] [assembly: Guid("0be3d72b-d2ef-409c-985c-d3ede89a25f1")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
@@ -74,5 +77,6 @@ using System.Security;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")] [assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("5.0.8.16617")] [assembly: AssemblyFileVersion("5.0.8.16620")]
@@ -38,6 +38,7 @@ using System.IO;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !(SILVERLIGHT || NETFX_CORE) #if !(SILVERLIGHT || NETFX_CORE)
using System.Data; using System.Data;
#endif #endif
namespace Newtonsoft.Json.Tests.Schema namespace Newtonsoft.Json.Tests.Schema
@@ -177,10 +178,7 @@ namespace Newtonsoft.Json.Tests.Schema
List<string> errors = new List<string>(); List<string> errors = new List<string>();
token.Validate(typeSchema, (sender, args) => token.Validate(typeSchema, (sender, args) => { errors.Add(args.Message); });
{
errors.Add(args.Message);
});
if (errors.Count > 0) if (errors.Count > 0)
Assert.Fail("Schema generated for type '{0}' is not valid." + Environment.NewLine + string.Join(Environment.NewLine, errors.ToArray()), typeof(T)); Assert.Fail("Schema generated for type '{0}' is not valid." + Environment.NewLine + string.Join(Environment.NewLine, errors.ToArray()), typeof(T));
@@ -47,6 +47,7 @@ using Extensions=Newtonsoft.Json.Schema.Extensions;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Schema namespace Newtonsoft.Json.Tests.Schema
@@ -26,6 +26,7 @@
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -26,6 +26,7 @@
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -116,6 +117,5 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(node, node.Items[0]); Assert.AreEqual(node, node.Items[0]);
} }
} }
} }
@@ -30,6 +30,7 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -275,7 +276,6 @@ namespace Newtonsoft.Json.Tests.Schema
} }
} }
}", json); }", json);
} }
[Test] [Test]
@@ -77,7 +77,6 @@ namespace Newtonsoft.Json.Tests.Serialization
""BirthDate"": ""2000-11-20T23:55:44Z"", ""BirthDate"": ""2000-11-20T23:55:44Z"",
""LastModified"": ""2000-11-20T23:55:44Z"" ""LastModified"": ""2000-11-20T23:55:44Z""
}", json); }", json);
} }
[Test] [Test]
@@ -27,6 +27,7 @@ using System.Reflection;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -50,6 +50,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public class DynamicContractResolver : DefaultContractResolver public class DynamicContractResolver : DefaultContractResolver
{ {
private readonly char _startingWithChar; private readonly char _startingWithChar;
public DynamicContractResolver(char startingWithChar) public DynamicContractResolver(char startingWithChar)
: base(false) : base(false)
{ {
@@ -195,6 +195,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[JsonProperty(PropertyName = "firstName")] [JsonProperty(PropertyName = "firstName")]
public string Firstname { get; set; } public string Firstname { get; set; }
[JsonProperty(PropertyName = "lastName")] [JsonProperty(PropertyName = "lastName")]
public string Lastname { get; set; } public string Lastname { get; set; }
@@ -360,9 +361,12 @@ namespace Newtonsoft.Json.Tests.Serialization
[DefaultValue(1)] [DefaultValue(1)]
public int IntValue1 { get; set; } public int IntValue1 { get; set; }
public int IntValue2 { get; set; } public int IntValue2 { get; set; }
[DefaultValue(null)] [DefaultValue(null)]
public int IntValue3 { get; set; } public int IntValue3 { get; set; }
public DefaultValueHandlingDeserialize ClassValue { get; set; } public DefaultValueHandlingDeserialize ClassValue { get; set; }
} }
@@ -380,6 +384,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[DefaultValue(1)] [DefaultValue(1)]
public int IntValue1 { get; set; } public int IntValue1 { get; set; }
public int IntValue2 { get; set; } public int IntValue2 { get; set; }
public DefaultValueHandlingDeserialize ClassValue { get; set; } public DefaultValueHandlingDeserialize ClassValue { get; set; }
} }
@@ -407,43 +412,61 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public Guid Guid { get; set; } public Guid Guid { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public TimeSpan TimeSpan { get; set; } public TimeSpan TimeSpan { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DateTime DateTime { get; set; } public DateTime DateTime { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DateTimeOffset DateTimeOffset { get; set; } public DateTimeOffset DateTimeOffset { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public decimal Decimal { get; set; } public decimal Decimal { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public int Integer { get; set; } public int Integer { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public double Double { get; set; } public double Double { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public bool Boolean { get; set; } public bool Boolean { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DefaultStruct Struct { get; set; } public DefaultStruct Struct { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public StringComparison Enum { get; set; } public StringComparison Enum { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public Guid? NullableGuid { get; set; } public Guid? NullableGuid { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public TimeSpan? NullableTimeSpan { get; set; } public TimeSpan? NullableTimeSpan { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DateTime? NullableDateTime { get; set; } public DateTime? NullableDateTime { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DateTimeOffset? NullableDateTimeOffset { get; set; } public DateTimeOffset? NullableDateTimeOffset { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public decimal? NullableDecimal { get; set; } public decimal? NullableDecimal { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public int? NullableInteger { get; set; } public int? NullableInteger { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public double? NullableDouble { get; set; } public double? NullableDouble { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public bool? NullableBoolean { get; set; } public bool? NullableBoolean { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public DefaultStruct? NullableStruct { get; set; } public DefaultStruct? NullableStruct { get; set; }
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]
public StringComparison? NullableEnum { get; set; } public StringComparison? NullableEnum { get; set; }
@@ -39,6 +39,7 @@ using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -335,8 +336,10 @@ namespace Newtonsoft.Json.Tests.Serialization
private readonly Dictionary<string, object> _members; private readonly Dictionary<string, object> _members;
public int Int; public int Int;
[JsonProperty] [JsonProperty]
public bool Explicit; public bool Explicit;
public DynamicChildObject ChildObject { get; set; } public DynamicChildObject ChildObject { get; set; }
internal Dictionary<string, object> Members internal Dictionary<string, object> Members
@@ -395,4 +398,5 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
} }
} }
#endif #endif
@@ -32,6 +32,7 @@ using System.Text;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -318,4 +319,5 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
} }
} }
#endif #endif
@@ -431,4 +431,5 @@ namespace Newtonsoft.Json.Tests.Serialization
#endregion #endregion
} }
} }
#endif #endif
File diff suppressed because it is too large Load Diff
@@ -29,6 +29,7 @@ using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -64,10 +65,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
@"Could not find member 'Price' on object of type 'ProductShort'. Path 'Price', line 4, position 11.", @"Could not find member 'Price' on object of type 'ProductShort'. Path 'Price', line 4, position 11.",
() => () => { ProductShort deserializedProductShort = (ProductShort)JsonConvert.DeserializeObject(output, typeof(ProductShort), new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); });
{
ProductShort deserializedProductShort = (ProductShort)JsonConvert.DeserializeObject(output, typeof(ProductShort), new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error });
});
} }
[Test] [Test]
@@ -132,10 +130,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"Could not find member 'Missing' on object of type 'DoubleClass'. Path 'Missing', line 1, position 11.", "Could not find member 'Missing' on object of type 'DoubleClass'. Path 'Missing', line 1, position 11.",
() => () => { JsonConvert.DeserializeObject<DoubleClass>(json, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); });
{
JsonConvert.DeserializeObject<DoubleClass>(json, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error });
});
} }
[Test] [Test]
@@ -28,6 +28,7 @@ using System.IO;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -29,6 +29,7 @@ using System.IO;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -157,10 +158,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public void PopulateWithBadJson() public void PopulateWithBadJson()
{ {
ExceptionAssert.Throws<JsonSerializationException>("Unexpected initial token 'Integer' when populating object. Expected JSON object or array. Path '', line 1, position 1.", ExceptionAssert.Throws<JsonSerializationException>("Unexpected initial token 'Integer' when populating object. Expected JSON object or array. Path '', line 1, position 1.",
() => () => { JsonConvert.PopulateObject("1", new Person()); });
{
JsonConvert.PopulateObject("1", new Person());
});
} }
} }
} }
@@ -32,6 +32,7 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -106,10 +107,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
"Self referencing loop detected with type '" + classRef + "'. Path '[2][0]'.", "Self referencing loop detected with type '" + classRef + "'. Path '[2][0]'.",
() => () => { JsonConvert.SerializeObject(circularList, Formatting.Indented); });
{
JsonConvert.SerializeObject(circularList, Formatting.Indented);
});
} }
[Test] [Test]
@@ -266,10 +264,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ExceptionAssert.Throws<JsonSerializationException>( ExceptionAssert.Throws<JsonSerializationException>(
@"Self referencing loop detected with type '" + classRef + "'. Path ''.", @"Self referencing loop detected with type '" + classRef + "'. Path ''.",
() => () => { JsonConvert.SerializeObject(circularDictionary, Formatting.Indented); });
{
JsonConvert.SerializeObject(circularDictionary, Formatting.Indented);
});
} }
[Test] [Test]
@@ -759,7 +754,6 @@ namespace Newtonsoft.Json.Tests.Serialization
public class User public class User
{ {
#region properties #region properties
[JsonProperty(Required = Required.Always, PropertyName = "SecretType")] [JsonProperty(Required = Required.Always, PropertyName = "SecretType")]
private string secretType; private string secretType;
@@ -774,27 +768,22 @@ namespace Newtonsoft.Json.Tests.Serialization
[JsonProperty] [JsonProperty]
public User Friend { get; set; } public User Friend { get; set; }
#endregion #endregion
#region constructors #region constructors
public User() public User()
{ {
} }
public User(string login, Type secretType) public User(string login, Type secretType)
: this() : this()
{ {
this.Login = login; Login = login;
this.SecretType = secretType; SecretType = secretType;
} }
#endregion #endregion
#region methods #region methods
public override int GetHashCode() public override int GetHashCode()
{ {
return SecretType.GetHashCode(); return SecretType.GetHashCode();
@@ -804,7 +793,6 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
return string.Format("SecretType: {0}, Login: {1}", secretType, Login); return string.Format("SecretType: {0}, Login: {1}", secretType, Login);
} }
#endregion #endregion
} }
@@ -1113,8 +1101,10 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
public TestComponentSimple Component1 { get; set; } public TestComponentSimple Component1 { get; set; }
public TestComponentSimple Component2 { get; set; } public TestComponentSimple Component2 { get; set; }
[JsonProperty(IsReference = false)] [JsonProperty(IsReference = false)]
public TestComponentSimple ComponentNotReference { get; set; } public TestComponentSimple ComponentNotReference { get; set; }
public string String { get; set; } public string String { get; set; }
public int Integer { get; set; } public int Integer { get; set; }
} }
@@ -654,10 +654,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public void WriteEndOnPropertyState() public void WriteEndOnPropertyState()
{ {
JsonSerializerSettings settings = new JsonSerializerSettings(); JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Error += (obj, args) => settings.Error += (obj, args) => { args.ErrorContext.Handled = true; };
{
args.ErrorContext.Handled = true;
};
var data = new List<ErrorPerson2>() var data = new List<ErrorPerson2>()
{ {
@@ -675,10 +672,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public void WriteEndOnPropertyState2() public void WriteEndOnPropertyState2()
{ {
JsonSerializerSettings settings = new JsonSerializerSettings(); JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Error += (obj, args) => settings.Error += (obj, args) => { args.ErrorContext.Handled = true; };
{
args.ErrorContext.Handled = true;
};
var data = new List<ErrorPerson2> var data = new List<ErrorPerson2>
{ {
@@ -702,10 +696,7 @@ namespace Newtonsoft.Json.Tests.Serialization
MemoryStream stream = new MemoryStream(byteArray); MemoryStream stream = new MemoryStream(byteArray);
JsonTextReader jReader = new JsonTextReader(new StreamReader(stream)); JsonTextReader jReader = new JsonTextReader(new StreamReader(stream));
JsonSerializer s = new JsonSerializer(); JsonSerializer s = new JsonSerializer();
s.Error += (sender, args) => s.Error += (sender, args) => { args.ErrorContext.Handled = true; };
{
args.ErrorContext.Handled = true;
};
ErrorPerson2 obj = s.Deserialize<ErrorPerson2>(jReader); ErrorPerson2 obj = s.Deserialize<ErrorPerson2>(jReader);
Assert.IsNull(obj); Assert.IsNull(obj);
@@ -722,19 +713,15 @@ namespace Newtonsoft.Json.Tests.Serialization
ExceptionAssert.Throws<JsonReaderException>( ExceptionAssert.Throws<JsonReaderException>(
@"Unterminated string. Expected delimiter: "". Path '', line 1, position 3.", @"Unterminated string. Expected delimiter: "". Path '', line 1, position 3.",
() => () => { ErrorTestObject obj = s.Deserialize<ErrorTestObject>(jReader); });
}
}
internal interface IErrorPerson2
{ {
ErrorTestObject obj = s.Deserialize<ErrorTestObject>(jReader);
});
}
} }
interface IErrorPerson2 internal class ErrorPerson2 //:IPerson - oops! Forgot to implement the person interface
{
}
class ErrorPerson2//:IPerson - oops! Forgot to implement the person interface
{ {
public string LastName { get; set; } public string LastName { get; set; }
public string FirstName { get; set; } public string FirstName { get; set; }
@@ -799,8 +786,11 @@ namespace Newtonsoft.Json.Tests.Serialization
[JsonObject] [JsonObject]
public class MyTypeWithRequiredMembers public class MyTypeWithRequiredMembers
{ {
[JsonProperty(Required = Required.AllowNull)] public string Required1; [JsonProperty(Required = Required.AllowNull)]
[JsonProperty(Required = Required.AllowNull)] public string Required2; public string Required1;
[JsonProperty(Required = Required.AllowNull)]
public string Required2;
} }
public class LogMessage public class LogMessage
@@ -338,6 +338,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Debug.Assert(foo.Identifier == 25); Debug.Assert(foo.Identifier == 25);
} }
#endif #endif
public class FooEvent public class FooEvent
{ {
public int Identifier { get; set; } public int Identifier { get; set; }
@@ -345,7 +346,7 @@ namespace Newtonsoft.Json.Tests.Serialization
[OnError] [OnError]
private void OnError(StreamingContext context, ErrorContext error) private void OnError(StreamingContext context, ErrorContext error)
{ {
this.Identifier = 25; Identifier = 25;
// Here we could for example manually copy the // Here we could for example manually copy the
// persisted "Id" value into the renamed "Identifier" // persisted "Id" value into the renamed "Identifier"
@@ -23,6 +23,7 @@ using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests.Serialization namespace Newtonsoft.Json.Tests.Serialization
@@ -996,9 +996,9 @@ namespace Newtonsoft.Json.Tests.Serialization
//Test Json Serialization //Test Json Serialization
//This fails because the JsonSerializer doesn't serialize type names correctly for ISerializable objects //This fails because the JsonSerializer doesn't serialize type names correctly for ISerializable objects
//Type Names should be serialized for All, Auto and Object modes //Type Names should be serialized for All, Auto and Object modes
this.TestJsonSerializationRoundTrip(w, TypeNameHandling.All); TestJsonSerializationRoundTrip(w, TypeNameHandling.All);
this.TestJsonSerializationRoundTrip(w, TypeNameHandling.Auto); TestJsonSerializationRoundTrip(w, TypeNameHandling.Auto);
this.TestJsonSerializationRoundTrip(w, TypeNameHandling.Objects); TestJsonSerializationRoundTrip(w, TypeNameHandling.Objects);
} }
private void TestJsonSerializationRoundTrip(SerializableWrapper e, TypeNameHandling flag) private void TestJsonSerializationRoundTrip(SerializableWrapper e, TypeNameHandling flag)
@@ -1750,10 +1750,7 @@ namespace Newtonsoft.Json.Tests.Serialization
public interface IExample public interface IExample
: ISerializable : ISerializable
{ {
String Name String Name { get; }
{
get;
}
} }
[Serializable] [Serializable]
@@ -1762,17 +1759,17 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
public Example(String name) public Example(String name)
{ {
this.Name = name; Name = name;
} }
protected Example(SerializationInfo info, StreamingContext context) protected Example(SerializationInfo info, StreamingContext context)
{ {
this.Name = info.GetString("name"); Name = info.GetString("name");
} }
public void GetObjectData(SerializationInfo info, StreamingContext context) public void GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.AddValue("name", this.Name); info.AddValue("name", Name);
} }
public String Name { get; set; } public String Name { get; set; }
@@ -1783,7 +1780,7 @@ namespace Newtonsoft.Json.Tests.Serialization
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj is IExample) if (obj is IExample)
{ {
return this.Name.Equals(((IExample)obj).Name); return Name.Equals(((IExample)obj).Name);
} }
else else
{ {
@@ -1850,10 +1847,13 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
public object Object1 { get; set; } public object Object1 { get; set; }
public object Object2 { get; set; } public object Object2 { get; set; }
[JsonProperty(TypeNameHandling = TypeNameHandling.None)] [JsonProperty(TypeNameHandling = TypeNameHandling.None)]
public object ObjectNotHandled { get; set; } public object ObjectNotHandled { get; set; }
public string String { get; set; } public string String { get; set; }
public int Integer { get; set; } public int Integer { get; set; }
} }
} }
#endif #endif
@@ -123,7 +123,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
public SerializableType(string protectedFieldValue) public SerializableType(string protectedFieldValue)
{ {
this.protectedField = protectedFieldValue; protectedField = protectedFieldValue;
} }
public string publicField; public string publicField;
@@ -134,14 +134,8 @@ namespace Newtonsoft.Json.Tests.Serialization
public string PublicProperty public string PublicProperty
{ {
get get { return privateField; }
{ set { privateField = value; }
return privateField;
}
set
{
this.privateField = value;
}
} }
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40) #if !(SILVERLIGHT || NETFX_CORE || PORTABLE || PORTABLE40)
@@ -153,11 +147,11 @@ namespace Newtonsoft.Json.Tests.Serialization
public bool Equals(SerializableType other) public bool Equals(SerializableType other)
{ {
return this.publicField == other.publicField && return publicField == other.publicField &&
this.internalField == other.internalField && internalField == other.internalField &&
this.protectedInternalField == other.protectedInternalField && protectedInternalField == other.protectedInternalField &&
this.protectedField == other.protectedField && protectedField == other.protectedField &&
this.privateField == other.privateField; privateField == other.privateField;
} }
} }
} }
@@ -27,6 +27,7 @@ using System;
using System.Reflection; using System.Reflection;
#if !NETFX_CORE #if !NETFX_CORE
using NUnit.Framework; using NUnit.Framework;
#else #else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -48,6 +48,7 @@ using System.Collections;
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
using System.Linq; using System.Linq;
#endif #endif
namespace Newtonsoft.Json.Tests namespace Newtonsoft.Json.Tests
@@ -29,6 +29,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
[JsonProperty(Required = Required.Always)] [JsonProperty(Required = Required.Always)]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public CircularReferenceClass Child { get; set; } public CircularReferenceClass Child { get; set; }
} }
@@ -30,6 +30,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
[JsonProperty(Required = Required.AllowNull)] [JsonProperty(Required = Required.AllowNull)]
public string Name { get; set; } public string Name { get; set; }
public CircularReferenceWithIdClass Child { get; set; } public CircularReferenceWithIdClass Child { get; set; }
} }
} }
@@ -28,6 +28,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class ClassAndMemberConverterClass public class ClassAndMemberConverterClass
{ {
public ConverterPrecedenceClass DefaultConverter { get; set; } public ConverterPrecedenceClass DefaultConverter { get; set; }
[JsonConverter(typeof(MemberConverterPrecedenceClassConverter))] [JsonConverter(typeof(MemberConverterPrecedenceClassConverter))]
public ConverterPrecedenceClass MemberConverter { get; set; } public ConverterPrecedenceClass MemberConverter { get; set; }
} }
@@ -27,6 +27,7 @@ using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if !NET20 #if !NET20
namespace Newtonsoft.Json.Tests.TestObjects namespace Newtonsoft.Json.Tests.TestObjects
{ {
[DataContract] [DataContract]
@@ -35,6 +36,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
// included in JSON // included in JSON
[DataMember] [DataMember]
public string Name { get; set; } public string Name { get; set; }
[DataMember] [DataMember]
public decimal SalePrice { get; set; } public decimal SalePrice { get; set; }
@@ -45,4 +47,5 @@ namespace Newtonsoft.Json.Tests.TestObjects
public DateTime NextShipmentDate { get; set; } public DateTime NextShipmentDate { get; set; }
} }
} }
#endif #endif
@@ -35,7 +35,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
this.param1 = param1; this.param1 = param1;
this.Param1 = Param1; this.Param1 = Param1;
this.Param2 = param2; Param2 = param2;
} }
} }
} }
@@ -33,6 +33,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
[JsonProperty] [JsonProperty]
public List<Content> Children; public List<Content> Children;
[JsonProperty] [JsonProperty]
public string Text; public string Text;
@@ -27,7 +27,10 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
public class ContentSubClass : ContentBaseClass public class ContentSubClass : ContentBaseClass
{ {
public ContentSubClass() { } public ContentSubClass()
{
}
public ContentSubClass(string EasyIn) public ContentSubClass(string EasyIn)
{ {
SomeString = EasyIn; SomeString = EasyIn;
@@ -41,7 +41,6 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")]
public partial class CustomerDataSet : global::System.Data.DataSet public partial class CustomerDataSet : global::System.Data.DataSet
{ {
private CustomersDataTable tableCustomers; private CustomersDataTable tableCustomers;
private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;
@@ -50,12 +49,12 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomerDataSet() public CustomerDataSet()
{ {
this.BeginInit(); BeginInit();
this.InitClass(); InitClass();
global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler; base.Tables.CollectionChanged += schemaChangedHandler;
base.Relations.CollectionChanged += schemaChangedHandler; base.Relations.CollectionChanged += schemaChangedHandler;
this.EndInit(); EndInit();
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -63,16 +62,16 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected CustomerDataSet(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : protected CustomerDataSet(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) :
base(info, context, false) base(info, context, false)
{ {
if ((this.IsBinarySerialized(info, context) == true)) if ((IsBinarySerialized(info, context) == true))
{ {
this.InitVars(false); InitVars(false);
global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new global::System.ComponentModel.CollectionChangeEventHandler(SchemaChanged);
this.Tables.CollectionChanged += schemaChangedHandler1; Tables.CollectionChanged += schemaChangedHandler1;
this.Relations.CollectionChanged += schemaChangedHandler1; Relations.CollectionChanged += schemaChangedHandler1;
return; return;
} }
string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
if ((this.DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema)) if ((DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema))
{ {
global::System.Data.DataSet ds = new global::System.Data.DataSet(); global::System.Data.DataSet ds = new global::System.Data.DataSet();
ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema)));
@@ -80,23 +79,23 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
base.Tables.Add(new CustomersDataTable(ds.Tables["Customers"])); base.Tables.Add(new CustomersDataTable(ds.Tables["Customers"]));
} }
this.DataSetName = ds.DataSetName; DataSetName = ds.DataSetName;
this.Prefix = ds.Prefix; Prefix = ds.Prefix;
this.Namespace = ds.Namespace; Namespace = ds.Namespace;
this.Locale = ds.Locale; Locale = ds.Locale;
this.CaseSensitive = ds.CaseSensitive; CaseSensitive = ds.CaseSensitive;
this.EnforceConstraints = ds.EnforceConstraints; EnforceConstraints = ds.EnforceConstraints;
this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); Merge(ds, false, global::System.Data.MissingSchemaAction.Add);
this.InitVars(); InitVars();
} }
else else
{ {
this.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema)));
} }
this.GetSerializationData(info, context); GetSerializationData(info, context);
global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler; base.Tables.CollectionChanged += schemaChangedHandler;
this.Relations.CollectionChanged += schemaChangedHandler; Relations.CollectionChanged += schemaChangedHandler;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -105,10 +104,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)]
public CustomersDataTable Customers public CustomersDataTable Customers
{ {
get get { return tableCustomers; }
{
return this.tableCustomers;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -117,14 +113,8 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Visible)] [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Visible)]
public override global::System.Data.SchemaSerializationMode SchemaSerializationMode public override global::System.Data.SchemaSerializationMode SchemaSerializationMode
{ {
get get { return _schemaSerializationMode; }
{ set { _schemaSerializationMode = value; }
return this._schemaSerializationMode;
}
set
{
this._schemaSerializationMode = value;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -132,10 +122,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public new global::System.Data.DataTableCollection Tables public new global::System.Data.DataTableCollection Tables
{ {
get get { return base.Tables; }
{
return base.Tables;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -143,19 +130,16 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public new global::System.Data.DataRelationCollection Relations public new global::System.Data.DataRelationCollection Relations
{ {
get get { return base.Relations; }
{
return base.Relations;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
protected override void InitializeDerivedDataSet() protected override void InitializeDerivedDataSet()
{ {
this.BeginInit(); BeginInit();
this.InitClass(); InitClass();
this.EndInit(); EndInit();
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -164,7 +148,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
CustomerDataSet cln = ((CustomerDataSet)(base.Clone())); CustomerDataSet cln = ((CustomerDataSet)(base.Clone()));
cln.InitVars(); cln.InitVars();
cln.SchemaSerializationMode = this.SchemaSerializationMode; cln.SchemaSerializationMode = SchemaSerializationMode;
return cln; return cln;
} }
@@ -186,28 +170,28 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
protected override void ReadXmlSerializable(global::System.Xml.XmlReader reader) protected override void ReadXmlSerializable(global::System.Xml.XmlReader reader)
{ {
if ((this.DetermineSchemaSerializationMode(reader) == global::System.Data.SchemaSerializationMode.IncludeSchema)) if ((DetermineSchemaSerializationMode(reader) == global::System.Data.SchemaSerializationMode.IncludeSchema))
{ {
this.Reset(); Reset();
global::System.Data.DataSet ds = new global::System.Data.DataSet(); global::System.Data.DataSet ds = new global::System.Data.DataSet();
ds.ReadXml(reader); ds.ReadXml(reader);
if ((ds.Tables["Customers"] != null)) if ((ds.Tables["Customers"] != null))
{ {
base.Tables.Add(new CustomersDataTable(ds.Tables["Customers"])); base.Tables.Add(new CustomersDataTable(ds.Tables["Customers"]));
} }
this.DataSetName = ds.DataSetName; DataSetName = ds.DataSetName;
this.Prefix = ds.Prefix; Prefix = ds.Prefix;
this.Namespace = ds.Namespace; Namespace = ds.Namespace;
this.Locale = ds.Locale; Locale = ds.Locale;
this.CaseSensitive = ds.CaseSensitive; CaseSensitive = ds.CaseSensitive;
this.EnforceConstraints = ds.EnforceConstraints; EnforceConstraints = ds.EnforceConstraints;
this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); Merge(ds, false, global::System.Data.MissingSchemaAction.Add);
this.InitVars(); InitVars();
} }
else else
{ {
this.ReadXml(reader); ReadXml(reader);
this.InitVars(); InitVars();
} }
} }
@@ -216,7 +200,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable()
{ {
global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream();
this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null));
stream.Position = 0; stream.Position = 0;
return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null);
} }
@@ -225,19 +209,19 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
internal void InitVars() internal void InitVars()
{ {
this.InitVars(true); InitVars(true);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
internal void InitVars(bool initTable) internal void InitVars(bool initTable)
{ {
this.tableCustomers = ((CustomersDataTable)(base.Tables["Customers"])); tableCustomers = ((CustomersDataTable)(base.Tables["Customers"]));
if ((initTable == true)) if ((initTable == true))
{ {
if ((this.tableCustomers != null)) if ((tableCustomers != null))
{ {
this.tableCustomers.InitVars(); tableCustomers.InitVars();
} }
} }
} }
@@ -246,12 +230,12 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
private void InitClass() private void InitClass()
{ {
this.DataSetName = "CustomerDataSet"; DataSetName = "CustomerDataSet";
this.Prefix = ""; Prefix = "";
this.EnforceConstraints = true; EnforceConstraints = true;
this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;
this.tableCustomers = new CustomersDataTable(); tableCustomers = new CustomersDataTable();
base.Tables.Add(this.tableCustomers); base.Tables.Add(tableCustomers);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -267,7 +251,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
if ((e.Action == global::System.ComponentModel.CollectionChangeAction.Remove)) if ((e.Action == global::System.ComponentModel.CollectionChangeAction.Remove))
{ {
this.InitVars(); InitVars();
} }
} }
@@ -338,38 +322,37 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")]
public partial class CustomersDataTable : global::System.Data.DataTable, global::System.Collections.IEnumerable public partial class CustomersDataTable : global::System.Data.DataTable, global::System.Collections.IEnumerable
{ {
private global::System.Data.DataColumn columnCustomerID; private global::System.Data.DataColumn columnCustomerID;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersDataTable() public CustomersDataTable()
{ {
this.TableName = "Customers"; TableName = "Customers";
this.BeginInit(); BeginInit();
this.InitClass(); InitClass();
this.EndInit(); EndInit();
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
internal CustomersDataTable(global::System.Data.DataTable table) internal CustomersDataTable(global::System.Data.DataTable table)
{ {
this.TableName = table.TableName; TableName = table.TableName;
if ((table.CaseSensitive != table.DataSet.CaseSensitive)) if ((table.CaseSensitive != table.DataSet.CaseSensitive))
{ {
this.CaseSensitive = table.CaseSensitive; CaseSensitive = table.CaseSensitive;
} }
if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) if ((table.Locale.ToString() != table.DataSet.Locale.ToString()))
{ {
this.Locale = table.Locale; Locale = table.Locale;
} }
if ((table.Namespace != table.DataSet.Namespace)) if ((table.Namespace != table.DataSet.Namespace))
{ {
this.Namespace = table.Namespace; Namespace = table.Namespace;
} }
this.Prefix = table.Prefix; Prefix = table.Prefix;
this.MinimumCapacity = table.MinimumCapacity; MinimumCapacity = table.MinimumCapacity;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -377,17 +360,14 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected CustomersDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : protected CustomersDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) :
base(info, context) base(info, context)
{ {
this.InitVars(); InitVars();
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public global::System.Data.DataColumn CustomerIDColumn public global::System.Data.DataColumn CustomerIDColumn
{ {
get get { return columnCustomerID; }
{
return this.columnCustomerID;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -395,20 +375,14 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.ComponentModel.Browsable(false)] [global::System.ComponentModel.Browsable(false)]
public int Count public int Count
{ {
get get { return Rows.Count; }
{
return this.Rows.Count;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersRow this[int index] public CustomersRow this[int index]
{ {
get get { return ((CustomersRow)(Rows[index])); }
{
return ((CustomersRow)(this.Rows[index]));
}
} }
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
@@ -427,18 +401,20 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public void AddCustomersRow(CustomersRow row) public void AddCustomersRow(CustomersRow row)
{ {
this.Rows.Add(row); Rows.Add(row);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersRow AddCustomersRow(string CustomerID) public CustomersRow AddCustomersRow(string CustomerID)
{ {
CustomersRow rowCustomersRow = ((CustomersRow)(this.NewRow())); CustomersRow rowCustomersRow = ((CustomersRow)(NewRow()));
object[] columnValuesArray = new object[] { object[] columnValuesArray = new object[]
CustomerID}; {
CustomerID
};
rowCustomersRow.ItemArray = columnValuesArray; rowCustomersRow.ItemArray = columnValuesArray;
this.Rows.Add(rowCustomersRow); Rows.Add(rowCustomersRow);
return rowCustomersRow; return rowCustomersRow;
} }
@@ -446,7 +422,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public virtual global::System.Collections.IEnumerator GetEnumerator() public virtual global::System.Collections.IEnumerator GetEnumerator()
{ {
return this.Rows.GetEnumerator(); return Rows.GetEnumerator();
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -469,22 +445,22 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
internal void InitVars() internal void InitVars()
{ {
this.columnCustomerID = base.Columns["CustomerID"]; columnCustomerID = base.Columns["CustomerID"];
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
private void InitClass() private void InitClass()
{ {
this.columnCustomerID = new global::System.Data.DataColumn("CustomerID", typeof(string), null, global::System.Data.MappingType.Element); columnCustomerID = new global::System.Data.DataColumn("CustomerID", typeof(string), null, global::System.Data.MappingType.Element);
base.Columns.Add(this.columnCustomerID); base.Columns.Add(columnCustomerID);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersRow NewCustomersRow() public CustomersRow NewCustomersRow()
{ {
return ((CustomersRow)(this.NewRow())); return ((CustomersRow)(NewRow()));
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -506,9 +482,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e)
{ {
base.OnRowChanged(e); base.OnRowChanged(e);
if ((this.CustomersRowChanged != null)) if ((CustomersRowChanged != null))
{ {
this.CustomersRowChanged(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action)); CustomersRowChanged(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action));
} }
} }
@@ -517,9 +493,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e)
{ {
base.OnRowChanging(e); base.OnRowChanging(e);
if ((this.CustomersRowChanging != null)) if ((CustomersRowChanging != null))
{ {
this.CustomersRowChanging(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action)); CustomersRowChanging(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action));
} }
} }
@@ -528,9 +504,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e)
{ {
base.OnRowDeleted(e); base.OnRowDeleted(e);
if ((this.CustomersRowDeleted != null)) if ((CustomersRowDeleted != null))
{ {
this.CustomersRowDeleted(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action)); CustomersRowDeleted(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action));
} }
} }
@@ -539,9 +515,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e)
{ {
base.OnRowDeleting(e); base.OnRowDeleting(e);
if ((this.CustomersRowDeleting != null)) if ((CustomersRowDeleting != null))
{ {
this.CustomersRowDeleting(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action)); CustomersRowDeleting(this, new CustomersRowChangeEvent(((CustomersRow)(e.Row)), e.Action));
} }
} }
@@ -549,7 +525,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public void RemoveCustomersRow(CustomersRow row) public void RemoveCustomersRow(CustomersRow row)
{ {
this.Rows.Remove(row); Rows.Remove(row);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -631,7 +607,6 @@ namespace Newtonsoft.Json.Tests.TestObjects
///</summary> ///</summary>
public partial class CustomersRow : global::System.Data.DataRow public partial class CustomersRow : global::System.Data.DataRow
{ {
private CustomersDataTable tableCustomers; private CustomersDataTable tableCustomers;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -639,7 +614,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
internal CustomersRow(global::System.Data.DataRowBuilder rb) : internal CustomersRow(global::System.Data.DataRowBuilder rb) :
base(rb) base(rb)
{ {
this.tableCustomers = ((CustomersDataTable)(this.Table)); tableCustomers = ((CustomersDataTable)(Table));
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -650,31 +625,28 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
try try
{ {
return ((string)(this[this.tableCustomers.CustomerIDColumn])); return ((string)(this[tableCustomers.CustomerIDColumn]));
} }
catch (global::System.InvalidCastException e) catch (global::System.InvalidCastException e)
{ {
throw new global::System.Data.StrongTypingException("The value for column \'CustomerID\' in table \'Customers\' is DBNull.", e); throw new global::System.Data.StrongTypingException("The value for column \'CustomerID\' in table \'Customers\' is DBNull.", e);
} }
} }
set set { this[tableCustomers.CustomerIDColumn] = value; }
{
this[this.tableCustomers.CustomerIDColumn] = value;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public bool IsCustomerIDNull() public bool IsCustomerIDNull()
{ {
return this.IsNull(this.tableCustomers.CustomerIDColumn); return IsNull(tableCustomers.CustomerIDColumn);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public void SetCustomerIDNull() public void SetCustomerIDNull()
{ {
this[this.tableCustomers.CustomerIDColumn] = global::System.Convert.DBNull; this[tableCustomers.CustomerIDColumn] = global::System.Convert.DBNull;
} }
} }
@@ -684,7 +656,6 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public class CustomersRowChangeEvent : global::System.EventArgs public class CustomersRowChangeEvent : global::System.EventArgs
{ {
private CustomersRow eventRow; private CustomersRow eventRow;
private global::System.Data.DataRowAction eventAction; private global::System.Data.DataRowAction eventAction;
@@ -693,30 +664,25 @@ namespace Newtonsoft.Json.Tests.TestObjects
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersRowChangeEvent(CustomersRow row, global::System.Data.DataRowAction action) public CustomersRowChangeEvent(CustomersRow row, global::System.Data.DataRowAction action)
{ {
this.eventRow = row; eventRow = row;
this.eventAction = action; eventAction = action;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public CustomersRow Row public CustomersRow Row
{ {
get get { return eventRow; }
{
return this.eventRow;
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
public global::System.Data.DataRowAction Action public global::System.Data.DataRowAction Action
{ {
get get { return eventAction; }
{
return this.eventAction;
}
} }
} }
} }
} }
#endif #endif
@@ -35,11 +35,14 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class DateTimeTestClass public class DateTimeTestClass
{ {
public string PreField { get; set; } public string PreField { get; set; }
[DefaultValue("")] [DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public DateTime DateTimeField { get; set; } public DateTime DateTimeField { get; set; }
public DateTimeOffset DateTimeOffsetField { get; set; } public DateTimeOffset DateTimeOffsetField { get; set; }
public string PostField { get; set; } public string PostField { get; set; }
} }
} }
#endif #endif
@@ -41,7 +41,6 @@ namespace Newtonsoft.Json.Tests.TestObjects
public sealed class Event public sealed class Event
{ {
/// <summary> /// <summary>
/// If no current user is specified, returns Nothing (0 from VB) /// If no current user is specified, returns Nothing (0 from VB)
/// </summary> /// </summary>
@@ -110,36 +109,43 @@ namespace Newtonsoft.Json.Tests.TestObjects
get { return _sublocation; } get { return _sublocation; }
set { _sublocation = value; } set { _sublocation = value; }
} }
public int userId public int userId
{ {
get { return _userId; } get { return _userId; }
set { _userId = value; } set { _userId = value; }
} }
public EventType type public EventType type
{ {
get { return _type; } get { return _type; }
set { _type = value; } set { _type = value; }
} }
public string summary public string summary
{ {
get { return _summary; } get { return _summary; }
set { _summary = value; } set { _summary = value; }
} }
public string details public string details
{ {
get { return _details; } get { return _details; }
set { _details = value; } set { _details = value; }
} }
public string stackTrace public string stackTrace
{ {
get { return _stackTrace; } get { return _stackTrace; }
set { _stackTrace = value; } set { _stackTrace = value; }
} }
public string tag public string tag
{ {
get { return _tag; } get { return _tag; }
set { _tag = value; } set { _tag = value; }
} }
public DateTime time public DateTime time
{ {
get { return _time; } get { return _time; }
@@ -29,7 +29,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
public class HolderClass public class HolderClass
{ {
public HolderClass() { } public HolderClass()
{
}
[Newtonsoft.Json.JsonProperty(TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All)] [Newtonsoft.Json.JsonProperty(TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All)]
public ContentBaseClass TestMember { get; set; } public ContentBaseClass TestMember { get; set; }
@@ -38,6 +40,5 @@ namespace Newtonsoft.Json.Tests.TestObjects
public Dictionary<int, IList<ContentBaseClass>> AnotherTestMember { get; set; } public Dictionary<int, IList<ContentBaseClass>> AnotherTestMember { get; set; }
public ContentBaseClass AThirdTestMember { get; set; } public ContentBaseClass AThirdTestMember { get; set; }
} }
} }
@@ -41,6 +41,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
// customize default values // customize default values
[DefaultValue(30)] [DefaultValue(30)]
public int FollowUpDays { get; set; } public int FollowUpDays { get; set; }
[DefaultValue("")] [DefaultValue("")]
public string FollowUpEmailAddress { get; set; } public string FollowUpEmailAddress { get; set; }
} }
@@ -31,6 +31,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
private int _ignoredProperty = 12; private int _ignoredProperty = 12;
public int Field; public int Field;
public int Property public int Property
{ {
get { return _property; } get { return _property; }
@@ -32,6 +32,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
public string Member { get; set; } public string Member { get; set; }
private string _throwError; private string _throwError;
public string ThrowError public string ThrowError
{ {
get get
@@ -32,6 +32,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
{ {
[JsonProperty] [JsonProperty]
public string id { get; set; } public string id { get; set; }
[JsonProperty] [JsonProperty]
public List<ListItem> items { get; set; } public List<ListItem> items { get; set; }
} }
@@ -31,6 +31,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class MemberConverterClass public class MemberConverterClass
{ {
public DateTime DefaultConverter { get; set; } public DateTime DefaultConverter { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))] [JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime MemberConverter { get; set; } public DateTime MemberConverter { get; set; }
} }
@@ -39,4 +39,5 @@ namespace Newtonsoft.Json.Tests.TestObjects
public string PostField { get; set; } public string PostField { get; set; }
} }
} }
#endif #endif
@@ -36,6 +36,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
public string Name { get; set; } public string Name { get; set; }
public int Age { get; set; } public int Age { get; set; }
public List<string> Roles public List<string> Roles
{ {
get get
@@ -47,6 +48,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
} }
set { _roles = value; } set { _roles = value; }
} }
public string Title { get; set; } public string Title { get; set; }
[OnError] [OnError]
@@ -33,8 +33,8 @@ namespace Newtonsoft.Json.Tests.TestObjects
[JsonProperty("PropertyA")] [JsonProperty("PropertyA")]
string IPrivateImplementationA.PropertyA string IPrivateImplementationA.PropertyA
{ {
get { return this.PropertyA; } get { return PropertyA; }
set { this.PropertyA = value; } set { PropertyA = value; }
} }
} }
} }
@@ -33,15 +33,15 @@ namespace Newtonsoft.Json.Tests.TestObjects
[JsonProperty("PropertyB")] [JsonProperty("PropertyB")]
string IPrivateImplementationB.PropertyB string IPrivateImplementationB.PropertyB
{ {
get { return this.PropertyB; } get { return PropertyB; }
set { this.PropertyB = value; } set { PropertyB = value; }
} }
[JsonProperty("OverriddenProperty")] [JsonProperty("OverriddenProperty")]
private string OverriddenPropertyString private string OverriddenPropertyString
{ {
get { return this.OverriddenProperty.ToString(); } get { return OverriddenProperty.ToString(); }
set { this.OverriddenProperty = value; } set { OverriddenProperty = value; }
} }
[JsonIgnore] [JsonIgnore]
@@ -50,8 +50,8 @@ namespace Newtonsoft.Json.Tests.TestObjects
[JsonIgnore] [JsonIgnore]
object IPrivateOverriddenImplementation.OverriddenProperty object IPrivateOverriddenImplementation.OverriddenProperty
{ {
get { return this.OverriddenProperty; } get { return OverriddenProperty; }
set { this.OverriddenProperty = value; } set { OverriddenProperty = value; }
} }
} }
} }
@@ -28,10 +28,12 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class SetOnlyPropertyClass2 public class SetOnlyPropertyClass2
{ {
private object _value; private object _value;
public object SetOnlyProperty public object SetOnlyProperty
{ {
set { _value = value; } set { _value = value; }
} }
public object GetValue() public object GetValue()
{ {
return _value; return _value;
@@ -1,4 +1,4 @@
#region License #region License
// Copyright (c) 2007 James Newton-King // Copyright (c) 2007 James Newton-King
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
@@ -37,10 +37,13 @@ namespace Newtonsoft.Json.Tests.TestObjects
public int[] RoomsPerFloor = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; public int[] RoomsPerFloor = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
public bool Open = false; public bool Open = false;
public char Symbol = '@'; public char Symbol = '@';
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)] [JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Mottos = new List<string>(); public List<string> Mottos = new List<string>();
public decimal Cost = 100980.1M; public decimal Cost = 100980.1M;
public string Escape = "\r\n\t\f\b?{\\r\\n\"\'"; public string Escape = "\r\n\t\f\b?{\\r\\n\"\'";
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)] [JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<Product> product = new List<Product>(); public List<Product> product = new List<Product>();
@@ -28,6 +28,10 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class SubKlass : SuperKlass public class SubKlass : SuperKlass
{ {
public string SubProp { get; set; } public string SubProp { get; set; }
public SubKlass(string subprop) { SubProp = subprop; }
public SubKlass(string subprop)
{
SubProp = subprop;
}
} }
} }
@@ -28,6 +28,10 @@ namespace Newtonsoft.Json.Tests.TestObjects
public class SuperKlass public class SuperKlass
{ {
public string SuperProp { get; set; } public string SuperProp { get; set; }
public SuperKlass() { SuperProp = "default superprop"; }
public SuperKlass()
{
SuperProp = "default superprop";
}
} }
} }
@@ -129,4 +129,5 @@ namespace Newtonsoft.Json.Tests.Utilities
} }
} }
} }
#endif #endif
@@ -299,4 +299,5 @@ namespace Newtonsoft.Json.Tests.Utilities
} }
} }
} }
#endif #endif
@@ -60,4 +60,5 @@ namespace Newtonsoft.Json.Tests.Utilities
} }
} }
} }
#endif #endif
@@ -31,8 +31,10 @@ namespace Newtonsoft.Json.Bson
{ {
Binary = 0x00, Binary = 0x00,
Function = 0x01, Function = 0x01,
[Obsolete("This type has been deprecated in the BSON specification. Use Binary instead.")] [Obsolete("This type has been deprecated in the BSON specification. Use Binary instead.")]
BinaryOld = 0x02, BinaryOld = 0x02,
[Obsolete("This type has been deprecated in the BSON specification. Use Uuid instead.")] [Obsolete("This type has been deprecated in the BSON specification. Use Uuid instead.")]
UuidOld = 0x03, UuidOld = 0x03,
Uuid = 0x04, Uuid = 0x04,

Some files were not shown because too many files have changed in this diff Show More