-Fixed serializing IListSource implementations

This commit is contained in:
James Newton-King
2017-04-01 12:44:17 +13:00
parent 73652124cd
commit 33cf71dc74
2 changed files with 39 additions and 2 deletions
@@ -96,6 +96,42 @@ namespace Newtonsoft.Json.Tests.Serialization
[TestFixture]
public class JsonSerializerTest : TestFixtureBase
{
public class ListSourceTest : IListSource
{
private string str;
public string strprop
{
get { return str; }
set { str = value; }
}
[JsonIgnore]
public bool ContainsListCollection
{
get { return false; }
}
public IList GetList()
{
return new List<string>();
}
}
[Test]
public void ListSourceSerialize()
{
ListSourceTest c = new ListSourceTest();
c.strprop = "test";
string json = JsonConvert.SerializeObject(c);
Assert.AreEqual(@"{""strprop"":""test""}", json);
ListSourceTest c2 = JsonConvert.DeserializeObject<ListSourceTest>(json);
Assert.AreEqual("test", c2.strprop);
}
public struct ImmutableStruct
{
public ImmutableStruct(string value)