Apply fix to #1460 to async writing. (#1540)

* Apply fix to #1460 to async writing.

* Replace recursion with iteration.

* Test for 1460 in async use.

* Change infinite loop style.
This commit is contained in:
Jon Hanna
2017-12-20 16:06:07 +13:00
committed by James Newton-King
parent 3ea750d6d6
commit 1b40ebfe26
4 changed files with 314 additions and 257 deletions
@@ -30,6 +30,10 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
#if !(NET20 || NET35 || NET40 || PORTABLE40)
using System.Threading.Tasks;
#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Xml;
@@ -60,5 +64,17 @@ namespace Newtonsoft.Json.Tests.Issues
Assert.AreEqual("null", sw.ToString());
}
#if !(NET20 || NET35 || NET40 || PORTABLE40)
[Test]
public async Task TestAsync()
{
StringWriter sw = new StringWriter();
JsonTextWriter writer = new JsonTextWriter(sw);
await JsonWriter.WriteValueAsync(writer, PrimitiveTypeCode.Object, null, CancellationToken.None);
Assert.AreEqual("null", sw.ToString());
}
#endif
}
}