System.Text.Json: Add IAsyncEnumerable support (#50778)
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Mon, 12 Apr 2021 16:06:01 +0000 (17:06 +0100)
committerGitHub <noreply@github.com>
Mon, 12 Apr 2021 16:06:01 +0000 (17:06 +0100)
commit81d3a993ca115ef7cf808d9f88f1ef6adad755f6
tree954389591b2dd88f8f502ac960d37575c1675dfe
parent111972565291bbfcaee2ae98609070c7ab764ee9
System.Text.Json: Add IAsyncEnumerable support (#50778)

* implement IAsyncEnumerable JsonConverter

* Prototype of IAsyncEnumerable deserialize with Stream

* Use a Queue + test buffersizes

* Avoid 1 item lag

* Add support for Serialize

* Misc cleanup on test

* extend DeserializeAsyncEnumerable test coverage

also removes SerializeAsyncEnumerable components

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableConverterFactory.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* address feedback

* tweak test buffer values

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableOfTConverter.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableOfTConverter.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* address feedback

* increase delayInterval in serialization tests

* address feedback

* address feedback

* add test on exceptional IAsyncDisposable disposal

* address feedback

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ReadAsyncState.cs

Co-authored-by: Layomi Akinrinade <layomia@gmail.com>
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/WriteStack.cs

Co-authored-by: Layomi Akinrinade <layomia@gmail.com>
* fix build and remove dead code

* address feedback

* Revert unneeded JsonClassInfo.ElementType workaround

* remove state allocation on async deserialization methods

* remove tooling artifacts

* address feedback

* reset AsyncEnumeratorIsPendingCompletion field

Co-authored-by: Steve Harter <steveharter@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Layomi Akinrinade <layomia@gmail.com>
19 files changed:
src/libraries/System.Text.Json/ref/System.Text.Json.cs
src/libraries/System.Text.Json/src/Resources/Strings.resx
src/libraries/System.Text.Json/src/System.Text.Json.csproj
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ClassType.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableConverterFactory.cs [new file with mode: 0644]
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableOfTConverter.cs [new file with mode: 0644]
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableDefaultConverter.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonResumableConverterOfT.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Helpers.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Stream.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ReadAsyncBufferState.cs [new file with mode: 0644]
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/WriteStack.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/WriteStackFrame.cs
src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs
src/libraries/System.Text.Json/tests/Serialization/CollectionTests/CollectionTests.AsyncEnumerable.cs [new file with mode: 0644]
src/libraries/System.Text.Json/tests/Serialization/Stream.DeserializeAsyncEnumerable.cs [new file with mode: 0644]
src/libraries/System.Text.Json/tests/System.Text.Json.Tests.csproj