Skip to content

feat(samples): host theme apps in a Toolkit wrapper - #1654

Merged
kazo0 merged 6 commits into
mainfrom
dev/ks/toolkit-sample-wrapper
Sep 29, 2026
Merged

kazo0 merged 6 commits into
mainfrom
dev/ks/toolkit-sample-wrapper

Conversation

@kazo0

@kazo0 kazo0 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

PR previews and main deployments currently publish only the Simple sample. This change deploys a Toolkit wrapper that hosts Material, Cupertino, and Simple using the same secondary-AssemblyLoadContext pattern as Uno Themes.

PR Type

  • Feature
  • Build or CI related changes
  • Documentation content changes

What is the new behavior?

  • Add a theme picker with reload/unload and ?app=material|cupertino|simple deep links.
  • Give each guest its own application instance and isolate Toolkit/theme assemblies while sharing the Uno runtime.
  • Clear framework caches that retain guest types and finish Release desktop collection before loading another theme, preventing stale binding resolution (related to XAML attached-property binding paths read null once a second ALC has loaded the owner assembly uno#24581).
  • Build all WASM guest heads and package their assemblies, fonts, and images in the wrapper deployment. Missing guest payloads fail packaging.
  • Preserve standalone sample artifacts for existing runtime tests, add the wrapper to both solutions, and add a strict desktop hosting smoke job.

The wrapper remains untrimmed because its guest assemblies load dynamically. No new package dependencies or framework/version changes are introduced.

Validation

  • Release desktop build: passed; final incremental build had 0 warnings/errors. Full sample compilation emitted warnings.
  • Release WASM guest builds and wrapper publish: passed. Guests emitted 103/102/102 warnings; wrapper publish emitted none.
  • Strict Release desktop hosting smoke: passed twice locally and in Linux CI build 236394, with normal runtime settings and unchanged reclamation assertions.
  • Final published browser hosting smoke: passed for all themes, reload/unload, missing guest, and cancellation. Material deep-link rendering was also checked.
  • Material runtime suite: 361 passed, 11 skipped, 0 failed locally; Linux CI validated 372 runtime cases and the separate hot-reload job validated 48 cases.
  • Workflow actionlint, Azure YAML parsing, shell syntax, and diff checks: passed. Missing guest packaging failed as expected.

CI and limitations

  • The desktop reclamation failure is fixed in c3e2179c and verified on macOS and Linux CI. The full CI run on final commit d7932b7e (236398), CodeQL, and preview deployment passed. The deployed browser smoke also passed after the functional fix. The strict assertions remain enabled.
  • WASM collection remains diagnostic, matching the reference host; a browser pass does not prove memory reclamation.
  • A warning-free full Release build remains outstanding.

Details and reproduction commands: validation notes.

PR Checklist

Port the Uno Themes isolated app host and deploy the combined WASM site for PR previews and main. Preserve standalone sample artifacts and add hosting smoke coverage.

Desktop ALC reclamation still fails on macOS; record this limitation and the successful browser/runtime validation for draft review.
@kazo0
kazo0 marked this pull request as ready for review September 29, 2026 18:51
Copilot AI balanced review requested due to automatic review settings September 29, 2026 18:51

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.

Copilot review overview

🔵 Needs a closer look

It introduces intricate collectible-ALC hosting, reflection-based runtime-cache sweeps, and custom MSBuild/CI packaging with self-acknowledged unresolved blockers (desktop ALC reclamation failing under the strict smoke gate, no linked issue), all of which require human judgment.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

This PR adds a new sample-app host, Uno.Toolkit.Samples.Wrapper (ToolkitSampleApp), that runs the existing Material, Cupertino, and Simple sample apps in-process inside collectible secondary AssemblyLoadContexts, porting the Uno Themes ALC-wrapper pattern. It replaces the "Simple-only" PR preview/main deployment with a single host exposing a theme picker (reload/unload plus ?app= deep links), while preserving the standalone sample heads used by runtime tests. The guest apps are adapted so each keeps its own App.Instance and finishes launch synchronously, so they behave correctly when Application.Current belongs to the wrapper.

Changes:

  • New wrapper app: guest catalog, deep links, collectible-ALC loader (desktop/WASM/sweeps partials), reflection-based per-ALC cache cleanup, and a self-driving hosting smoke test with strict Release-desktop reclamation assertions.
  • Guest adaptation: App.Instance now uses a private static instead of Current as App, OnLaunched is synchronous, UnoEnableAlcAppSupport=true, and shared-project call sites use App.Instance.
  • Build/CI: custom MSBuild targets to package guest WASM payloads/fonts, a build-wasm-guest-heads.sh script, WASM/desktop pipeline jobs (incl. a desktop hosting smoke), the static-web-app deploy switch, both solutions, README, and validation notes.
File Description
samples/​Uno.Toolkit.Samples.Wrapper/​ToolkitSampleApp.csproj Wrapper project: TFM overrides, untrimmed publish, guest payload/font packaging targets.
.../​GuestHosting/​GuestAppLoader*.cs Core loader + desktop/WASM/sweeps partials for boot/teardown/collection.
.../​GuestHosting/​GuestAssemblyLoadContext.cs Collectible ALC with share-vs-isolate resolution.
.../​GuestHosting/​GuestSharedAssemblies.txt Single-source share/isolate rules (runtime + build).
.../​GuestHosting/​GuestHostingSmoke.cs, GuestAppDeepLink.cs, GuestAppCatalog.cs Smoke harness, launch selectors, hostable-app catalog.
.../​MainPage.xaml(.cs), App.xaml(.cs), Platforms/​*, app.manifest, Properties/​launchSettings.json Wrapper UI, app, platform heads, manifests.
samples/​Uno.Toolkit.Samples.{Material,Cupertino,Simple}/​App.xaml.cs + .csproj App.Instance rework, synchronous launch, ALC support flag.
samples/​Uno.Toolkit.Samples/​{Shell,Controls/​OverviewSampleView,Content/​Controls/​SeedColorSamplePage} Shared call sites switched to App.Instance.
build/​workflow/​*.yml, build/​workflow/​scripts/​build-wasm-guest-heads.sh, .github/​workflows/​azure-static-webapp.yml Guest-head builds, desktop hosting-smoke job, deploy target switch.
src/​Uno.Toolkit.sln, samples/​Uno.Toolkit.Samples.sln Register the wrapper with guest build-ordering dependencies.
README.md, specs/​toolkit-wrapper/​progress.md Usage docs and validation notes.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

1 similar comment
@github-actions

Copy link
Copy Markdown

@kazo0
kazo0 enabled auto-merge (squash) September 29, 2026 19:50
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@mergify

mergify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@kazo0
kazo0 merged commit dfa8b63 into main Sep 29, 2026
26 checks passed
@kazo0
kazo0 deleted the dev/ks/toolkit-sample-wrapper branch September 29, 2026 20:30
@kazo0

kazo0 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport servicing/10.0

@mergify

mergify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

backport servicing/10.0

✅ Backports have been created

Details

Cherry-pick of dfa8b63 has failed:

On branch mergify/bp/servicing/10.0/pr-1654
Your branch is up to date with 'origin/servicing/10.0'.

You are currently cherry-picking commit dfa8b63.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   .github/workflows/azure-static-webapp.yml
	modified:   README.md
	new file:   build/workflow/scripts/build-wasm-guest-heads.sh
	modified:   build/workflow/stage-build-desktop.yml
	modified:   build/workflow/stage-build-wasm.yml
	modified:   samples/Uno.Toolkit.Samples.Cupertino/CupertinoSampleApp.csproj
	modified:   samples/Uno.Toolkit.Samples.Material/MaterialSampleApp.csproj
	modified:   samples/Uno.Toolkit.Samples.Simple/SimpleSampleApp.csproj
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/App.xaml
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/App.xaml.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppCatalog.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppDeepLink.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppLoader.Desktop.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppLoader.Sweeps.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppLoader.Wasm.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAppLoader.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestAssemblyLoadContext.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestHostingSmoke.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/GuestHosting/GuestSharedAssemblies.txt
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/MainPage.xaml
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/MainPage.xaml.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/Desktop/Program.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/WebAssembly/LinkerConfig.xml
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/WebAssembly/Program.cs
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/WebAssembly/WasmScripts/AppManifest.js
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/WebAssembly/manifest.webmanifest
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Platforms/WebAssembly/wwwroot/staticwebapp.config.json
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/Properties/launchSettings.json
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/ToolkitSampleApp.csproj
	new file:   samples/Uno.Toolkit.Samples.ThemeWrapper/app.manifest
	modified:   samples/Uno.Toolkit.Samples.sln
	modified:   samples/Uno.Toolkit.Samples/Content/Controls/SeedColorSamplePage.xaml.cs
	modified:   samples/Uno.Toolkit.Samples/Controls/OverviewSampleView.cs
	modified:   samples/Uno.Toolkit.Samples/Shell.xaml.cs
	new file:   specs/toolkit-wrapper/progress.md
	modified:   src/Uno.Toolkit.sln

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   samples/Uno.Toolkit.Samples.Cupertino/App.xaml.cs
	both modified:   samples/Uno.Toolkit.Samples.Material/App.xaml.cs
	both modified:   samples/Uno.Toolkit.Samples.Simple/App.xaml.cs
	both modified:   specs/lessons.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

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.

3 participants