Skip to content

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

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

[ci-fix] Needs review: Fix PolymorphicTests order-dependent assertion on tvOS Mono (refs #128765)#129653
github-actions[bot] wants to merge 4 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.

@kotlarmilos
kotlarmilos marked this pull request as ready for review July 3, 2026 11:10
Copilot AI review requested due to automatic review settings July 3, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates a System.Text.Json polymorphism test to avoid relying on reflection attribute ordering, improving cross-runtime stability (notably for Mono on Apple mobile targets).

Changes:

  • Remove the [ActiveIssue] skip from MetadataServices_NullPolymorphismOptions_DoesNotActivateAttributeClassifier.
  • Replace order-sensitive Assert.Collection validation of JsonPolymorphismOptions.DerivedTypes with order-insensitive count + membership assertions.
Show a summary per file
File Description
src/libraries/System.Text.Json/tests/Common/PolymorphicTests.TypeClassifier.cs Makes derived-type assertions order-insensitive and removes the tvOS Mono skip for the affected test.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
Comment thread src/libraries/System.Text.Json/tests/Common/PolymorphicTests.TypeClassifier.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "0fa6bd7fd97344489d24ff3733406232f7074481",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "e6428cb16317ce994463cb132690ec728991edd9",
  "last_reviewed_commit": "0fa6bd7fd97344489d24ff3733406232f7074481",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "e6428cb16317ce994463cb132690ec728991edd9",
  "last_recorded_worker_run_id": "29679153469",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "0fa6bd7fd97344489d24ff3733406232f7074481",
      "review_id": 4730521752
    }
  ]
}

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holistic Review

Motivation: Justified. The test MetadataServices_NullPolymorphismOptions_DoesNotActivateAttributeClassifier asserted DerivedTypes in the exact order the [JsonDerivedType] attributes are declared, but reflection attribute enumeration order is not guaranteed by ECMA and differs on tvOS Mono, producing a spurious failure (issue #128765). Making the assertion order-independent addresses the real root cause rather than only suppressing the failure via [ActiveIssue].

Approach: Sound and minimal. Replacing the order-sensitive Assert.Collection with a count check plus two Assert.Contains predicates preserves the test's intent (both derived types with correct discriminators are present) while removing the incorrect ordering dependency. Removing the [ActiveIssue] annotation is appropriate since the fix is a genuine correction, and the change is confined to a single test file. DerivedTypes ordering is not semantically significant for serialization correctness — discriminator resolution is keyed by type and discriminator name, not list position — so relaxing the ordering assertion does not weaken meaningful coverage.

Summary: ✅ LGTM. Test-only change that correctly removes an unwarranted reflection-ordering assumption; low risk with no product-code impact. Two non-blocking notes for the human merger: (1) issue #128765 can be closed once this merges, since the [ActiveIssue] suppression is being removed; (2) as the PR description itself notes, it is worth a quick check for other order-sensitive Assert.Collection/Assert.Equal assertions over reflection-derived collections in the polymorphic test suite that could exhibit the same Mono ordering fragility. The author flagged that the change was not build-validated (environment lacked the required SDK); the edit is straightforward and syntactically correct, but CI should confirm the build and the tvOS Mono run.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 49.3 AIC · ⌖ 10.3 AIC · ⊞ 10K

@kotlarmilos

Copy link
Copy Markdown
Member

Mono mobile doesn't run on CI anymore

kotlarmilos added a commit that referenced this pull request Aug 18, 2026
…fixed & retired-leg PRs (#132318)

The `ci-failure-fix` workflow keeps opening help-wanted PRs for failures
that no longer happen — retired legs (#129653, "Mono
mobile doesn't run on CI anymore"), already-merged fixes
(#130231), and stale KBEs (#130232). This is
the dominant closed-unmerged class over the last several ticks, and
prior feedback issues (#131644, #131699)
flagged it without a guard ever landing.

## Changes

`.github/workflows/ci-failure-fix.md` only — prompt text, no code:

- **Step 4, new gate before any fix attempt** (inserted as item 2;
following items renumbered 3/4). Three checks, first trip ends the KBE
with a recorded skip — no PR, no loop-in comment:
- **Recent occurrence** — signature checked against the newest completed
builds of the definition plus Build Analysis occurrence data in the KBE
body; nothing in 14d → `skipped: no occurrence in last 14d, likely
already fixed or retired`
- **Live leg** — the leg must appear in the newest completed build's
timeline *and* still be defined in `eng/pipelines/**` at `HEAD`; retired
Mono-mobile/wasm legs, deleted queues, dropped images → `skipped:
failing leg retired, no longer runs at HEAD`
- **Fix already landed** — failing source read at `HEAD` plus `git log`
since KBE creation; faulty path already removed → `skipped: fix already
present at HEAD; KBE stale`
- **Recognized skip reasons list** — the three phrasings registered
verbatim so the feedback workflow's tally aggregation stays stable.
- One pre-existing trailing space removed (line 192); markdownlint runs
repo-wide on any PR touching `.md` and MD009 is the sole enabled rule.

Placement is deliberate: after Step 3 dedup, before Step 5's fix
attempt, mirroring the existing Step 5.1.1 pipeline-category gate.
`Recorded skip` is already a valid outcome in the Step-summary table, so
no downstream change is needed.

## Notes

No lock-file regeneration: `ci-failure-fix.lock.yml` pulls the prompt
via `{{#runtime-import .github/workflows/ci-failure-fix.md}}` and stores
no hash of the body — only frontmatter changes require a recompile, and
the frontmatter is untouched. No other prompt references Step 4 items by
number, so the renumbering is contained.

Verified `markdownlint-cli` clean on the file. Nothing built or tested —
there is no code here.

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes #131873

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com>
@jkotas
jkotas deleted the ci-fix/polymorphic-order-128765-55a8cc5e50e04736 branch August 24, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment