Skip to content

[ci-fix] Needs review: Fix PolymorphicTests order-dependent assertion on tvOS Mono (refs #128765)#129653

Draft
github-actions[bot] wants to merge 2 commits into
mainfrom
ci-fix/polymorphic-order-128765-55a8cc5e50e04736
Draft

[ci-fix] Needs review: Fix PolymorphicTests order-dependent assertion on tvOS Mono (refs #128765)#129653
github-actions[bot] wants to merge 2 commits into
mainfrom
ci-fix/polymorphic-order-128765-55a8cc5e50e04736

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Workflow artifact: ci-fix
Artifact kind: help
Linked KBE: #128765

Note

This is an AI/Copilot-generated draft PR that attempts to fix the CI failure described in KBE #128765. It has NOT been build-validated (environment lacks .NET 11 SDK). Human review is needed.

Root cause

The test MetadataServices_NullPolymorphismOptions_DoesNotActivateAttributeClassifier uses Assert.Collection (order-sensitive) to verify JsonPolymorphismOptions.DerivedTypes. It expects [Dog, Cat] matching the attribute declaration order on AttrClassifiedAnimal:

[JsonDerivedType(typeof(AttrClassifiedDog), "dog")]
[JsonDerivedType(typeof(AttrClassifiedCat), "cat")]
public class AttrClassifiedAnimal { ... }

On tvOS Mono, Type.GetCustomAttributes() returns these attributes in reverse order ([Cat, Dog]), causing the test to fail. The ECMA specification does not guarantee attribute ordering from reflection APIs.

Fix

Replace the order-sensitive Assert.Collection with:

  • Assert.Equal(2, options.DerivedTypes.Count) — verifies the expected number of types
  • Assert.Contains(...) for each type — verifies presence and discriminator without order dependency

Remove the [ActiveIssue] annotation since this fix addresses the root cause rather than disabling the test.

What is unverified / help needed

  • Build not validated: Environment has .NET 8/9 SDKs; the project targets .NET 11 preview.
  • Semantic question: Is the ordering of DerivedTypes semantically significant for JSON serialization behavior? If so, the real fix may be in the product code (ensuring deterministic ordering). If not, this test fix is correct.
  • Other tests: There may be similar order-dependent assertions elsewhere in the polymorphic test suite that could have the same issue on Mono.

Suggested reviewers / area contacts

  • @eiriktsarpalis (area-System.Text.Json owner)
  • @SteveSandersonMS

Validation

  • Command: dotnet build src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj
  • Result: not run because environment lacks .NET 11 SDK

Evidence


Filed by ci-failure-fix, which attempts validated fixes for [ci-scan] Known Build Errors and otherwise loops in owners. Comment here or on the workflow file to suggest changes; ci-failure-scan-feedback reads in-scope feedback daily and opens (or updates) a PR with prompt edits.

Note

🔒 Integrity filter blocked 2 items

The following items were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by CI Outer-Loop Failure Fixer · ● 60.4M ·

The test MetadataServices_NullPolymorphismOptions_DoesNotActivateAttributeClassifier
used Assert.Collection which is order-sensitive. On tvOS Mono, attribute
ordering from Type.GetCustomAttributes differs from CoreCLR, causing
DerivedTypes to appear as [Cat, Dog] instead of [Dog, Cat].

Since the ECMA specification does not guarantee attribute ordering from
GetCustomAttributes, replace the order-sensitive Assert.Collection with
Assert.Contains checks that verify both derived types are present with
correct discriminators, regardless of order.

Remove the [ActiveIssue] annotation that disabled the test on Apple
Mobile Mono since the fix addresses the root cause.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants