diff --git a/Doc/Samples/Linq/QueryJsonSelectTokenEscaped.aml b/Doc/Samples/Linq/QueryJsonSelectTokenEscaped.aml
index 4ddbb41b..c92645a9 100644
--- a/Doc/Samples/Linq/QueryJsonSelectTokenEscaped.aml
+++ b/Doc/Samples/Linq/QueryJsonSelectTokenEscaped.aml
@@ -2,7 +2,7 @@
- This sample loads JSON with properties that required escaped queries using M:Newtonsoft.Json.Linq.JToken.SelectToken(System.String).
+ This sample loads JSON with properties that need to be escaped when queried with M:Newtonsoft.Json.Linq.JToken.SelectToken(System.String).
Sample
diff --git a/Doc/SerializationAttributes.aml b/Doc/SerializationAttributes.aml
index ca4558df..3fe7ed53 100644
--- a/Doc/SerializationAttributes.aml
+++ b/Doc/SerializationAttributes.aml
@@ -146,6 +146,7 @@
T:Newtonsoft.Json.JsonPropertyAttribute
T:Newtonsoft.Json.JsonConverterAttribute
T:Newtonsoft.Json.JsonExtensionDataAttribute
+ T:Newtonsoft.Json.JsonConstructorAttribute
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs
index 6aeae522..a6e16db3 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs
@@ -203,7 +203,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.IsFalse(contract.IsInstantiable);
Assert.IsNull(contract.DefaultCreator);
- Assert.IsFalse(contract.HasParametrizedCreator);
+ Assert.IsFalse(contract.HasParameterizedCreatorInternal);
ExceptionAssert.Throws(() => JsonConvert.DeserializeObject>(@"[1,2]", new JsonSerializerSettings
{
@@ -283,7 +283,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.IsFalse(contract.IsInstantiable);
Assert.IsNull(contract.DefaultCreator);
- Assert.IsFalse(contract.HasParametrizedCreator);
+ Assert.IsFalse(contract.HasParameterizedCreatorInternal);
ExceptionAssert.Throws(() => JsonConvert.DeserializeObject>(@"{key1:1,key2:2}", new JsonSerializerSettings
{
@@ -436,13 +436,13 @@ namespace Newtonsoft.Json.Tests.Serialization
}
[Test]
- public void ParametrizedCreator()
+ public void ParameterizedCreator()
{
var resolver = new DefaultContractResolver();
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(PublicParametizedConstructorWithPropertyNameConflictWithAttribute));
Assert.IsNull(contract.DefaultCreator);
- Assert.IsNotNull(contract.ParametrizedCreator);
+ Assert.IsNotNull(contract.ParameterizedCreator);
#pragma warning disable 618
Assert.AreEqual(contract.ParametrizedConstructor, typeof(PublicParametizedConstructorWithPropertyNameConflictWithAttribute).GetConstructor(new[] { typeof(string) }));
#pragma warning restore 618
@@ -452,7 +452,7 @@ namespace Newtonsoft.Json.Tests.Serialization
#pragma warning disable 618
contract.ParametrizedConstructor = null;
#pragma warning restore 618
- Assert.IsNull(contract.ParametrizedCreator);
+ Assert.IsNull(contract.ParameterizedCreator);
}
[Test]
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs
index 369c0fb9..e50dfdac 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs
@@ -59,6 +59,248 @@ namespace Newtonsoft.Json.Tests.Serialization
[TestFixture]
public class JsonSerializerCollectionsTests : TestFixtureBase
{
+ public class TestCollectionPrivateParameterized : IEnumerable
+ {
+ private readonly List _bars;
+
+ public TestCollectionPrivateParameterized()
+ {
+ _bars = new List();
+ }
+
+ [JsonConstructor]
+ private TestCollectionPrivateParameterized(IEnumerable bars)
+ {
+ _bars = new List(bars);
+ }
+
+ public void Add(int bar)
+ {
+ _bars.Add(bar);
+ }
+
+ public IEnumerator GetEnumerator() => _bars.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+ }
+
+ [Test]
+ public void CollectionJsonConstructorPrivateParameterized()
+ {
+ TestCollectionPrivateParameterized c1 = new TestCollectionPrivateParameterized();
+ c1.Add(0);
+ c1.Add(1);
+ c1.Add(2);
+ string json = JsonConvert.SerializeObject(c1);
+ TestCollectionPrivateParameterized c2 = JsonConvert.DeserializeObject(json);
+
+ List values = c2.ToList();
+
+ Assert.AreEqual(3, values.Count);
+ Assert.AreEqual(0, values[0]);
+ Assert.AreEqual(1, values[1]);
+ Assert.AreEqual(2, values[2]);
+ }
+
+ public class TestCollectionPrivate : List
+ {
+ [JsonConstructor]
+ private TestCollectionPrivate()
+ {
+ }
+
+ public static TestCollectionPrivate Create()
+ {
+ return new TestCollectionPrivate();
+ }
+ }
+
+ [Test]
+ public void CollectionJsonConstructorPrivate()
+ {
+ TestCollectionPrivate c1 = TestCollectionPrivate.Create();
+ c1.Add(0);
+ c1.Add(1);
+ c1.Add(2);
+ string json = JsonConvert.SerializeObject(c1);
+ TestCollectionPrivate c2 = JsonConvert.DeserializeObject(json);
+
+ List values = c2.ToList();
+
+ Assert.AreEqual(3, values.Count);
+ Assert.AreEqual(0, values[0]);
+ Assert.AreEqual(1, values[1]);
+ Assert.AreEqual(2, values[2]);
+ }
+
+ public class TestCollectionMultipleParameters : List
+ {
+ [JsonConstructor]
+ public TestCollectionMultipleParameters(string s1, string s2)
+ {
+ }
+ }
+
+ [Test]
+ public void CollectionJsonConstructorMultipleParameters()
+ {
+ ExceptionAssert.Throws(
+ () => JsonConvert.SerializeObject(new TestCollectionMultipleParameters(null, null)),
+ "Constructor for 'Newtonsoft.Json.Tests.Serialization.JsonSerializerCollectionsTests+TestCollectionMultipleParameters' must have no parameters or a single parameter that implements 'System.Collections.Generic.IEnumerable`1[System.Int32]'.");
+ }
+
+ public class TestCollectionBadIEnumerableParameter : List
+ {
+ [JsonConstructor]
+ public TestCollectionBadIEnumerableParameter(List l)
+ {
+ }
+ }
+
+ [Test]
+ public void CollectionJsonConstructorBadIEnumerableParameter()
+ {
+ ExceptionAssert.Throws(
+ () => JsonConvert.SerializeObject(new TestCollectionBadIEnumerableParameter(null)),
+ "Constructor for 'Newtonsoft.Json.Tests.Serialization.JsonSerializerCollectionsTests+TestCollectionBadIEnumerableParameter' must have no parameters or a single parameter that implements 'System.Collections.Generic.IEnumerable`1[System.Int32]'.");
+ }
+
+#if !(DNXCORE50 || PORTABLE)
+ public class TestCollectionNonGeneric : ArrayList
+ {
+ [JsonConstructor]
+ public TestCollectionNonGeneric(IEnumerable l)
+ : base(l.Cast