diff --git a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs index b035ea29..d8bafe89 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs @@ -71,7 +71,9 @@ namespace Newtonsoft.Json.Tests jsonWriter.WriteEndObject(); } - string json = Encoding.UTF8.GetString(ms.ToArray()); + byte[] data = ms.ToArray(); + + string json = Encoding.UTF8.GetString(data, 0, data.Length); Assert.AreEqual(@"{" + '\n' + @" ""prop"": true" + '\n' + "}", json); } diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index 4dbd1238..dd92fe1a 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -75,4 +75,4 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.3.17309")] +[assembly: AssemblyFileVersion("6.0.3.17312")] diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs index cfe56f93..0395cc7e 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs @@ -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 + { + 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 + { + private readonly List _list; + + public ReadOnlyIntegerList(List l) + { + _list = l; + } + + public int Count + { + get { return _list.Count; } + } + + public IEnumerator GetEnumerator() + { + return _list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +#endif + public class Array2D { public string Before { get; set; } diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index 8088a949..917f8b38 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -91,5 +91,5 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.3.17309")] +[assembly: AssemblyFileVersion("6.0.3.17312")] [assembly: CLSCompliant(true)] diff --git a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs index bca6477a..a205efe5 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs @@ -127,7 +127,7 @@ namespace Newtonsoft.Json.Serialization #if !(NET40 || NET35 || NET20 || PORTABLE40) else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyCollection<>), out tempCollectionType)) { - CollectionItemType = underlyingType.GetGenericArguments()[0]; + CollectionItemType = tempCollectionType.GetGenericArguments()[0]; if (ReflectionUtils.IsGenericDefinition(underlyingType, typeof(IReadOnlyCollection<>)) || ReflectionUtils.IsGenericDefinition(underlyingType, typeof(IReadOnlyList<>)))