Skip to content

[Validation only - do not merge] dotnet test migration with sample PRs (net11) - #40705

Closed
kubaflo wants to merge 180 commits into
net11from
kubaflo-mtp-net11-sample-prs
Closed

kubaflo wants to merge 180 commits into
net11from
kubaflo-mtp-net11-sample-prs

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Warning

Validation only — do not merge. Exercises the Helix/XHarness → dotnet test migration (#40661) with real contributor PRs on top, to check that their new tests are discovered, run and reported by the native runners.

Description of Change

Base: the net11 validation branch of the migration (#40703).

Merged PRs: #40696 (Controls unit test), #40660 (iOS RefreshView device test), #40654 (Windows CollectionView device test), #40691 (Android Shell device test).

Issues Fixed

None — validation for #40661.

mattleibow and others added 30 commits November 5, 2026 13:52
Migrate xUnit suites and native device hosts to xUnit v3 and Microsoft.Testing.Platform, retain NUnit Appium integration, and run tests directly in CI with real TRX reporting.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the complete default platform matrix while allowing focused secondary-pipeline validation. Add the technical terms introduced by the migration documentation to the spelling dictionary.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add an explicit native Windows validation mode without review automation or automatic triggers. Keep the recursive trusted-asset workflow regression aligned with the new launcher sources.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Parse entry text with the culture used to format it. Keep the existing decimal-value assertions intact and verify both French and English runner cultures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the Copilot pipeline unchanged and use the dedicated device-tests pipeline for migration validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Do not label the existing Windows Server image as Windows 11 or reject it with an implicit client-only guard. Preserve interactive desktop and x64 checks, both packaging modes, and an explicit Windows 11 client requirement for client pools. Document the client-specific coverage difference.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fix the nonexistent image demands reported by the remote provider. Preserve both runtimes by default while exposing the existing runtime matrix for focused runs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Document macOS 15/26 and Windows 11 client coverage gaps explicitly while retaining strict OS checks and configurable execution pools.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the selected RID on Windows project references and scope package generation to native test applications instead of their library dependencies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reset handler factories, avoid shared Entry and theme state, and observe binding failures on the test task instead of throwing from asynchronous diagnostic callbacks. Exclude stale generated Debug sources from Release compilation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoid truthy string False values enabling Windows jobs or choosing CoreCLR for Mono lanes in legacy mapping-form templates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep binding diagnostics scoped to the exact binding and assert every reported diagnostic, preserving the original expected message.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use the standard xUnit executor on the real app dispatcher and verify actual fact/theory UI execution. Import the Desktop-only Appx module through Windows PowerShell compatibility when installing and cleaning owned packages from pwsh.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assert both invocation and disposal errors on all platforms without leaving the app's root service provider faulted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoid empty emulator console responses on macOS while preserving exact AVD identity checks and owned cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Release APK assembly stores and ReadyToRun both leave Assembly.Location empty. Use supported SDK fast deployment and IL loading while retaining Release optimization; document the loading-coverage difference.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reproduce a pre-existing native UI thread without inherited AsyncLocal state, then flow the caller's execution context without replacing the UI synchronization context.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…overage

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the retired Helix entrypoint deleted while migrating main's new visual-comparer project into the xUnit v3/MTP inventory.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
xUnit v3 now awaits fixture disposal; keep animation-manager teardown on the Android Looper instead of disposing its platform ticker on an MTP worker. Preserve the existing leak assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Exercise AnimationManager startup with an explicitly enabled platform ticker without changing system accessibility settings. Retain synchronous MTP logs when a native test exits before finalizing TRX.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore AppActions' launcher prerequisite and unregister test lifecycle listeners before their Java callbacks can be collected. Preserve all regression assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use xUnit v3 4.0.2 and coherent MTP 2.5.1 modules for existing theory display-name filters. Preserve sequential execution, timeouts and cancellation; align NUnit's bridge and attachment paths; keep native attributes out of the Appium host. Use OS-native child probes without changing shared build environment.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Collect fresh DiagnosticReports entries containing the job-owned simulator UUID, preserving evidence when the native app aborts before producing TRX.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 13:33 — with GitHub Actions Failure
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 13:33 — with GitHub Actions Failure
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

kubaflo and others added 3 commits November 27, 2026 21:21
The AppX deployment service ignores CurrentUser trust, so installing the
self-signed test package failed with 0x800B0109. Add only the public
certificate machine-wide (as the former Helix setup did); the private key
stays non-exportable in CurrentUser\My, and cleanup removes the owned
certificate from every store.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… is already disconnected

ShellView.Disconnect read the typed ShellItemHandler.PlatformView, which
throws once that handler is disconnected. It runs from Window.Closed, so
the exception terminated the process (0xDEAD), aborting the Controls
device-test run at SearchHandlerFocusTracksDetachment.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 20:22 — with GitHub Actions Failure
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 20:22 — with GitHub Actions Failure
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

kubaflo and others added 3 commits November 27, 2026 21:57
…uncher

The WinApp build tools replace RunCommand with 'winapp run', which tries
to register a development-mode package and fails because the owned
signed MSIX is already installed. Disable their run support for packaged
device tests so dotnet test uses MauiTestLauncherPath.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The Windows Controls suite now runs in one process (XHarness ran each
category in its own), and closed but uncollected test windows keep their
GDI objects until finalized; runs ended with 0xDEAD at ~8,000 GDI objects
after 350-600 tests. Collect and finalize when usage passes a threshold,
logging the counts before and after.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 20:57 — with GitHub Actions Failure
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 20:57 — with GitHub Actions Failure
kubaflo and others added 3 commits November 27, 2026 22:22
… out"

CI showed forced collections do not lower the GDI count (3033 -> 3162,
14525 -> 14601), and the host passed 10,000 GDI objects without crashing,
so this was not the cause.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
In one process the Windows Controls suite terminates with 0xDEAD at a
fixed point (CollectionView2 focus after 599 tests on main, NavigationPage
title icon after 346 on net11) in tests that pass in isolation, as they
did when cake/Helix ran one process per category. Restore that isolation:
build once, then run each category (and the uncategorized rest) with
--no-build, keeping one TRX per category and continuing after a failure.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 21:23 — with GitHub Actions Failure
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 21:23 — with GitHub Actions Failure
kubaflo and others added 2 commits November 27, 2026 22:53
The testing platform's controller exits 0xDEAD when its test host
crashes, and native fail-fast crashes produce neither a .NET crash dump
nor a managed exception. Register Windows Error Reporting local dumps
for the test executables (removed afterwards), and collect application
error events for the per-category test host PIDs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 21:54 — with GitHub Actions Failure
@kubaflo
kubaflo had a problem deploying to skill-evaluation-pat-pool November 27, 2026 21:54 — with GitHub Actions Failure
kubaflo added a commit that referenced this pull request Nov 28, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is test infrastructure for the .NET 12 (`main`) line, so it targets
`main`.

### Description of Change

Migrate all repository test execution from **Helix + XHarness** to plain
**`dotnet test`** on **Microsoft.Testing.Platform (MTP)**.

This PR carries the migration from #39918 (by @mattleibow, commits
preserved) brought up to date with current `main` (.NET 12 SDK, `/review
run-device-tests`, recent product and test fixes), plus the follow-up
fixes needed to make it build and pass on .NET 12.

#### Why we need this

- **One way to run tests, everywhere.** Today unit tests run through
Arcade's Helix SDK (`eng/helix.proj`), device tests through Helix +
XHarness (`eng/helix_xharness.proj`), Appium tests through Cake, and
locally through yet other scripts. After this change the same command —
`dotnet test --project <test project>` (plus `--device` for mobile) —
runs every suite on a developer machine, in CI, and in the Copilot
review gate. A CI failure can be reproduced locally with the exact
command CI used.
- **Remove a fragile, opaque layer.** Helix/XHarness add payload
zipping, remote queues, a job monitor, custom work-item scripts and a
separate result path. Many recurring device-test infra failures
(XHarness exit 78/80/83 `APP_LAUNCH_FAILURE`/`APP_CRASH`, Helix jobs
never scheduled, stale or missing `testResults.xml`, queue/image drift
such as XHarness requiring an iPhone 11 Pro device type that iOS 27.1+
no longer ships) come from that layer, not from MAUI. Direct execution
on the agent gives real logs, real exit codes and the actual device in
the job.
- **Genuine, trustworthy results.** Every suite now produces the test
framework's own TRX via MTP (`--report-trx`), and empty selections or
missing reports fail the job instead of silently passing. On Android/iOS
the native app's own TRX is collected and reconciled with the host
proxy, so a crash cannot be reported as a pass.
- **Modern test stack.** xUnit v2 + VSTest + XHarness test runners are
replaced by **xUnit v3 + MTP**, which is what the .NET SDK `dotnet test`
and device (`--device`) support is built on. This unblocks newer xUnit
features (`TestContext`, cancellation, `Assert.Skip*`) and keeps us on
the path the SDK supports directly.
- **Fewer moving parts to maintain.** Removes `eng/helix.proj`,
`eng/helix_xharness.proj`, the Helix pipeline stages, the XHarness CLI
tool, and the XHarness/Helix package dependencies.

#### What changes

- **Unit tests**: all repository xUnit suites move to xUnit v3 (`4.0.2`)
on MTP (`2.5.1`); `global.json` selects `Microsoft.Testing.Platform` as
the `dotnet test` runner. CI (`stage-unit-tests.yml`) runs each project
with `dotnet test --project … --report-trx` on Windows and macOS (Debug
and Release) and validates the TRX
(`eng/scripts/Assert-TestResults.ps1`). Helix unit-test stages are
removed.
- **Device tests** (Controls, Core, Graphics, Essentials,
BlazorWebView): the XHarness/visual runners are replaced by native MTP
hosts — Android instrumentation, the normal Apple MAUI app/scene
lifecycle, and an owned Windows MSIX/unpackaged launcher.
`maui-pr-devicetests` runs them directly on device-capable agents
(`stage-device-tests.yml`, `device-tests-steps.yml`) with job-owned
emulators/simulators.
- **UI tests (Appium)** stay on NUnit, now hosted on MTP with matching
fixture-failure, retry and attachment handling.
- **Integration tests** run with `dotnet test`; legacy `--filter`
selectors are translated to MTP filters. iOS template apps are launched
with `simctl` on a dedicated simulator instead of XHarness.
- **Local tooling** (`Run-DeviceTests.ps1`, Cake, review-gate scripts,
skills/instructions) updated to the same direct commands.

#### Changes made while bringing #39918 onto current `main`

- Merged `main` (.NET 12 move #40060, `/review run-device-tests` #40545,
review-gate removal #40595, and other fixes) and resolved 23 conflicts.
- **`/review run-device-tests` selection ported** to the direct
template: `ci-device-tests.yml` passes
`selectedRun`/`selectedPlatforms`/`selectedProjects`/`selectedFilters`,
and `stage-device-tests.yml` runs only the selected platforms and
projects with the selected category skip-lists. Verified with the AzDO
YAML preview API (full run: 28 jobs; a sample selection of Android+iOS /
Controls+Essentials with `SkipCategories=Shell,Label`: exactly 4 jobs
with that filter). `eng/helix_xharness.proj` is no longer a trusted
dispatch path.
- **Device tests default to `net12.0` and CoreCLR only** — the .NET 12
mobile workloads no longer provide Mono (same as #40060).
- Took main's Switch hover-resource fix (#40209) over the PR's earlier
variant; kept the HybridWebView asset-ownership change together with
main's `DynamicDependency`.
- Ported main's UI-test retry recovery rules (#40407) into the shared
`UITestRetry.cs` used by Cake and MTP.
- Dropped the XHarness-only simulator runtime selection
(`SelectLatestIOSVersion`) and its tests; runtime/device-type selection
is covered by `SimulatorTests`.

#### Fixes found by running CI / locally after the merge

- **xUnit v3 adaptation of tests added on `main`**:
`TestContext.Current.CancellationToken` (xUnit1051), source-info
constructor for `WindowsFact` (xUnit3003); `UITest.NUnit.Tests` and the
Windows launcher build for the repo TFM instead of `net11.0`.
- **Async-void / inline continuation differences in xUnit v3** (v2's
`AsyncTestSyncContext` hid them):
- `ListProxyTests.SynchronizedCollectionAdd` leaked thread-static
dispatcher options onto a thread-pool thread, so later tests got a
dispatcher that always required dispatch (68 Storyboard failures in
macOS Release). Restored after use; fixtures reset the options.
- Shell tests resumed inline from `Navigated`, so the *next* tests ran
inside Shell's navigation callback and had their implicit routes reset
(`DeferPopNavigation(Pop)`). Verified locally by detecting
`FireNavigatedEvents` on the next test's stack before/after the change.
- **Native runner thread affinity** (test bodies run on the thread pool,
not the UI thread as under XHarness):
`WillTerminateDestroysMainPageWindowOnce` resolved the `Application` off
the UI thread; the CarouselView leak test posted a UIKit notification
off the UI thread.
- **iOS simulator selection**: only use device types that the runtime
lists (device-specific iOS 27.1 builds only accept one, causing
`SimError 403 Incompatible device`), and prefer the iPhone 11 Pro
profile XHarness used (Shell flyout header geometry tests from #39877
fail on Dynamic Island phones; passes on iPhone 11 Pro, fails on iPhone
16 — reproduced locally).
- **Mac Catalyst**: `dotnet test` starts the app executable directly, so
unlike `open`/XHarness it isn't activated; activate it before running
(animated CarouselView scrolls intermittently never finished).
- **Integration tests**: shut down build servers after installing the
test workloads — reused MSBuild nodes kept a stale workload resolver and
nested `UseWorkload=true` sample builds failed with NU1015 (reproduced
locally; Samples macOS now passes in CI). The Android `maui-blazor` +
`TrimMode=full` row is skipped explicitly: the previous runner silently
dropped `TrimMode`, and Blazor does not support full trimming
(dotnet/aspnetcore#63951).
- **Windows `HybridWebView` disconnect** NRE when `CoreWebView2` is not
(or no longer) initialized — exposed by the new fixture teardown that
disconnects every handler.
- Docs spellcheck word, and a template boolean comparison so the device
stage doesn't expand to zero jobs.
- **UI-test retry reconciliation**: when a fixture's `OneTimeSetUp`
fails, NUnit reports its `[Ignore]`d tests as failed and the retry
reports them skipped. MTP's TRX names classes of fixtures with arguments
(every UI-test fixture, e.g. `EditorFeatureTests(Windows)`) by namespace
only, so the ignored tests were never matched as recovered and the job
failed although the retry passed. Replaying the real CI TRX/NUnit
reports reproduces the failure before the fix and merges cleanly after
it; `FixtureRecoveryReconcilesIgnoredTestsInParameterizedFixtures`
covers it.
- **iOS CarouselView test timing** (`Animated ScrollTo Does Not Report
Positions It Passes Over`, failed on every native CI run, passed under
Helix): with logging, every failing run showed a still-queued
initial-position pass scrolling back to page 0 without animation,
cancelling the test's animated `ScrollTo`. Under the native runner the
test can resume between those queued passes. The test now lets them
drain; full-class cold runs went from 2/9 failing to 5/5 passing, and it
passes in CI.
- **`main` build breaks from re-enabled CA1416** (#40663): carried the
fixes from #40708 (merged) and #40720
(`UISettings.AnimationsEnabledChanged` in `PlatformTicker` and
`MotionPolicy` requires Windows 10.0.19041). The Windows errors only
surfaced one project at a time because `Core` references `Essentials`.

### Validation

Local (macOS arm64, .NET SDK `12.0.100-alpha.1.26523.103`, Debug,
`dotnet test --project <csproj> --report-trx`):

| Project | Result |
| --- | --- |
| Controls.Xaml.UnitTests | 2,327 passed, 8 skipped |
| Controls.Core.UnitTests | 7,453 passed, 30 skipped |
| Controls.BindingSourceGen.UnitTests | 135 passed |
| SourceGen.UnitTests | 997 passed |
| Core.UnitTests | 1,147 passed |
| Resizetizer.UnitTests | 795 passed, 3 skipped |
| Essentials.UnitTests | 520 passed |
| Essentials.ExternalBackend.UnitTests | 6 passed |
| Graphics.Tests | 406 passed |
| VisualTestUtils.MagickNet.Tests | 13 passed |
| MauiBlazorWebView.UnitTests | 70 passed |
| MauiBlazorWebView.ExternalHandler.UnitTests | 52 passed |
| UITest.NUnit.Tests | 50 passed, 5 skipped |
| TestUtils.UnitTests | 61 passed, 1 skipped |

Pester (pipeline/runner scripts): `Direct-TestDevice`, `Cake-Mtp`,
`RunTests`, `NUnitMtp`, `XunitMtp`, `Run-DeviceTests`,
`WindowsTestPackage`, `Assert-TestResults`, `CopilotPipeline`,
`Review-PR`, `Verify-TestsFail`, `BuildAndRunHostApp`, `Review-Tests`,
`Recover-MissedReviewCommands`: 600+ passed. The only remaining failure
(`handles qualified selections in every stage guard`, expects 10 vs 11)
also fails on `main` and is unrelated.

Note:
`StoryboardTests.StoppingFromPropertyChangingDuringATakeoverRaisesOnePairOfNotifications`
(added on `main`) is culture-sensitive and fails under a comma-decimal
locale on `main` as well; it passes under `en-US` as in CI.

#### CI

Every pipeline was run with `/azp run` on this PR and on validation-only
drafts:
- #40703: this PR's changes on `net11`.
- #40705: the #40703 changes plus sample PRs #40696, #40660, #40654 and
#40691, to check that tests added by other PRs run under the native
runners.
- #40706: this PR plus sample PR #40669.

Failures were compared against `main`/`net11` Helix baselines by test
name.

| Pipeline | This PR (`main`) | `net11` validation (#40703 / #40705) |
| --- | --- | --- |
| `maui-pr` (build, pack, unit tests, integration) | ✅ 35/35 jobs (with
the CA1416 fixes) | ✅ 33/33 jobs |
| `maui-pr-devicetests` | ✅ Android, iOS, Mac Catalyst except
`PageTransitions` tests that fail identically in `main`'s Helix runs | ✅
Android, iOS, Mac Catalyst; only intermittent single-test failures that
don't repeat across runs |
| `maui-pr-uitests` (Appium on MTP) | ✅ 133/134 jobs; the only failure,
WinUI `SharedElementLandsAndSourceIsRestoredAfterPop`, also fails on
`main`'s Helix runs | ✅ 130/133; see below |

Remaining UI-test failures on `net11`, none of them regressions:
- `DragAndDropWithAnElementThatIsRemoved` (Mac Catalyst) fails in 2 of
the last 10 `net11` Helix runs too.
- The RefreshView tests failed only on #40705, which includes
RefreshView sample PR #40660.
- The `vlatest` shard failed because the agent couldn't download the iOS
18.5 simulator runtime.
- Material3 (API 36) screenshots in the last two runs came out 87 px
taller. #40603, merged on `net11` yesterday, now crops by the status-bar
height that Appium reports. The same tree and emulator setup passed
430/433 in the two previous runs.

**Known remaining device-test blockers (from #39918, not regressions of
this merge):** packaged Windows MSIX installation is rejected with
`0x800B0109` (the temporary signer is not a trusted root on the agent
image — needs owner-provided signing/provisioning), and the Windows
Controls unpackaged suite can terminate with `0xDEAD` after ~350 tests
(native composition resource exhaustion investigated in #39918).

### Issues Fixed

No product issue. Supersedes/continues #39918.

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 28, 2026
…[net11]

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is test infrastructure for the .NET 12 (`main`) line, so it targets
`main`.

Migrate all repository test execution from **Helix + XHarness** to plain
**`dotnet test`** on **Microsoft.Testing.Platform (MTP)**.

This PR carries the migration from #39918 (by @mattleibow, commits
preserved) brought up to date with current `main` (.NET 12 SDK, `/review
run-device-tests`, recent product and test fixes), plus the follow-up
fixes needed to make it build and pass on .NET 12.

- **One way to run tests, everywhere.** Today unit tests run through
Arcade's Helix SDK (`eng/helix.proj`), device tests through Helix +
XHarness (`eng/helix_xharness.proj`), Appium tests through Cake, and
locally through yet other scripts. After this change the same command —
`dotnet test --project <test project>` (plus `--device` for mobile) —
runs every suite on a developer machine, in CI, and in the Copilot
review gate. A CI failure can be reproduced locally with the exact
command CI used.
- **Remove a fragile, opaque layer.** Helix/XHarness add payload
zipping, remote queues, a job monitor, custom work-item scripts and a
separate result path. Many recurring device-test infra failures
(XHarness exit 78/80/83 `APP_LAUNCH_FAILURE`/`APP_CRASH`, Helix jobs
never scheduled, stale or missing `testResults.xml`, queue/image drift
such as XHarness requiring an iPhone 11 Pro device type that iOS 27.1+
no longer ships) come from that layer, not from MAUI. Direct execution
on the agent gives real logs, real exit codes and the actual device in
the job.
- **Genuine, trustworthy results.** Every suite now produces the test
framework's own TRX via MTP (`--report-trx`), and empty selections or
missing reports fail the job instead of silently passing. On Android/iOS
the native app's own TRX is collected and reconciled with the host
proxy, so a crash cannot be reported as a pass.
- **Modern test stack.** xUnit v2 + VSTest + XHarness test runners are
replaced by **xUnit v3 + MTP**, which is what the .NET SDK `dotnet test`
and device (`--device`) support is built on. This unblocks newer xUnit
features (`TestContext`, cancellation, `Assert.Skip*`) and keeps us on
the path the SDK supports directly.
- **Fewer moving parts to maintain.** Removes `eng/helix.proj`,
`eng/helix_xharness.proj`, the Helix pipeline stages, the XHarness CLI
tool, and the XHarness/Helix package dependencies.

- **Unit tests**: all repository xUnit suites move to xUnit v3 (`4.0.2`)
on MTP (`2.5.1`); `global.json` selects `Microsoft.Testing.Platform` as
the `dotnet test` runner. CI (`stage-unit-tests.yml`) runs each project
with `dotnet test --project … --report-trx` on Windows and macOS (Debug
and Release) and validates the TRX
(`eng/scripts/Assert-TestResults.ps1`). Helix unit-test stages are
removed.
- **Device tests** (Controls, Core, Graphics, Essentials,
BlazorWebView): the XHarness/visual runners are replaced by native MTP
hosts — Android instrumentation, the normal Apple MAUI app/scene
lifecycle, and an owned Windows MSIX/unpackaged launcher.
`maui-pr-devicetests` runs them directly on device-capable agents
(`stage-device-tests.yml`, `device-tests-steps.yml`) with job-owned
emulators/simulators.
- **UI tests (Appium)** stay on NUnit, now hosted on MTP with matching
fixture-failure, retry and attachment handling.
- **Integration tests** run with `dotnet test`; legacy `--filter`
selectors are translated to MTP filters. iOS template apps are launched
with `simctl` on a dedicated simulator instead of XHarness.
- **Local tooling** (`Run-DeviceTests.ps1`, Cake, review-gate scripts,
skills/instructions) updated to the same direct commands.

- Merged `main` (.NET 12 move #40060, `/review run-device-tests` #40545,
review-gate removal #40595, and other fixes) and resolved 23 conflicts.
- **`/review run-device-tests` selection ported** to the direct
template: `ci-device-tests.yml` passes
`selectedRun`/`selectedPlatforms`/`selectedProjects`/`selectedFilters`,
and `stage-device-tests.yml` runs only the selected platforms and
projects with the selected category skip-lists. Verified with the AzDO
YAML preview API (full run: 28 jobs; a sample selection of Android+iOS /
Controls+Essentials with `SkipCategories=Shell,Label`: exactly 4 jobs
with that filter). `eng/helix_xharness.proj` is no longer a trusted
dispatch path.
- **Device tests default to `net12.0` and CoreCLR only** — the .NET 12
mobile workloads no longer provide Mono (same as #40060).
- Took main's Switch hover-resource fix (#40209) over the PR's earlier
variant; kept the HybridWebView asset-ownership change together with
main's `DynamicDependency`.
- Ported main's UI-test retry recovery rules (#40407) into the shared
`UITestRetry.cs` used by Cake and MTP.
- Dropped the XHarness-only simulator runtime selection
(`SelectLatestIOSVersion`) and its tests; runtime/device-type selection
is covered by `SimulatorTests`.

- **xUnit v3 adaptation of tests added on `main`**:
`TestContext.Current.CancellationToken` (xUnit1051), source-info
constructor for `WindowsFact` (xUnit3003); `UITest.NUnit.Tests` and the
Windows launcher build for the repo TFM instead of `net11.0`.
- **Async-void / inline continuation differences in xUnit v3** (v2's
`AsyncTestSyncContext` hid them):
- `ListProxyTests.SynchronizedCollectionAdd` leaked thread-static
dispatcher options onto a thread-pool thread, so later tests got a
dispatcher that always required dispatch (68 Storyboard failures in
macOS Release). Restored after use; fixtures reset the options.
- Shell tests resumed inline from `Navigated`, so the *next* tests ran
inside Shell's navigation callback and had their implicit routes reset
(`DeferPopNavigation(Pop)`). Verified locally by detecting
`FireNavigatedEvents` on the next test's stack before/after the change.
- **Native runner thread affinity** (test bodies run on the thread pool,
not the UI thread as under XHarness):
`WillTerminateDestroysMainPageWindowOnce` resolved the `Application` off
the UI thread; the CarouselView leak test posted a UIKit notification
off the UI thread.
- **iOS simulator selection**: only use device types that the runtime
lists (device-specific iOS 27.1 builds only accept one, causing
`SimError 403 Incompatible device`), and prefer the iPhone 11 Pro
profile XHarness used (Shell flyout header geometry tests from #39877
fail on Dynamic Island phones; passes on iPhone 11 Pro, fails on iPhone
16 — reproduced locally).
- **Mac Catalyst**: `dotnet test` starts the app executable directly, so
unlike `open`/XHarness it isn't activated; activate it before running
(animated CarouselView scrolls intermittently never finished).
- **Integration tests**: shut down build servers after installing the
test workloads — reused MSBuild nodes kept a stale workload resolver and
nested `UseWorkload=true` sample builds failed with NU1015 (reproduced
locally; Samples macOS now passes in CI). The Android `maui-blazor` +
`TrimMode=full` row is skipped explicitly: the previous runner silently
dropped `TrimMode`, and Blazor does not support full trimming
(dotnet/aspnetcore#63951).
- **Windows `HybridWebView` disconnect** NRE when `CoreWebView2` is not
(or no longer) initialized — exposed by the new fixture teardown that
disconnects every handler.
- Docs spellcheck word, and a template boolean comparison so the device
stage doesn't expand to zero jobs.
- **UI-test retry reconciliation**: when a fixture's `OneTimeSetUp`
fails, NUnit reports its `[Ignore]`d tests as failed and the retry
reports them skipped. MTP's TRX names classes of fixtures with arguments
(every UI-test fixture, e.g. `EditorFeatureTests(Windows)`) by namespace
only, so the ignored tests were never matched as recovered and the job
failed although the retry passed. Replaying the real CI TRX/NUnit
reports reproduces the failure before the fix and merges cleanly after
it; `FixtureRecoveryReconcilesIgnoredTestsInParameterizedFixtures`
covers it.
- **iOS CarouselView test timing** (`Animated ScrollTo Does Not Report
Positions It Passes Over`, failed on every native CI run, passed under
Helix): with logging, every failing run showed a still-queued
initial-position pass scrolling back to page 0 without animation,
cancelling the test's animated `ScrollTo`. Under the native runner the
test can resume between those queued passes. The test now lets them
drain; full-class cold runs went from 2/9 failing to 5/5 passing, and it
passes in CI.
- **`main` build breaks from re-enabled CA1416** (#40663): carried the
fixes from #40708 (merged) and #40720
(`UISettings.AnimationsEnabledChanged` in `PlatformTicker` and
`MotionPolicy` requires Windows 10.0.19041). The Windows errors only
surfaced one project at a time because `Core` references `Essentials`.

Local (macOS arm64, .NET SDK `12.0.100-alpha.1.26523.103`, Debug,
`dotnet test --project <csproj> --report-trx`):

| Project | Result |
| --- | --- |
| Controls.Xaml.UnitTests | 2,327 passed, 8 skipped |
| Controls.Core.UnitTests | 7,453 passed, 30 skipped |
| Controls.BindingSourceGen.UnitTests | 135 passed |
| SourceGen.UnitTests | 997 passed |
| Core.UnitTests | 1,147 passed |
| Resizetizer.UnitTests | 795 passed, 3 skipped |
| Essentials.UnitTests | 520 passed |
| Essentials.ExternalBackend.UnitTests | 6 passed |
| Graphics.Tests | 406 passed |
| VisualTestUtils.MagickNet.Tests | 13 passed |
| MauiBlazorWebView.UnitTests | 70 passed |
| MauiBlazorWebView.ExternalHandler.UnitTests | 52 passed |
| UITest.NUnit.Tests | 50 passed, 5 skipped |
| TestUtils.UnitTests | 61 passed, 1 skipped |

Pester (pipeline/runner scripts): `Direct-TestDevice`, `Cake-Mtp`,
`RunTests`, `NUnitMtp`, `XunitMtp`, `Run-DeviceTests`,
`WindowsTestPackage`, `Assert-TestResults`, `CopilotPipeline`,
`Review-PR`, `Verify-TestsFail`, `BuildAndRunHostApp`, `Review-Tests`,
`Recover-MissedReviewCommands`: 600+ passed. The only remaining failure
(`handles qualified selections in every stage guard`, expects 10 vs 11)
also fails on `main` and is unrelated.

Note:
`StoryboardTests.StoppingFromPropertyChangingDuringATakeoverRaisesOnePairOfNotifications`
(added on `main`) is culture-sensitive and fails under a comma-decimal
locale on `main` as well; it passes under `en-US` as in CI.

Every pipeline was run with `/azp run` on this PR and on validation-only
drafts:
- #40703: this PR's changes on `net11`.
- #40705: the #40703 changes plus sample PRs #40696, #40660, #40654 and
runners.
- #40706: this PR plus sample PR #40669.

Failures were compared against `main`/`net11` Helix baselines by test
name.

| Pipeline | This PR (`main`) | `net11` validation (#40703 / #40705) |
| --- | --- | --- |
| `maui-pr` (build, pack, unit tests, integration) | ✅ 35/35 jobs (with
the CA1416 fixes) | ✅ 33/33 jobs |
| `maui-pr-devicetests` | ✅ Android, iOS, Mac Catalyst except
`PageTransitions` tests that fail identically in `main`'s Helix runs | ✅
Android, iOS, Mac Catalyst; only intermittent single-test failures that
don't repeat across runs |
| `maui-pr-uitests` (Appium on MTP) | ✅ 133/134 jobs; the only failure,
WinUI `SharedElementLandsAndSourceIsRestoredAfterPop`, also fails on
`main`'s Helix runs | ✅ 130/133; see below |

Remaining UI-test failures on `net11`, none of them regressions:
- `DragAndDropWithAnElementThatIsRemoved` (Mac Catalyst) fails in 2 of
the last 10 `net11` Helix runs too.
- The RefreshView tests failed only on #40705, which includes
RefreshView sample PR #40660.
- The `vlatest` shard failed because the agent couldn't download the iOS
18.5 simulator runtime.
- Material3 (API 36) screenshots in the last two runs came out 87 px
taller. #40603, merged on `net11` yesterday, now crops by the status-bar
height that Appium reports. The same tree and emulator setup passed
430/433 in the two previous runs.

**Known remaining device-test blockers (from #39918, not regressions of
this merge):** packaged Windows MSIX installation is rejected with
`0x800B0109` (the temporary signer is not a trusted root on the agent
image — needs owner-provided signing/provisioning), and the Windows
Controls unpackaged suite can terminate with `0xDEAD` after ~350 tests
(native composition resource exhaustion investigated in #39918).

No product issue. Supersedes/continues #39918.

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit b5108cd)

net11 adaptation: net11.0 TFM, CoreCLR + Mono device-test runtimes and net11's Arcade SDK version, matching validation PR #40703. SourceGen tests for .NET 12-only features are not brought over.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

kubaflo commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Validation-only PR; the migration landed in #40661, so closing.

@kubaflo kubaflo closed this Nov 28, 2026

This branch had an error being deployed

1 failed and 1 inactive (outdated) deployments
skill-evaluation-pat-pool — e0131933 Deployed Nov 27, 2026 by kubaflo via Harness hermeticity gate #38959
copilot-pat-pool — a0da067f Deployed Nov 27, 2026 by kubaflo via conclusion #3398
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants