Consume the WinUI Gallery published sample index - #895
Conversation
Replace the Gallery scraper with the published sample index, preserve pasteability normalization, surface Gallery xmlns imports, and re-bake the embedded corpus. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 034ffdc8-3308-4286-96d8-e02406110630
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 7794 passed, 37 skipped out of 7831 tests in 1224.8s (+7 tests, -4.2s vs. baseline) Test Coverage✅ 86% line coverage, 80.7% branch coverage · ✅ +0.4% vs. baseline CLI Startup Time63ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 895Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 895Run Updated 2026-09-22 17:40:17 UTC · commit |
Resolve conflicts between the sample-index rewrite and main's no-truncation change: - GalleryFetcher.cs: deleted (replaced by SampleIndexFetcher/GalleryProvider); main's truncation removal there is moot. - ControlSnippetText.cs: take main's CloseUnbalancedTags; drop the GalleryFetcher cref now that the gallery path is GalleryProvider. - CacheVersion: main shipped `23` for the no-truncation bake, so the sample-index entry becomes `24`. - Re-baked the embedded corpus at cache version 24. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Gallery output still exposes private namespaces and asset paths that break pasted samples.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Replaces Gallery scraping with the shared published-index pipeline while preserving searchable, pasteable find-ui results.
Changes:
- Adds shared Gallery/Reactor index fetching and removes
GalleryFetcher. - Adds Gallery normalization, namespace rendering, and corpus validation.
- Rebakes the Gallery snapshot and increments cache version.
| File | Description |
|---|---|
SearchEngine.cs |
Renders Gallery XAML namespace setup. |
SampleIndexFetcher.cs |
Adds shared index downloading. |
ReactorFetcher.cs |
Uses the shared fetcher. |
GalleryProvider.cs |
Parses, enriches, and normalizes Gallery samples. |
GalleryFetcher.cs |
Removes the legacy scraper. |
snapshot-gallery.json.br |
Rebakes Gallery corpus data. |
snapshot-manifest.json |
Updates corpus counts and version. |
ControlSnippetText.cs |
Updates provider references. |
CacheVersion.cs |
Invalidates pre-index caches. |
GalleryFetcherCleanContentTests.cs |
Removes obsolete scraper tests. |
FindUiSearchTests.cs |
Removes scraper-specific normalization tests. |
EmbeddedSnapshotTests.cs |
Adds Gallery corpus safeguards. |
find-ui-corpus-check.yml |
Watches shared index components. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Address two review findings on the sample-index port. The index publishes Gallery's source verbatim, and NormalizeForPaste only covered part of what that carries: - 20 scenarios still named a Gallery CLR namespace. 16 of them in the index's xmlnsImports field, which SearchEngine renders as the "Setup:" line -- so we printed `xmlns:local="using:WinUIGallery.ControlPages"` as an instruction to declare a prefix that cannot resolve. tabview-2 was inconsistent with itself: the type was already rewritten to <samplepages:YourPage />, but the prefix it used still mapped to WinUIGallery.SamplePages. - 41 scenarios pointed at assets that exist only in Gallery's package -- 32 under Assets/SampleMedia, 9 under Assets/Tiles. Those compile and then render nothing: a silently blank Image, an AppWindow.SetIcon that quietly does not take. The scraper rewrote SampleMedia (one URI form of three, so 17 of the 32); dropping it was a regression, and Tiles was never covered at all. Rewrites are environment only -- identifiers and paths that resolve against Gallery's own assembly and package. The sample still teaches what upstream wrote. Asset rewrites preserve the URI form, because AppWindow.SetIcon takes a package-relative path rather than a ms-appx URI, and preserve the extension, because a MediaPlayerElement pointed at a .png is a different kind of broken. Guards: the corpus check now covers xmlnsImports and Gallery-only asset paths, and GalleryProviderNormalizeTests pins the transform hermetically -- a corpus guard alone passes vacuously the day upstream stops shipping the thing being rewritten. Cache version 24 is unreleased, so its history entry is amended rather than superseded. Corpus re-baked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 883032eb-8c56-4340-b3d7-4c38bb1916b8
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Gallery output still contains unbacked event attributes that make several emitted XAML samples fail when pasted.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1


Description
Replaces the WinUI Gallery scraper with the machine-readable sample index now published by microsoft/WinUI-Gallery#2232 at
catalog/windows-samples.json.The old path reconstructed the corpus by downloading Gallery metadata and hundreds of individual source files. This change consumes the upstream index in one request and deletes
GalleryFetcher.csentirely. A sharedSampleIndexFetchernow handles the Gallery and Reactor indexes.The published index contains Gallery source verbatim, so
GalleryProviderpreserves the pasteability normalization users relied on: Gallery-private page types and namespaces become app-local placeholders, calls to Gallery's internalUIHelperare removed, and XAML event attributes are retained only when the emitted C# defines the handler. Samples remain complete rather than being truncated;find-uiretrieves one selected sample at a time, and measurement showed recovering a truncated sample costs more tokens than serving it whole.Gallery
xmlnsImportsare now rendered in the**Setup:**line instead of being discarded by the Toolkit-only formatter gate.Usage Example
The selected sample now includes the namespace declaration published by Gallery:
A cold corpus refresh fetches the Gallery index once rather than making up to 433 requests.
Related Issue
Closes: #809
Upstream index: microsoft/WinUI-Gallery#2232
Depends on the index-consumption foundation from #852.
Type of Change
Checklist
Additional Notes
Before → after:
The three removed scenarios are upstream omissions rather than parser loss. Search enrichment preserves exact tag parity across all 127 controls represented by the shared Gallery tag data.
Validation:
scripts/build-cli.ps1 -SkipTestscompleted successfully, including NativeAOT, npm, NuGet, and MSIX packaging.The full CLI suite was not used as the local signal because unrelated network/UI-dependent tests block on this machine; PR CI remains the complete repository gate.
AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.