Skip to content

Integrate the WinUI 3 XAML language service into the winapp extension - #50

Closed
Nikola Metulev (nmetulev) wants to merge 106 commits into
mainfrom
nmetulev/winui
Closed

Nikola Metulev (nmetulev) wants to merge 106 commits into
mainfrom
nmetulev/winui

Conversation

@nmetulev

@nmetulev Nikola Metulev (nmetulev) commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Description

Integrates the WinUI 3 XAML language service into the shipping winapp VS Code extension as a single additive extension experience. Existing CLI commands, debugging, AppxManifest editing, and the new manifest IntelliSense from main remain intact.

What lands:

  • LSP client module (src/xaml/) with lazy XAML activation, serialized start/stop/restart lifecycle, workspace-trust gating, automatic settings restarts, and actionable degraded-mode notifications.
  • .NET LSP server (server/) providing completion, hover, definition, diagnostics, references, rename, code actions, formatting, semantic tokens, folding, links, and project-aware Roslyn/MSBuild features.
  • Framework-dependent delivery. The VSIX bundles the server assemblies and BuildHost-netcore, but no .NET runtime and no apphost — scripts/validate-vsix-server.ps1 fails the build if either appears.
  • Runtime acquired through the .NET Install Tool. The extension does not probe for .NET itself. It calls dotnet.findPath on ms-dotnettools.vscode-dotnet-runtime — the same component the C# extension and C# Dev Kit use — pinned to 10.0 with versionSpecRequirement: "equal" so any 10.0.x is accepted. The Install Tool is deliberately not an extensionDependencies entry (that would install it for every WinApp user); it is installed silently on demand the first time a XAML file is opened in a trusted workspace.
  • Signed release artifact flow: local development publishes from source with dotnet publish; CI/release builds the server once, signs it, downloads the signed artifact, and packages without unsigned fallback.
  • Language contributions for XAML syntax highlighting and editing configuration.
  • CI and release validation covering server tests, ARM64, LSP smoke, integration tests, VSIX payload validation, and marketplace publication gated on signing.

Usage Example

Opening any .xaml file in a trusted workspace activates the language service. There is nothing to configure: the winui-xaml.server.path and winui-xaml.server.dotnetPath settings were removed in this PR, and the .NET runtime is resolved through the Install Tool. The WINUI_XAML_SERVER_PATH environment variable remains, for development and integration testing only.

Commands: WinUI XAML: Show Info and WinUI XAML: Restart Language Server.

Prerequisites

  • Running the server: .NET 10 runtime, acquired automatically via the Install Tool. No user action required.
  • Project-aware IntelliSense: a machine .NET SDK, because MSBuild comes from the SDK toolset rather than from the runtime hosting the server. Without one, the server still starts and the tolerant parser still reports syntax diagnostics, but no type information is available.

Related issues

Closes #215 (in-flight project loads can cache a pre-invalidation graph). Invalidate could only test completed cache entries with ContainsProject, so an invalidation arriving while another root's load was in flight was dropped and that root was cached with a pre-invalidation graph. Pending entries now record the invalidated key and re-test it against the graph on completion, self-evicting if it is present. The issue also asked that eviction not dispose a workspace an active resolve is still reading; testing that premise showed it is not a live hazard, because every RoslynProjectWorkspace read goes through the immutable Roslyn Project snapshot captured at load time. A test pins that so it cannot silently regress.

Closes #220 (Go to Definition should never block on a project load). GoToDefinitionAsync now runs inside WithoutBlockingOnProjectLoadAsync, which gates GetContextAsync on an AsyncLocal so a definition request takes whatever context is already loaded, kicks off the shared warm-up, and returns immediately instead of queuing behind a cold MSBuild design-time build. Hover and every other handler are unaffected because the flag defaults to false. Regression coverage lives in server/test/lsp-smoke/smoke.mjs, which asserts a cold F12 returns no result in under a second.

Closes #213 (extract a shared dismissible-notification helper). The persisted globalState get/update pair behind a Don't Show Again action was inlined at four sites; notificationDismissal(key, store) now owns it and both the C# Dev Kit recommendation and the missing-runtime warning route through it. Scoped to the dismissal flag rather than the whole notification: the degraded warning carries a multi-action model and suppresses on cause transitions, and projectRestoreNotification has no persisted dismissal at all, so a shared presentation helper would have been indirection without deduplication.

Closes #214 (bound Content-Length and header sizes in JsonRpcConnection). ReadMessageAsync allocated new byte[contentLength] straight from the header with no cap, and the header reader bounded neither line length nor total block size. Adds 32 MB body, 8 KB header-line, and 64 KB header-block limits, and treats an unparsable or negative Content-Length as a protocol error instead of letting int.TryParse's 0 overwrite the sentinel and frame an empty body. Not a defense against a hostile peer, since the extension host is the only writer on this stdio pipe; the value is failing fast on a truncated frame instead of an OutOfMemoryException.

Closes #209 (show color swatches for named colors). The color provider recognized only hex literals, so Fill="CornflowerBlue" got no swatch and no picker. Named colors now resolve to their exact ARGB. The issue assumed this needed a build-time hex import from WinAppSDK source; it does not. System.Drawing.Color.FromName agrees with the WinUI parser on every name, Transparent's zero alpha included, so no hardcoded table was added. Validity still comes from GetNamedColors(), never from FromName, which also resolves .NET system colors (Control, Desktop, ActiveBorder, Highlight) that WinUI lacks and that throw XamlParseException at runtime — gating on it would paint swatches on markup that crashes the app. Presentations also preserve the user's spelling, so picking a color over Red no longer silently rewrites it to #FFFF0000.

Closes #115 (integration tests for the XAML language client/extension wiring). Four of the five flows the issue lists are covered by real extension-host tests in test/xaml-integration/client.test.js: command registration (winui-xaml.restartServer, winui-xaml.showInfo), the restart command's stop/start cycle, the winapp.xaml.intelliSense.enable toggle stopping and restarting the client (asserted by the semantic capability disappearing and returning, not just by the setting flipping), and three startup-failure recovery paths (missing server DLL, no .NET 10 runtime, untrusted workspace). Lifecycle serialization is covered both at the unit level in xaml-server-lifecycle.test.ts and end-to-end by the rapid back-to-back restart test. The issue's symbol names predate the rename to activateXaml / deactivateXaml and winui-xaml.restartServer. Not covered: deactivateXaml as a composition. It is two lines, lifecycle.beginDisposal() (unit-tested) followed by stopClient(), and the LSP shutdown/exit handshake is exercised in the smoke test; a direct test would have to tear the server down inside the shared extension host and break every test after it, which is not worth the marginal coverage.

Type of Change

  • ✨ New feature
  • 🔧 Config/build/release
  • 🧪 Test update
  • 📚 Documentation

Checklist

  • New tests added for server, client lifecycle, delivery, .NET host resolution, workspace boundaries, JSON-RPC concurrency/cancellation, and integration behavior
  • Canonical .\scripts\package-vsc.ps1 packaging flow run locally
  • Tested locally on Windows, including ARM64
  • README.md, CONTRIBUTING.md, and release documentation updated
  • package.json language, grammar, commands, configuration, activation, and dependency surfaces updated
  • Latest main merged and conflicts resolved
  • PR review loop completed; no remaining critical or high findings, remaining mediums deferred to the follow-up issues listed under Review history

Verification

  • Extension unit suite: 1,119 passing / 0 failing
  • Server suites: 1,029 passing / 0 failing (62 parser, 89 workspace, 878 language-server)
  • XAML LSP smoke (real server, end-to-end): passing
  • Client lifecycle integration: 10 passing / 0 failing
  • Full XAML integration: 1,635 passing / 0 failing / 28 pending
  • ARM64 framework-dependent smoke (project-aware MSBuild/Roslyn flow): passing
  • VSIX payload validated: required server assemblies, dependency metadata, runtime config, and BuildHost-netcore present; apphost and bundled runtime files rejected
  • VSIX size is reported per-build by the metrics workflow (most recent run: ~118.6 MB)
  • TypeScript type-check and lint: passing (existing warnings only)

Security and runtime notes

The server only evaluates projects under trusted workspace-folder roots. Paths are canonicalized across reparse points before containment checks, preventing junction/symlink escapes. Untrusted and empty windows remain syntax-only.

Project-independent features remain available when no MSBuild toolset is present; project-aware features surface an actionable prerequisite warning rather than failing silently.

Review history

The implementation went through iterative multi-dimension review and an independent different-model cross-check. The final pass found no critical or high defects, and no medium defect that blocks release.

Some review findings were deliberately deferred to follow-up issues rather than expanding this release-critical PR. These are known limitations of code this PR introduces, not pre-existing bugs:

Reviewers should treat the first group as accepted-for-now behavior in new code, not as resolved.

Scope note

Three VS Code test-harness fixes under .github/skills/vsce-testing/ were committed to this branch by accident and have been extracted to #218 (Isolate the VS Code test harness from the user's extension install). They were unrelated to the language service, so this PR no longer touches .github/skills/ and its diff dropped from 273 to 270 files.

Nikola Metulev (nmetulev) added a commit that referenced this pull request Jul 14, 2026
- test:xaml-smoke now runs restore:fixture before the smoke harness so
  element completion has WinUI SDK metadata in CI. The fixture's obj/ is
  gitignored and was previously only restored by the integration pretest,
  so the standalone smoke step failed in CI with 0 completion items. This
  unblocks build-and-test and the packaged VSIX artifact.
- redteam-gap4.test.js: use replaceAll for the caret-marker strip
  (CodeQL "incomplete string escaping or encoding").
- redteam19.test.js: drop the no-op self-replacement
  (CodeQL "replacement of a substring with itself").
- pr-description.yml: tolerate the REST diff API's 20k-line cap (HTTP 406)
  on very large PRs instead of failing; fall back to the changed-file list.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
@chiaramooney
Chiara Mooney (chiaramooney) marked this pull request as ready for review August 5, 2026 03:02
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

VSIX Build

Artifact Baseline Current Delta
VS Code Extension (VSIX) 27.88 MB 39.10 MB 📈 +11.22 MB (+40.25%)

Updated 2026-09-09 21:34:13 UTC · commit 449d4ea · workflow run

Chiara Mooney (chiaramooney) pushed a commit that referenced this pull request Aug 5, 2026
- test:xaml-smoke now runs restore:fixture before the smoke harness so
  element completion has WinUI SDK metadata in CI. The fixture's obj/ is
  gitignored and was previously only restored by the integration pretest,
  so the standalone smoke step failed in CI with 0 completion items. This
  unblocks build-and-test and the packaged VSIX artifact.
- redteam-gap4.test.js: use replaceAll for the caret-marker strip
  (CodeQL "incomplete string escaping or encoding").
- redteam19.test.js: drop the no-op self-replacement
  (CodeQL "replacement of a substring with itself").
- pr-description.yml: tolerate the REST diff API's 20k-line cap (HTTP 406)
  on very large PRs instead of failing; fall back to the changed-file list.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
@chiaramooney
Chiara Mooney (chiaramooney) marked this pull request as draft August 6, 2026 17:05
Nikola Metulev (nmetulev) and others added 15 commits August 6, 2026 14:49
Folds the hardened XAML language service prototype (nmetulev/winui-vsc) into the shipping winapp VS Code extension as a single unified extension. Additive and non-breaking to the existing winapp CLI / debug / manifest features.

Server: copy the .NET 10 LSP server (WinUiXaml.LanguageServer/Workspace/Xaml + 3 xUnit test projects + WinUiXaml.slnx + lsp-smoke) under server/. Builds 0/0; 489/489 unit tests pass.

Client: add src/xaml/xamlLanguageService.ts (activateXaml/deactivateXaml, resolveServerDll bundled->dev fallback) wired additively from src/extension.ts; degrades to syntax-only on server-start failure. Contribute the xaml language, TextMate grammar, language-configuration, winui-xaml.showInfo|restartServer commands, winui-xaml.server.* config, onLanguage:xaml activation, and the vscode-languageclient ^9 dependency in package.json.

Tests: port the 81-file integration harness to test/xaml-integration/ (kept as source of truth) with a clean committed WinAppSDK fixture at test/fixtures/xaml/fixture/ and a root .vscode-test.mjs. Full suite: 1596 passing / 28 pending / 0 failing. smoke.mjs and features.test.js (218) green.

Packaging/CI: esbuild + package-vsc.ps1 publish the server into dist/server (bundled in the VSIX); .vscodeignore excludes C# sources/tests; release-vsc.yml adds UseDotNet@2, a server publish step, and a conditional ESRP DLL-signing step for our own WinUiXaml.*.dll.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
Automated fix->review loop iteration 1 — resolves all 17 findings from the
post-migration PR review (2 High, 9 Medium, 6 Low):

- H1 security: machine-scope winui-xaml.server.path/dotnetPath + workspace-trust
  gate (isTrusted + onDidGrantWorkspaceTrust) + capabilities.untrustedWorkspaces
- H2: deterministic fixture NuGet restore (restore:fixture in pretest)
- M1: run XAML/server/smoke suites in CI with .NET 10 (setup-dotnet)
- M2: document .NET-dependent suites; unit tests stay dotnet-free
- M3/M4: README Features + Requirements for the XAML language service
- M5: serialize client start/stop lifecycle (no torn-down pending start)
- M6: handle workspace/didChangeWatchedFiles (invalidate stale Roslyn cache)
- M7: user-facing "degraded to syntax-only" notification with actions
- M8: client command/lifecycle/degradation integration tests
- M9: fold server bundling into vscode:prepublish (ensure-server-bundle.mjs)
- L1: share bundled-asset path resolver (firstExistingPath)
- L2: tighten .vscodeignore + VSIX-contents assertion
- L3/L4: README command table + CONTRIBUTING .NET 10 SDK prereq
- L5/L6: docs/RELEASE.md signing checklist + server/nuget.config feed pin

Verified: tsc clean, eslint 0 errors, server build 0/0, 489/489 server tests,
smoke PASS, integration 1601 passing / 0 failing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
Automated fix->review loop iteration 2 — resolves the 5 residual/new findings
the independent GPT-5.6 review raised on iteration 1:

- N1 (CRITICAL security): do not start the semantic server while the workspace
  is untrusted (Roslyn/MSBuild would evaluate an attacker-controlled .csproj and
  could execute code). Stay syntax-only until trust is granted; test host runs
  with --disable-workspace-trust so the feature suite still exercises the server.
- N2 (correctness): replace the partial start-guard with a single lifecycle
  queue (runExclusive) so stop fully completes before any start — two servers
  can never coexist across concurrent restarts.
- N3 (correctness): null-guard workspace/didChangeWatchedFiles (changes:null).
- N4 (test-coverage): WINUI_XAML_FORCE_NO_SERVER test seam + a real absent-DLL
  degradation test (syntax-only, no throw).
- N5 (packaging): ensure-server-bundle publishes fresh by default; reuse only
  under WINUI_REUSE_SIGNED_SERVER=1 (set by CI -SkipServerBuild) to preserve
  signed DLLs, so a bare vsce package can never ship a stale server.

Verified: tsc clean, eslint 0 errors, server build 0/0, 489/489 server tests,
smoke PASS, integration 1602 passing / 0 failing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
…(P1-P3)

P1 (M5 residual): guard against server resurrection when restart races
deactivate. Add module-level `disposing` flag set synchronously at the top
of deactivateXaml and reset in activateXaml; doStart early-returns when
disposing. Replace the separate stop+start in the restartServer command and
onDidGrantWorkspaceTrust with a single restartClient() that runs
stop-then-start inside one runExclusive op (atomic; skips start if disposing).

P2: rewrite package.json untrustedWorkspaces capability description to match
actual behavior (syntax highlighting only until the workspace is trusted).

P3 (M9 residual): package-vsc.ps1 -SkipServerBuild set WINUI_REUSE_SIGNED_SERVER
into the caller's environment and never cleaned it up. Capture the prior value
before the try and restore/remove it in the finally block.

Full integration suite: 1602 passing / 0 failing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
…packaging)

Final 8-dimension PR-review gate over the whole branch surfaced 10 findings the
per-iteration reviews (scoped to their own residuals) never looked at. Fix all.

G1 (HIGH security): the isTrusted gate is necessary but not sufficient — an empty
window is trusted, so opening a loose XAML file outside any workspace folder made
the server warm up and MSBuild-evaluate its nearest .csproj (code-exec vector).
Client now passes workspaceFolders as initializationOptions.allowedRoots; the
server (ResolveAllowedRoots/IsPathUnderAllowedRoot/ResolveIfAllowedAsync) only
runs project discovery + OpenProjectAsync for documents under a trusted root.
Empty allow-list => no project evaluation; out-of-root/untitled files are served
project-less (tolerant parser only). Boundary-aware, case-insensitive path check.
allowedRoots is authoritative when present; legacy clients fall back to rootUri.

G3 (HIGH test-coverage): add WINUI_XAML_FORCE_UNTRUSTED seam (mirrors
WINUI_XAML_FORCE_NO_SERVER) so the trust gate + onDidGrantWorkspaceTrust recovery
are exercised under the trusted harness. New client tests cover degrade+recover.

G4 (docs): document winui-xaml.server.path in README.
G5 (correctness): retain the synchronize.fileEvents FileSystemWatcher and dispose
it in doStop / failed-start catch (was leaking one per start/restart/trust cycle).
G6 (UX): untrusted degradation now shows a once-per-transition warning with a
Manage Workspace Trust action (was log-only).
G7 (test-coverage): extract pure buildDegradedNotification() + unit test message
and action mapping.
G8 (test-coverage): client tests for explicit server.path (valid -> semantic
completion; invalid -> syntax-only, no throw).
G9 (test-coverage): lsp-smoke sends didChangeWatchedFiles with omitted/null/empty
changes and asserts the server stays responsive.
G10 (packaging): drop the redundant bundle:server in package-vsc.ps1 (vscode:
prepublish/ensure-server-bundle.mjs is the single publish path).
G2 (packaging): narrow .vscodeignore to exclude only the apphost exe so Roslyn's
net472 MSBuild BuildHost.exe ships; assert a BuildHost is present in the VSIX.

Full integration 1605 passing / 0 failing; server 489, unit 595, smoke green.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
…indings)

The final 8-dimension confirmation gate (incl. a cross-model check) found 5 issues
the per-iteration reviews never scoped. Fix all 5.

G15 (HIGH security): the allow-list was purely lexical — Path.GetFullPath does not
resolve reparse points, so a junction/symlink placed inside a trusted workspace root
that targets an external directory passed the containment check, and the resolver
(FindOwningProject -> MSBuild GetOrLoadAsync) then evaluated the external .csproj.
Fix: CanonicalizePath resolves the final physical path (GetFinalPathNameByHandle) for
both the workspace roots (NormalizeRoots) and the document (IsPathUnderAllowedRoot)
before containment; falls back to the lexical full path for non-existent/untitled
docs or on any OS-call failure. A junction escaping the root now canonicalizes
outside it and is served project-less.

G11 (MEDIUM correctness): a workspace opened at a bare drive root (C:\) rejected all
its children — NormalizeRoots keeps C:\ with its trailing separator, but PathIsWithin
required path[root.Length] to be a separator (it was the first path-segment letter).
Fix: when the root already ends in a separator (bare drive/UNC root) the prefix match
is itself the boundary. The boundary-char check still guards C:\root vs C:\rootEvil.

G12 (HIGH test-coverage): the security-critical boundary had no direct test. Made
NormalizeRoots/PathIsWithin/CanonicalizePath internal (test project already has
InternalsVisibleTo) and added AllowedRootBoundaryTests (exact/child/out-of-root/
sibling-prefix/drive-root/cross-drive/case/trailing-sep/normalize-trim + a non-admin
mklink /J junction regression). Added a behavioral lsp-smoke case: a document under
os.tmpdir (outside the sole allowedRoot) gets no project-backed resolution while the
in-root fixture still resolves.

G13 (MEDIUM UX): the degraded-notification guard was a single boolean reset only on a
successful start, so after a user granted trust but the server still could not start
(e.g. no dotnet) the server-missing guidance was suppressed. Fix: track the last
degraded cause and notify once per distinct cause (untrusted vs server), still
non-nagging; reset on successful start.

G14 (LOW docs): README used the abbreviated server.dotnetPath; use the full
winui-xaml.server.dotnetPath.

Full integration 1605 passing / 0 failing; server 505, unit 595, smoke green;
server debug build 0 warnings.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
…trust boundary

reviewer-iter5 (independent cross-model) found two HIGH residuals in the iter5
allow-list hardening. Both are closed here.

G15 (security) — the canonicalizer only resolved reparse points for an EXISTING
leaf (CreateFileW/OPEN_EXISTING). A not-yet-created XAML leaf under an in-root
junction (e.g. C:\trusted\link\Page.xaml, no file) failed that call and fell back
to the lexical path, which still passed lexical containment. XamlProjectResolver
.FindOwningProject only needs the DIRECTORY (new FileInfo(path).Directory +
dir.GetFiles("*.csproj")), so the external junction target's .csproj was still
MSBuild-evaluated — a code-exec bypass. CanonicalizePath now walks up to the
deepest EXISTING ancestor (which follows any junction/symlink in the ancestry),
resolves it via GetFinalPathNameByHandle, and re-appends the missing tail; lexical
fallback is used only when no ancestor exists or the OS call fails. Legit
not-yet-saved files under a real (non-junction) dir still resolve in-root, so
IntelliSense for new files is preserved.

G12 (test-coverage) — the junction regression test never created the linked file,
so it exercised the same missing-leaf fallback, and its Assert.False threw inside a
broad catch(Exception) that swallowed the failure: a green test over a live hole.
The test now creates the linked file and asserts BOTH the existing-leaf and the
missing-leaf paths canonicalize OUTSIDE the trusted root, with the assertions moved
out of the swallowing catch (it skips only on genuine junction-creation failure).
The out-of-root lsp-smoke case gains a sibling .csproj + code-behind so the null F12
result is attributable to the trust gate rather than to an absent project.

Verification: build:server:debug 0 warnings/0 errors; test:server 505/505 (junction
test genuinely exercised — junctions confirmed creatable in this env);
test:xaml-smoke PASS incl. the strengthened out-of-root case; full integration
1605 passing / 0 failing / 28 pending.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
- test:xaml-smoke now runs restore:fixture before the smoke harness so
  element completion has WinUI SDK metadata in CI. The fixture's obj/ is
  gitignored and was previously only restored by the integration pretest,
  so the standalone smoke step failed in CI with 0 completion items. This
  unblocks build-and-test and the packaged VSIX artifact.
- redteam-gap4.test.js: use replaceAll for the caret-marker strip
  (CodeQL "incomplete string escaping or encoding").
- redteam19.test.js: drop the no-op self-replacement
  (CodeQL "replacement of a substring with itself").
- pr-description.yml: tolerate the REST diff API's 20k-line cap (HTTP 406)
  on very large PRs instead of failing; fall back to the changed-file list.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
CodeQL's full scan of the migrated test files (features.test.js, smoke.mjs)
flagged sanitization patterns in test helpers. All fixes are behavior
preserving (smoke PASS; integration 1605 passing / 0 failing):

- caret-marker strip: .replace("|", "") -> .replaceAll("|", "")
  (js/incomplete-sanitization).
- exact completion-label membership: array.includes(<uri>) ->
  array.some((l) => l === <uri>) — these were array-membership checks that
  CodeQL misread as URL substring checks (js/incomplete-url-substring-sanitization).
- diagnostic display string: drop the nested template literal in favor of
  string concatenation (js/bad-code-sanitization).

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c713cc-41ae-4c28-ab49-3c851aa8e2bd
Build local native bundles, consume signed release artifacts, harden workspace boundaries and lifecycle behavior, and validate both packaged architectures.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Keep bundled mode fail-closed for fallback resolution while allowing authoritative custom path settings to exercise degradation and recovery. Avoid secondary artifact-upload failures when an earlier CI gate fails.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Keep the canonical x:Bind diagnostics in redteam15 and clarify that the prefix-sharing resource tests exercise references and document highlights separately.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Add merged resource traversal, semantic binding diagnostics, namespace cleanup, on-type formatting, snippets, and surround-with refactors with full server and live VS Code coverage.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Distinguish language-server completions from VS Code word suggestions and align resource and attached-property assertions with current behavior.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Shorten comments, split oversized server and test files, remove unrelated release and CLI downloader changes, and rename red-team tests by scenario.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Remove static color, font-weight, and theme-resource tables; source completion data from project metadata and generic.xaml. Also remove standalone snippets, Surround With, and user-facing server path overrides.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d48e3dcd-70ba-416d-b66e-e5f046facd10
The server supplies folding ranges, including #region/#endregion pairs. When the .NET runtime or MSBuild toolset is missing, XAML degrades to syntax highlighting only, the folding provider goes with it, and region folding is lost -- even though it needs no type system.

VS Code's folding markers are consumed by the indentation-based fallback, and a folding range provider takes precedence when one is registered, so this only affects the degraded path and cannot change behaviour while the server is running.

The patterns mirror the server's marker rules in XamlFolding.ClassifyRegion: an optional label is allowed, and a word boundary keeps '#regionalize' from matching.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
XamlValidator had grown to 3384 lines in a single static class, well past the point where the file is navigable. The surrounding code already uses partial files for this -- CompletionProvider and XamlLanguageServer are each split across five -- so this applies the established convention to the one type that had outgrown it.

The seams follow the existing method grouping: per-element checks, binding markup, x:Bind paths, x:Bind functions, and document-scope rules. Validate and Walk stay in the primary file with the diagnostic codes and reporting helpers, so the entry point still reads top to bottom.

This is a pure move: no signature, body, or accessibility changed. Verified by comparing the non-blank line multiset of the original class body against the union of the new files -- 3047 lines on both sides, identical.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Four integration tests asserted that a leading '!' in an x:Bind path is valid and should stay silent. The validator reports WXAML0035 for it, and smoke-core-scenarios.mjs asserts that error explicitly, so the suites contradicted each other and the four tests failed.

'!' is not part of the {x:Bind} grammar -- neither the x:Bind markup extension reference nor the function-bindings page defines a negation operator, and the documented ways to invert a bool are an inverted property or a helper function. The diagnostic is correct and these assertions were stale.

