-Fixed deserializing non-generic IReadOnlyCollection<T> implementations
This commit is contained in:
@@ -1488,8 +1488,58 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(2, products.Count);
|
||||
Assert.AreEqual("Product 1", products[0].Name);
|
||||
}
|
||||
|
||||
#if !(NET40 || NET35 || NET20 || PORTABLE40)
|
||||
[Test]
|
||||
public void ReadOnlyIntegerList()
|
||||
{
|
||||
ReadOnlyIntegerList l = new ReadOnlyIntegerList(new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
int.MaxValue
|
||||
});
|
||||
|
||||
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
2147483647
|
||||
]", json);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !(NET40 || NET35 || NET20 || PORTABLE40)
|
||||
public class ReadOnlyIntegerList : IReadOnlyCollection<int>
|
||||
{
|
||||
private readonly List<int> _list;
|
||||
|
||||
public ReadOnlyIntegerList(List<int> l)
|
||||
{
|
||||
_list = l;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _list.Count; }
|
||||
}
|
||||
|
||||
public IEnumerator<int> GetEnumerator()
|
||||
{
|
||||
return _list.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public class Array2D
|
||||
{
|
||||
public string Before { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user