diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
index 939e3471..e56ebef5 100644
--- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
@@ -38,8 +38,7 @@ namespace Newtonsoft.Json.Tests.Bson
{
public class BsonReaderTests : TestFixtureBase
{
- private char pound = '\u00a3';
- private char euro = '\u20ac';
+ private const char Euro = '\u20ac';
[Test]
public void ReadSingleObject()
@@ -829,7 +828,7 @@ namespace Newtonsoft.Json.Tests.Bson
//sb.Append('1',127); //first char of euro at the end of the boundry.
//sb.Append(euro, 5);
//sb.Append('1',128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringValue(expected));
@@ -840,9 +839,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 127); //first char of euro at the end of the boundry.
- sb.Append(euro, 5);
+ sb.Append(Euro, 5);
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringValue(expected));
@@ -853,9 +852,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 126);
- sb.Append(euro, 5); //middle char of euro at the end of the boundry.
+ sb.Append(Euro, 5); //middle char of euro at the end of the boundry.
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
string result = WriteAndReadStringValue(expected);
@@ -866,7 +865,7 @@ namespace Newtonsoft.Json.Tests.Bson
public void TestReadLenStringValueTripleByteCharOne()
{
StringBuilder sb = new StringBuilder();
- sb.Append(euro, 1); //Just one triple byte char in the string.
+ sb.Append(Euro, 1); //Just one triple byte char in the string.
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringValue(expected));
@@ -877,9 +876,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 125);
- sb.Append(euro, 5); //last char of the eruo at the end of the boundry.
+ sb.Append(Euro, 5); //last char of the eruo at the end of the boundry.
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringValue(expected));
@@ -908,7 +907,7 @@ namespace Newtonsoft.Json.Tests.Bson
//sb.Append('1',127); //first char of euro at the end of the boundry.
//sb.Append(euro, 5);
//sb.Append('1',128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringPropertyName(expected));
@@ -919,9 +918,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 127); //first char of euro at the end of the boundry.
- sb.Append(euro, 5);
+ sb.Append(Euro, 5);
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
string result = WriteAndReadStringPropertyName(expected);
@@ -933,9 +932,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 126);
- sb.Append(euro, 5); //middle char of euro at the end of the boundry.
+ sb.Append(Euro, 5); //middle char of euro at the end of the boundry.
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringPropertyName(expected));
@@ -945,7 +944,7 @@ namespace Newtonsoft.Json.Tests.Bson
public void TestReadStringPropertyNameTripleByteCharOne()
{
StringBuilder sb = new StringBuilder();
- sb.Append(euro, 1); //Just one triple byte char in the string.
+ sb.Append(Euro, 1); //Just one triple byte char in the string.
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringPropertyName(expected));
@@ -956,9 +955,9 @@ namespace Newtonsoft.Json.Tests.Bson
{
StringBuilder sb = new StringBuilder();
sb.Append('1', 125);
- sb.Append(euro, 5); //last char of the eruo at the end of the boundry.
+ sb.Append(Euro, 5); //last char of the eruo at the end of the boundry.
sb.Append('1', 128);
- sb.Append(euro);
+ sb.Append(Euro);
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringPropertyName(expected));
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
index 450e30d6..95774c26 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
@@ -3318,6 +3318,44 @@ keyword such as type of business.""
Assert.AreEqual(27, deserialized.Age);
}
+ public class Employee
+ {
+ public string Name { get; set; }
+ public Employee Manager { get; set; }
+
+ public bool ShouldSerializeManager()
+ {
+ return (Manager != this);
+ }
+ }
+
+ [Test]
+ public void ShouldSerializeExample()
+ {
+ Employee joe = new Employee();
+ joe.Name = "Joe Employee";
+ Employee mike = new Employee();
+ mike.Name = "Mike Manager";
+
+ joe.Manager = mike;
+ mike.Manager = mike;
+
+ string json = JsonConvert.SerializeObject(new []{ joe, mike }, Formatting.Indented);
+ // [
+ // {
+ // "Name": "Joe Employee",
+ // "Manager": {
+ // "Name": "Mike Manager"
+ // }
+ // },
+ // {
+ // "Name": "Mike Manager"
+ // }
+ // ]
+
+ Console.WriteLine(json);
+ }
+
public class DictionaryKey
{
public string Value { get; set; }
diff --git a/Src/Newtonsoft.Json/Bson/BsonObjectId.cs b/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
index 5a305ad8..7fcf223d 100644
--- a/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
@@ -31,10 +31,21 @@ using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Bson
{
+ ///
+ /// Represents a BSON Oid (object id).
+ ///
public class BsonObjectId
{
+ ///
+ /// Gets or sets the value of the Oid.
+ ///
+ /// The value of the Oid.
public byte[] Value { get; private set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Oid value.
public BsonObjectId(byte[] value)
{
ValidationUtils.ArgumentNotNull(value, "value");
diff --git a/Src/Newtonsoft.Json/Bson/BsonWriter.cs b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
index 076bcbbc..91c328b5 100644
--- a/Src/Newtonsoft.Json/Bson/BsonWriter.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
@@ -134,6 +134,10 @@ namespace Newtonsoft.Json.Bson
AddParent(new BsonObject());
}
+ ///
+ /// Writes the property name of a name/value pair on a Json object.
+ ///
+ /// The name of the property.
public override void WritePropertyName(string name)
{
base.WritePropertyName(name);
diff --git a/Src/Newtonsoft.Json/Converters/BsonObjectIdConverter.cs b/Src/Newtonsoft.Json/Converters/BsonObjectIdConverter.cs
index 2d0ef82c..e5697c22 100644
--- a/Src/Newtonsoft.Json/Converters/BsonObjectIdConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/BsonObjectIdConverter.cs
@@ -8,8 +8,17 @@ using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Converters
{
+ ///
+ /// Converts a to and from JSON and BSON.
+ ///
public class BsonObjectIdConverter : JsonConverter
{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
BsonObjectId objectId = (BsonObjectId) value;
@@ -25,6 +34,14 @@ namespace Newtonsoft.Json.Converters
}
}
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The existing value of object being read.
+ /// The calling serializer.
+ /// The object value.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType != JsonToken.Bytes)
@@ -35,6 +52,13 @@ namespace Newtonsoft.Json.Converters
return new BsonObjectId(value);
}
+ ///
+ /// Determines whether this instance can convert the specified object type.
+ ///
+ /// Type of the object.
+ ///
+ /// true if this instance can convert the specified object type; otherwise, false.
+ ///
public override bool CanConvert(Type objectType)
{
return (objectType == typeof (BsonObjectId));
diff --git a/Src/Newtonsoft.Json/Converters/DataTableConverter.cs b/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
index 3f588df6..55d98ef0 100644
--- a/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
@@ -65,6 +65,7 @@ namespace Newtonsoft.Json.Converters
///
/// The to read from.
/// Type of the object.
+ /// The existing value of object being read.
/// The calling serializer.
/// The object value.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
diff --git a/Src/Newtonsoft.Json/Converters/RegexConverter.cs b/Src/Newtonsoft.Json/Converters/RegexConverter.cs
index 21d78d2c..cd6ce993 100644
--- a/Src/Newtonsoft.Json/Converters/RegexConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/RegexConverter.cs
@@ -7,8 +7,17 @@ using Newtonsoft.Json.Bson;
namespace Newtonsoft.Json.Converters
{
+ ///
+ /// Converts a to and from JSON and BSON.
+ ///
public class RegexConverter : JsonConverter
{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Regex regex = (Regex) value;
@@ -63,6 +72,14 @@ namespace Newtonsoft.Json.Converters
writer.WriteEndObject();
}
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The existing value of object being read.
+ /// The calling serializer.
+ /// The object value.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
BsonReader bsonReader = reader as BsonReader;
@@ -119,6 +136,13 @@ namespace Newtonsoft.Json.Converters
return new Regex(pattern, (RegexOptions)options);
}
+ ///
+ /// Determines whether this instance can convert the specified object type.
+ ///
+ /// Type of the object.
+ ///
+ /// true if this instance can convert the specified object type; otherwise, false.
+ ///
public override bool CanConvert(Type objectType)
{
return (objectType == typeof (Regex));
diff --git a/Src/Newtonsoft.Json/JsonConvert.cs b/Src/Newtonsoft.Json/JsonConvert.cs
index ebdf8697..24a38e3a 100644
--- a/Src/Newtonsoft.Json/JsonConvert.cs
+++ b/Src/Newtonsoft.Json/JsonConvert.cs
@@ -739,17 +739,52 @@ namespace Newtonsoft.Json
}
#if !NET20 && !SILVERLIGHT
+ ///
+ /// Serializes the to a JSON string.
+ ///
+ /// The node to convert to JSON.
+ /// A JSON string of the XNode.
public static string SerializeXNode(XObject node)
{
return SerializeXNode(node, Formatting.None);
}
+ ///
+ /// Serializes the to a JSON string.
+ ///
+ /// The node to convert to JSON.
+ /// Indicates how the output is formatted.
+ /// A JSON string of the XNode.
public static string SerializeXNode(XObject node, Formatting formatting)
{
XmlNodeConverter converter = new XmlNodeConverter();
return SerializeObject(node, formatting, converter);
}
+
+ ///
+ /// Deserializes the from a JSON string.
+ ///
+ /// The JSON string.
+ /// The deserialized XNode
+ public static XDocument DeserializeXNode(string value)
+ {
+ return DeserializeXNode(value, null);
+ }
+
+ ///
+ /// Deserializes the from a JSON string nested in a root elment.
+ ///
+ /// The JSON string.
+ /// The name of the root element to append when deserializing.
+ /// The deserialized XNode
+ public static XDocument DeserializeXNode(string value, string deserializeRootElementName)
+ {
+ XmlNodeConverter converter = new XmlNodeConverter();
+ converter.DeserializeRootElementName = deserializeRootElementName;
+
+ return (XDocument)DeserializeObject(value, typeof(XDocument), converter);
+ }
#endif
#if !SILVERLIGHT
@@ -799,32 +834,6 @@ namespace Newtonsoft.Json
return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), converter);
}
-
-#if !NET20
- ///
- /// Deserializes the XNode from a JSON string.
- ///
- /// The JSON string.
- /// The deserialized XmlNode
- public static XDocument DeserializeXNode(string value)
- {
- return DeserializeXNode(value, null);
- }
-
- ///
- /// Deserializes the XmlNode from a JSON string nested in a root elment.
- ///
- /// The JSON string.
- /// The name of the root element to append when deserializing.
- /// The deserialized XmlNode
- public static XDocument DeserializeXNode(string value, string deserializeRootElementName)
- {
- XmlNodeConverter converter = new XmlNodeConverter();
- converter.DeserializeRootElementName = deserializeRootElementName;
-
- return (XDocument)DeserializeObject(value, typeof(XDocument), converter);
- }
-#endif
#endif
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/JsonPropertyAttribute.cs b/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
index f4b2895d..5df13e69 100644
--- a/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
+++ b/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
@@ -57,6 +57,10 @@ namespace Newtonsoft.Json
set { _objectCreationHandling = value; }
}
+ ///
+ /// Gets or sets the type name handling used when serializing this property.
+ ///
+ /// The type name handling.
public TypeNameHandling TypeNameHandling
{
get { return _typeNameHandling ?? default(TypeNameHandling); }
diff --git a/Src/Newtonsoft.Json/Serialization/JsonProperty.cs b/Src/Newtonsoft.Json/Serialization/JsonProperty.cs
index 77cec849..13d721cd 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonProperty.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonProperty.cs
@@ -125,10 +125,18 @@ namespace Newtonsoft.Json.Serialization
/// The object creation handling.
public ObjectCreationHandling? ObjectCreationHandling { get; set; }
- public Predicate