From 1fd66df8afc31313825bd22ef8fe99ee94d54d9a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2026 13:50:45 +0000 Subject: [PATCH 1/2] Unwrap TargetInvocationException in async enumerable serialization tests On Mono/tvOS, async iterator exceptions propagated through JsonSerializer.SerializeAsyncEnumerable are wrapped in a TargetInvocationException. The tests previously used Assert.ThrowsAsync which fails when the exception is wrapped. Replace with Assert.ThrowsAnyAsync followed by explicit unwrapping of TargetInvocationException, then assert the inner exception is InvalidOperationException. This works correctly on both CoreCLR (direct exception) and Mono (wrapped exception). Remove the [ActiveIssue] annotations that disabled these tests on Apple Mobile Mono since the fix addresses the behavioral difference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../tests/Common/AsyncEnumerableTests.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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; From 2de48bbf3a4d7ad052a4ef8fd2e7a89409b0bcbb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 20 Jun 2026 13:50:49 +0000 Subject: [PATCH 2/2] ci: trigger checks