Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs')
-rw-r--r--Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
index 14df3b6..7d5d738 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
@@ -5112,6 +5112,23 @@ keyword such as type of business.""
Assert.AreEqual(d1.Count, d2.Count);
Assert.AreEqual(d1[0], d2[0]);
}
+
+ [Test]
+ public void SerializeInheritanceHierarchyWithDuplicateProperty()
+ {
+ Bb b = new Bb();
+ b.no = true;
+ Aa a = b;
+ a.no = int.MaxValue;
+
+ string json = JsonConvert.SerializeObject(b);
+
+ Assert.AreEqual(@"{""no"":true}", json);
+
+ Bb b2 = JsonConvert.DeserializeObject<Bb>(json);
+
+ Assert.AreEqual(true, b2.no);
+ }
}
public class DecimalTestClass
@@ -5146,6 +5163,16 @@ keyword such as type of business.""
public Uri Uri { get; set; }
}
+ class Aa
+ {
+ public int no;
+ }
+
+ class Bb : Aa
+ {
+ public bool no;
+ }
+
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
[JsonObject(MemberSerialization.OptIn)]
public class GameObject