Updated them to expect WXAML0035, and dropped the '!' from the dense realistic-page case so it keeps testing what it was written for: that a valid page produces no diagnostics. Navigation is deliberately more lenient than validation -- hover and F12 still see through a negation prefix -- and those assertions are unchanged.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
server/nuget.config pinned nuget.org as the only feed and used <clear /> to drop inherited sources. On machines whose policy blocks public NuGet egress and serves packages from an approved internal mirror, that is actively fatal: <clear /> removes the working feed but does not clear disabledPackageSources, so nuget.org stays disabled and server/ is left with zero enabled sources.

Measured on such a machine, restoring WinUiXaml.LanguageServer.csproj into an empty packages folder: with the file present every package fails NU1100; with it absent all three projects restore from the approved feed. Warm builds only passed because the packages were already in the global packages folder.

The pin bought version determinism the projects already have -- all 26 PackageReference entries specify exact versions -- so removing it changes nothing about which package versions resolve. Hosted CI runners keep nuget.org as their default source, so the workflow restore is unaffected. 6de338c reached this same conclusion for the fixture restore; 03a0e48 reverted it to preserve a determinism the version pins were already providing.

Also drops the --configfile pin from restore:fixture in package.json and build.yml, which forced the same nuget.org-only view onto a fixture that lives outside server/.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The untrusted-workspace and server-not-started messages joined two independent clauses with an em dash. Both clauses stand alone, so they are now separate sentences.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
All eight status messages led with the same 'WinUI XAML Tools -- ' prefix. The em dash is now a colon, which reads as the label separator it always was. Updates the seven exact-string assertions in xaml-configuration.test.ts to match.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The project-context state set was written out three times: the ProjectContextState union, an inline copy in XamlProjectContextSummary, and a runtime array in updateProjectContextStatus. The runtime copy was the dangerous one, since adding a state to the union still compiled while the validator silently dropped it. States now derive from a single PROJECT_CONTEXT_STATES tuple, and the validator uses an isProjectContextState guard built from it.

The status bar and the showInfo summary describe the same three conditions, and had already drifted apart: the error fallback read 'project metadata failed to load.' in one and 'Project IntelliSense failed to load.' in the other, and the framework-ready sentence differed in both capitalization and separator. Both surfaces now compose shared constants, so the status bar tooltip and the summary agree by construction.

Also folds the two quick-fix errors duplicated across promptedTextEdit and xamlLanguageService into exported constants, and points the Install .NET action at the existing DOTNET_DOWNLOAD_URL instead of repeating the literal.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The XAML TypeScript restated the same command ids, settings keys, and user-facing sentences at several sites, and three of them had already drifted apart: the quick-fix 'could not edit' message, and the .NET resolution failure sentence, which said 'a compatible installed runtime' at one site and omitted 'installed' at the other.

Adds a dependency-free xamlConstants module holding the command ids, settings keys, download URL, and status-action labels, so the notification and configuration surfaces can share them without an import cycle. Message wording moves behind helpers (couldNotEditMessage, describeDotnetResolutionFailure) that own the single copy of each sentence.

Typing DegradedAction.label as DegradedActionLabel turns the previously unchecked button labels into compile-time errors when the two surfaces disagree.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The error branch composed the general 'WinUI XAML Tools:' prefix with a reason that is itself a sentence, so the summary read with two colons: 'WinUI XAML Tools: project IntelliSense unavailable: <reason>'.

The error case now uses 'WinUI XAML IntelliSense Unavailable:', which states the condition once and lets the reason follow as the sentence after the colon. Both prefixes move into xamlConstants so the eight status sites stop restating them.

The per-status tests compose the prefixes rather than re-typing them, so they cannot drift; a separate test pins the two prefix literals, since composing both sides from the same constant would not catch a typo in the wording itself.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Removes the resource-index and MarkupExtension detail from the language server paragraph, and condenses 'Where Go to Definition works' to a short summary. The per-case F12 table went into the weeds on exactly which constructs navigate and from which load stage, which is more detail than a README needs; the heading stays so the two cross-references still resolve.

Replaces every em dash. Prose takes a colon, comma, or sentence break depending on what the dash was doing, paired appositives become parentheses, and the support matrix uses a plain hyphen for its not-supported cells, since a colon would not make sense as a table marker.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The document-change handler re-typed the Enter-detection regex as a cheap pre-filter so it can skip reading the document text on every keystroke. The pattern was character-for-character identical to isEnterEdit, which attributeSuggestionTrigger already exports, so the two copies would have drifted apart the moment the rule changed.

