-Fixed serializing types with hidden properties

This commit is contained in:
JamesNK
2012-01-16 08:00:48 +00:00
parent 45cbd34daa
commit 2941344044
4 changed files with 57 additions and 5 deletions
@@ -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