Rewrite System.Text.Json stream tests to be async friendly and enable on WASM (#38663)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 10 Jul 2020 20:43:16 +0000 (22:43 +0200)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 20:43:16 +0000 (22:43 +0200)
commit95e3dcc5ec4a8b5028a3fd6705d55f77d1e1cca9
tree9c857d87c9dafc34e80a3df0aa05b4c446fba2e2
parenta0987db4857ea6f15944f4e8306e49517afa5768
Rewrite System.Text.Json stream tests to be async friendly and enable on WASM (#38663)

The tests dealing are using a (De)SerializationWrapper so the same code can be used both for String and Stream types.
It does that by wrapping the async Stream serialization calls in `Task.Run().GetAwaiter().GetResult()` to turn them into sync calls.
However that doesn't work on WebAssembly since we can't wait on tasks as there's only a single thread.

To fix this inverse the wrapper so the synchronous String calls are turned into async and use normal awaits for the Stream calls.

This allows the test suite to pass on WebAssembly: `Tests run: 8349, Errors: 0, Failures: 0, Skipped: 11. Time: 475.528706s`
17 files changed:
src/libraries/System.Text.Json/tests/JsonDocumentTests.cs
src/libraries/System.Text.Json/tests/Serialization/CacheTests.cs
src/libraries/System.Text.Json/tests/Serialization/ConstructorTests/ConstructorTests.AttributePresence.cs
src/libraries/System.Text.Json/tests/Serialization/ConstructorTests/ConstructorTests.Cache.cs
src/libraries/System.Text.Json/tests/Serialization/ConstructorTests/ConstructorTests.Exceptions.cs
src/libraries/System.Text.Json/tests/Serialization/ConstructorTests/ConstructorTests.ParameterMatching.cs
src/libraries/System.Text.Json/tests/Serialization/ConstructorTests/ConstructorTests.Stream.cs
src/libraries/System.Text.Json/tests/Serialization/DeserializationWrapper.cs
src/libraries/System.Text.Json/tests/Serialization/InvalidTypeTests.cs
src/libraries/System.Text.Json/tests/Serialization/PolymorphicTests.cs
src/libraries/System.Text.Json/tests/Serialization/ReferenceHandlerTests.Deserialize.cs
src/libraries/System.Text.Json/tests/Serialization/SerializationWrapper.cs
src/libraries/System.Text.Json/tests/Serialization/Stream.Collections.cs
src/libraries/System.Text.Json/tests/Serialization/Stream.ReadTests.cs
src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.MultiSegment.cs
src/libraries/System.Text.Json/tests/Utf8JsonReaderTests.cs
src/libraries/tests.proj