The pre-filter itself is worth keeping: it avoids a getText() call on unrelated edits.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Resolves package.json (keep main's version, dep bumps, and enum formatting alongside the branch's XAML settings) and .pipelines/release-vsc.yml (adopt main's extracted download-cli.ps1 script while keeping the XAML server install and smoke steps).

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The XAML language-client dependencies (vscode-jsonrpc, vscode-languageclient, vscode-languageserver-protocol/types, minimatch) still carried 'resolved' URLs pointing at a private Azure Artifacts mirror. Main's lockfile policy omits registry URLs so the lockfile is not tied to whichever feed the installing machine used.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
- M1: document degraded XAML behavior in README
- M2: drop legacy warning/error diagnostics aliases from settings and schema
- M3: run framework-dependent smoke against the right bundle mode in CI
- M5: honor LSP end-exclusive ranges in XamlFormatter range formatting
- M6: report the real assembly version in serverInfo
- M7: match code-behind partial classes by fully qualified name
- M9: extract and test the generated-handler apply path
- M10: extract and test the project restore notification flow
- L1: restore contributes.configuration to an object
- L2: split ThemeResourceCatalog out of XamlTypeSystem
- L3: share status action constants
- L4: drop internal Host B jargon from user-facing text

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
XamlProjectResolver.Invalidate could only test completed cache entries with
ContainsProject, because a project graph does not exist until its load
finishes. An invalidation that arrived while a load for a different root was
in flight was therefore dropped, and that root was cached afterwards with a
pre-invalidation graph that nothing ever evicted, leaving IntelliSense stale
until the next edit to the changed project.

Record the invalidated key on each pending entry instead of skipping it, and
re-test those keys against the graph when the load completes, self-evicting if
any of them is present. This is scoped to the entry that is actually affected;
the previously attempted `|| !pair.Value.IsCompleted` predicate was reverted
because it evicted every in-flight load across all roots.

Self-eviction on completion makes the pre-existing disposal hazard load-bearing:
it disposes exactly when awaiting callers resume, so ResolveAsync could observe
a disposed workspace between receiving it and reading its compilation. Add a
lease around the workspace read - eviction now removes the entry immediately but
defers Dispose until the last active resolve releases it.

Adds an internal IsCached hook so the tests can assert eviction directly rather
than racing on file content, plus regression coverage for the Invalidate and
InvalidateAll pending paths. Both assert the load is still in flight when the
invalidation lands, so they fail loudly rather than passing spuriously; the
Invalidate test was confirmed to fail against the previous behaviour.

Refs #215

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The previous commit added a lease so an evicted workspace was only disposed
once no active resolve was still reading it. Testing the premise directly
showed the hazard does not exist: RoslynProjectWorkspace exposes every read
(GetCompilationAsync, GetFrameworkCompilation, ContainsProject, XamlFiles,
ApplicationDefinitionPath) through the immutable Roslyn Project snapshot
captured at load time, and only LoadDiagnostics touches the MSBuildWorkspace.
Disposal therefore cannot break a resolve that is already in flight.

Removing the lease and its UseWorkspaceAsync wrapper restores the original
straight-line resolve path and leaves only the fix that is actually load-bearing:
replaying invalidations that arrive while a load is pending.

Keeps a DisposedWorkspaceStillServesCompilationReads test to pin the premise, so
if a future read starts touching the disposed MSBuildWorkspace this fails rather
than silently reintroducing the hazard.

Refs #215

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Extracts notificationDismissal(key, store), which owns the globalState read and
write behind a "Don't Show Again" action, and routes the Dev Kit recommendation
and the missing-.NET-runtime warning through it. Both previously inlined the
same get/update pair, and the degraded path additionally repeated an
undefined-context fallback at each site.

Scoped deliberately to the dismissal flag rather than the whole notification.
The two surfaces differ too much to share a presentation helper: the Dev Kit
recommendation is a one-shot suggestion, while the degraded warning carries a
multi-action model and suppresses itself on cause transitions. Forcing both
through one showDismissibleNotification would have added indirection without
removing duplication.

projectRestoreNotification is intentionally untouched: it has no persisted
dismissal at all, only a session-scoped gate, so it has nothing to share here.

Registers the new test file in test:unit, which lists test files explicitly
rather than globbing, so an unregistered file would silently never run.

Closes #213

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
ReadMessageAsync allocated new byte[contentLength] straight from the header, and
the header reader had no cap on either line length or total block size. Adds a
32 MB body limit, an 8 KB header-line limit, and a 64 KB header-block limit, each
failing the frame with its own log message.

Also treats an unparsable or negative Content-Length as a protocol error rather
than falling through. int.TryParse writes 0 on failure, which overwrote the -1
sentinel, bypassed the missing-header guard, and framed an empty body while the
real body bytes stayed in the stream to be misread as the next frame's headers.

These are not a defense against a hostile peer. The only writer on this pipe is
the extension host over stdio, as Program.cs is the sole construction site. The
value is that a truncated or half-written frame from a crashing client now fails
fast with a diagnostic instead of an OutOfMemoryException or a read loop that
never terminates.

Four of the six new tests were confirmed to fail with the bounds reverted. The
other two are deliberate non-regression guards: a negative length was already
rejected by the old < 0 check, and one is a positive control asserting that
headers within the limits still dispatch.

Closes #214

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The framing bound landed with a default int.TryParse, which is culture-sensitive
and accepts a leading sign. LSP specifies digits only, so this switches to
NumberStyles.None with InvariantCulture.

No behavior change for well-formed input, since ASCII digits parse identically
under any culture. What it removes is culture as a variable in the wire protocol
and tightens the accepted grammar to the spec: "+39" previously parsed as 39 and
dispatched the frame, and now fails as malformed. Rejecting the sign also makes
a negative length unparsable, so the separate < 0 guard is no longer needed.

ContentLengthWithASignIsRejected was confirmed to fail without NumberStyles.None.
The culture test is a guard rather than a regression test: it passes either way,
because the difference only shows up on input the parser now rejects outright.

Refs #214

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
…ehavior

Commit 6de338c changed two server behaviors while addressing PR review
findings, and 17 extension-host integration tests were left asserting the
old ones. Commit be3cb42 updated four of them; these are the rest. CI has
been red since 2026-09-04 as a result.

x:Bind negation (3 tests). Verified against the real WinUI XAML compiler
by compiling a probe page into the SmokeFixture project: `{x:Bind !IsReady}`
fails the build with "token recognition error at: '!'". WXAML0035 is
therefore correct, and a negated path is unsupported syntax rather than a
misspelled member, so no rename quick fix is offered on it.

Undeclared-prefix xmlns (14 tests). The server now offers a manual-entry
prompt ("Add xmlns:zzz...") for any prefix whose namespace it cannot
resolve. The tests matched /^Add xmlns/, which caught that prompt as well
as inferred fixes. The guarantee they exist to protect is that the server
never *guesses* a namespace, so they now forbid only concrete
`Add xmlns:prefix="uri"` actions. Adds a positive test asserting the prompt
is present, applies no edit of its own, and offers no inferred choices, so
loosening the matcher cannot silently let the prompt disappear.

Integration suite: 1630 passing, 0 failing (was 1612 passing, 17 failing).

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Resolves conflicts in package.json and package-lock.json. The PR was in a
CONFLICTING state, which prevented GitHub from computing the merge commit
and so stopped the pull_request-triggered "Build and Test" workflow from
running on the last four pushes.

package.json: keep main's @xmldom/xmldom bump to ^0.9.12 alongside this
branch's vscode-languageclient dependency. package-lock.json was
regenerated from the resolved manifest rather than hand-merged.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The color provider only recognized hex literals, so `Fill="CornflowerBlue"`
got no swatch and no picker. Named colors now resolve to their exact ARGB.

Validity comes from XamlTypeSystem.GetNamedColors(), which discovers the real
Microsoft.UI.Colors surface from the referenced SDK. System.Drawing.Color.FromName
supplies the channel values for a name that already passed that gate, and never
decides validity: it also resolves .NET *system* colors (Control, Desktop,
ActiveBorder, Highlight) with IsKnownColor == true, which WinUI does not have and
which throw XamlParseException at runtime. Gating on FromName would paint swatches
on markup that crashes the app. No hardcoded color table is needed; FromName agrees
with the WinUI parser on every name, Transparent's zero alpha included.

Matching is case-insensitive because the XAML parser accepts red and RED as readily
as Red, which also matches XamlValueConverter's existing validation.

Presentations preserve the user's spelling: picking a color over `Red` offers the
name first, so accepting VS Code's default no longer silently rewrites it to
#FFFF0000. Over a hex literal, hex stays first and the name is an alternative.
This required wiring ColorPresentationAsync to resolve the document and type
system, which it previously did not do.

Verified against the real WindowsAppSDK, not just a synthetic type system: the
integration tests confirm the exact ARGB for Red/CornflowerBlue/DarkSlateGray/
Transparent and that the four .NET system colors produce no swatch.

Closes #209

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The enum sat alone in a 16-line file next to the node hierarchy it
discriminates. Syntax/ is not one-type-per-file — XamlNodes.cs already holds
the 11 node types — and XamlNodeKind exists solely to tag those types via
XamlNode.Kind, so it belongs beside them.

Pure code movement; no behavior change.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The framework-dependent smoke test failed in CI on a commit that only moved an
enum between files, and the log shows why: the whole post-invalidation section
completed in about 3 ms, so `await reloadReadyPromise` released instantly and the
authoritative hover then raced a reload that had not finished, returning the
empty "suppressed while loading" result.

dispatch() resolves the first waiter whose matcher accepts a message, so a bare
`state === "ready"` matcher can be satisfied by any ready notification that
happens to arrive after the waiter is registered, not specifically the one ending
this reload. The barrier now gates on the reload's own `loading` transition,
which LoadContextAsync publishes before every load, and only accepts a `ready`
that follows it.

The flag is set inside the matcher rather than in a `.then` because `loading` and
`ready` can arrive in one stdout chunk and be dispatched synchronously, before a
microtask would run.

Test-only; no product code changes. The local run also confirms the gate is
reachable: were `loading` not published on this path, it would now time out.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
The smoke test sent the LSP `exit` notification and then unconditionally exited
after a fixed 200 ms, so a server that answered `shutdown` but never terminated
would have been reported as a pass. That failure mode leaves an orphaned dotnet
process behind every time the editor closes.

Now waits on the child process `exit` event with a 10s cap and asserts the LSP
contract that `exit` after `shutdown` terminates with code 0.

Verified load-bearing by suppressing the `exit` notification, which produces
"server did not exit within 10s of the exit notification" instead of passing.
Both smoke entry points (test:xaml-smoke and test:xaml-framework-dependent)
pass with the assertion in place.

The 200 ms delay is kept solely to flush buffered stdout; server termination is
no longer assumed to fit inside it.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
main pinned all GitHub Actions to full-length commit SHAs (#232) while this
branch added .NET server build/test steps to the same workflows, so the two
collided on the VSIX upload step.

Base had `!cancelled()` with `actions/upload-artifact@v7`. This branch changed
the condition to `success()` (review finding, 1dac082); main pinned the SHA.
Each side changed a different thing, so both are kept.

The .NET steps added here were invisible to main's pinning sweep and still
carried floating tags, which would have silently reintroduced exactly what
#232 removed. Pinned them to the SHAs already canonical in this repo:
actions/checkout v7.0.1 and actions/setup-dotnet v4.3.1 (verified v4 and
v4.3.1 resolve to the same commit).

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants