Export WinUI Gallery samples as a catalog/windows-samples.json manifest - #2226
Draft
Niels Laute (niels9001) wants to merge 1 commit into
Draft
Export WinUI Gallery samples as a catalog/windows-samples.json manifest#2226Niels Laute (niels9001) wants to merge 1 commit into
Niels Laute (niels9001) wants to merge 1 commit into
Conversation
- Add tools/CatalogExporter: a small, platform-agnostic console tool/library that derives a machine-readable manifest from the existing WinUIGallery/SampleSupport/Data/ControlInfoData.json source of truth plus the on-disk WinUIGallery/Samples/<UniqueId>/ folders, validates it (unique ids, case-exact referenced paths, resolvable RelatedControls / Catalog.RelatedSamples references, existing SampleDefinition snippets), and serializes it deterministically. - Generate catalog/windows-samples.json (120 samples) plus catalog/windows-samples.schema.json (JSON Schema contract) and catalog/README.md (design rationale + regeneration/check instructions). - Extend ControlInfoDataSchema.json with an optional, additive Catalog override block (Exclude/Aliases/RelatedSamples), demonstrated on the Button and ScratchPad entries in ControlInfoData.json. Everything else is derived, so no per-item sample.yml duplication is introduced. - Add tests/WinUIGallery.CatalogExporter.Tests (plain MSTest, no WinUI dependency) covering normalization, determinism, path/reference validation, and stale-output detection against the real repository data. - Wire both new projects into WinUIGallery.slnx and add a fast 'dotnet test' step to azure-pipelines.yml so a stale manifest fails CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
microsoft/windows-samplesaggregates standalone projects via oneSamples/<Name>/sample.ymleach, generating
catalog/samples.jsonfor agents and a browser gallery. WinUI Gallery's ~120samples are different: they're pages embedded in one app
(
WinUIGallery/Samples/<UniqueId>/), and an authoritative inventory of them already exists atWinUIGallery/SampleSupport/Data/ControlInfoData.json(consumed today by the app itself and by
WinUIGallery.SourceGenerator).This PR makes that existing inventory exportable into a future federated
windows-samplescatalog without creating ~120 duplicate
sample.ymlfiles.ControlInfoData.jsonstays thesingle source of truth; a small generator derives and validates everything else.
What's here
tools/CatalogExporter– a plain, platform-agnostic (no WinUI/Windows App SDK) consoletool + library that:
ControlInfoData.json(Title,Subtitle/Description,Docs,Tags,RelatedControls– all already present in the JSON/schema) and theWinUIGallery/Samples/<UniqueId>/folders.controls:ControlExampleelement with aSampleDefinition="..."snippet reference).<UniqueId>Page.xamlper item, resolvableRelatedControls/Catalog.RelatedSamplesreferences, and existingSampleDefinitionsnippets — failing loudly (
CatalogValidationException) instead of guessing.nullinstead of[]/""for anything with no source data).
dotnet run --project tools/CatalogExporter -- generateregenerates the manifest;... -- checkverifies it without writing anything (used in CI).catalog/windows-samples.json– the generated manifest (120 samples), pluscatalog/windows-samples.schema.json(JSON Schema draft-07 contract) andcatalog/README.md(design rationale, field mapping table, inclusion/exclusion rules,regeneration instructions).
Catalogoverride block added toControlInfoDataSchema.json(
Exclude/Aliases/RelatedSamples) for the rare item that needs to diverge from what'sauto-derived. Demonstrated (not invented) on two real entries:
ButtonandScratchPadeachget
Catalog.AliasesinControlInfoData.json. This block is read only by the exporter — therunning app is unaffected.
tests/WinUIGallery.CatalogExporter.Tests– plain MSTest (no WinUI dependency, so it runswith a plain
dotnet test, unlike the packagedWinUIGallery.UnitTests/UITests) covering:normalization (optional fields omitted, not guessed), determinism, duplicate-id detection,
missing-folder detection, case-mismatch detection, broken related-reference detection, missing
snippet detection,
Catalog.Exclude,Catalog.Aliases/RelatedSamplesmerging, and — againstthe real repository data — that the committed manifest is not stale.
WinUIGallery.slnx, and.pipelines/azure-pipelines.ymlgained one fast
dotnet teststep so a stale/hand-edited manifest fails CI.Design choices
repository.defaultBranch, not a hash, and isregenerated whenever samples change.
defaultscarry the facts shared by every entry (MIT, C#, WinUI 3, WindowsApp SDK,
embedded-gallery-pagekind) instead of repeating them ~120 times."{owner}/{repo}#{uniqueId}") so aggregation across repositories inwindows-samplescan't collide.Validation
No changes to the running app's behavior;
ControlInfoDataSchema.json's newCatalogblock isadditive and ignored by the app today (mirroring how
RelatedControlsalready sits unused in theschema/JSON).
Opened as draft: a follow-up PR in
microsoft/windows-sampleswill import this manifest into itsown
catalog/samples.jsonaggregation.