diff --git a/src/libraries/System.Text.Json/tests/Common/AsyncEnumerableTests.cs b/src/libraries/System.Text.Json/tests/Common/AsyncEnumerableTests.cs index 69f11d1324fefa..3e7f0946f41560 100644 --- a/src/libraries/System.Text.Json/tests/Common/AsyncEnumerableTests.cs +++ b/src/libraries/System.Text.Json/tests/Common/AsyncEnumerableTests.cs @@ -7,6 +7,7 @@ using System.IO; using System.IO.Pipelines; using System.Linq; +using System.Reflection; using System.Text.Json.Serialization.Metadata; using System.Threading; using System.Threading.Tasks; @@ -841,7 +842,6 @@ static async IAsyncEnumerable EmptyAsyncEnumerable() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/128766", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsMonoRuntime))] public async Task SerializeAsyncEnumerable_TopLevelValues_PartialItemFailure_PriorItemsAreFullyWritten() { // When element serialization throws mid-item, items written prior to the failure @@ -851,13 +851,17 @@ public async Task SerializeAsyncEnumerable_TopLevelValues_PartialItemFailure_Pri using MemoryStream stream = new(); - await Assert.ThrowsAsync(() => + Exception ex = await Assert.ThrowsAnyAsync(() => JsonSerializer.SerializeAsyncEnumerable( stream, Items(), ResolveJsonTypeInfo(), topLevelValues: true)); + if (ex is TargetInvocationException { InnerException: { } inner }) + ex = inner; + Assert.IsType(ex); + string actual = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal("{\"V\":1}\n{\"V\":2}\n", actual); @@ -871,7 +875,6 @@ static async IAsyncEnumerable Items() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/128766", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsMonoRuntime))] public async Task SerializeAsyncEnumerable_PipeWriter_TopLevelValues_PartialItemFailure_PriorItemsAreFullyWritten() { // When element serialization throws mid-item, items written prior to the failure @@ -916,7 +919,11 @@ public async Task SerializeAsyncEnumerable_PipeWriter_TopLevelValues_PartialItem } }); - await Assert.ThrowsAsync(() => writeTask); + Exception ex = await Assert.ThrowsAnyAsync(() => writeTask); + if (ex is TargetInvocationException { InnerException: { } inner }) + ex = inner; + Assert.IsType(ex); + await pipe.Writer.CompleteAsync(); byte[] bytes = await readerTask;