Skip to content

Fix XAML IntelliSense bug-bash issues (#356, #359, #360, #363, #366) - #377

Open
Chiara Mooney (chiaramooney) wants to merge 2 commits into
mainfrom
chiaramooney-fix-xaml-intellisense-bugs
Open

Chiara Mooney (chiaramooney) wants to merge 2 commits into
mainfrom
chiaramooney-fix-xaml-intellisense-bugs

Conversation

@chiaramooney

Copy link
Copy Markdown
Collaborator

Description

Fixes five XAML IntelliSense bugs from the bug bash.

  • Server stops restarting ([Bug]: Status bar spins forever after the XAML server stops restarting #363): after the server crashes 5 times in 3 minutes, the status bar now shows WinApp: XAML Language Server Stopped instead of spinning forever. Clicking it restarts the server. The warning offers Restart Language Server and Show Output, and opening another XAML file no longer silently restarts a server the client gave up on.

  • Deep nesting ([Bug]: Deeply nested XAML hangs Outline and produces bogus diagnostics #366): a page with 500 nested elements now gets an outline promptly and no bogus "no matching end tag" diagnostics. The root cause was the outline response exceeding Utf8JsonWriter's depth limit of 1000. The exception was thrown outside the handler's try block, so the request was never answered. Changes:

    • The server now always replies, with an error if a result can't be serialized.
    • Outline and selection-range results are capped at 100 levels deep.
    • The parser handles up to 512 levels, then reports one warning and skips the rest without recursing. 512 keeps the recursive parser well inside a 1 MB thread stack; 1024 overflowed it.
  • Line endings and surrogates ([Bug]: XAML document sync breaks on CR-only line endings and unpaired surrogates #360): \r, \n and \r\n are all line breaks for positions, formatting, namespace insertion and generated event handlers. A lone UTF-16 surrogate in didOpen/didChange becomes U+FFFD, so the document still updates and the character is reported, instead of the notification failing with a JsonException.

  • Formatting with only the C# extension ([Bug]: XAML formatting does nothing when only the C# extension is installed #359): winapp.xaml.formatting.provider = auto now defers only when C# Dev Kit is installed and dotnet.enableXamlTools is on, since the C# extension formats XAML only with Dev Kit. Installing or removing Dev Kit restarts the server so the choice takes effect.

  • XML syntax errors ([Bug]: XML syntax errors are not reported in XAML files #356): new diagnostics XAML0011 to XAML0019 cover:

    • Multiple roots and text outside the root.
    • Raw &, bad entities and invalid character references.
    • Raw < in attribute values.
    • Invalid XML characters.
    • XML declaration errors.
    • < Button/> and </ Button>.
    • Malformed markup extensions: a missing name, trailing text, and positional arguments after named ones.

    Markup values recognize every XML spelling of a quote (literal, &apos;/&quot;, decimal or hex), so valid escaped values aren't flagged.

Usage Example

Each line shows the input, then the result.

<!-- #356: errors at the offending token -->
<Page ...></Page>
<Grid/>                                   <!-- XAML0012: A XAML document can have only one root element. -->
<Button Content="a & b"/>                 <!-- XAML0015: '&' must be escaped as '&amp;'. -->
< Button/>                                <!-- XAML0018: Whitespace is not allowed between '<' and the element name. -->

<!-- Still clean -->
<Button Content="{x:Bind Format('{0}, {1}', A, B)}"/>
<Button Content="{Binding Path, ConverterParameter=&apos;a,b&apos;}"/>

Related Issue

Fixes #356
Fixes #359
Fixes #360
Fixes #363
Fixes #366

Type of Change

  • 🐛 Bug fix
  • 🧪 Test update

Checklist

  • New tests added for new functionality (if applicable)
  • Tested locally on Windows (if applicable)
  • README.md updated (if applicable)
  • package.json contribution points / command/debugger/custom-editor docs updated (if extension surface changed)

Screenshots / Demo

No screenshots captured. The visible changes are the stopped status-bar item and warning, which the VS Code integration test exercises (below). All other changes are diagnostics and server behavior, shown in the example above.

Additional Notes

Validation (local, Windows ARM64):

  • dotnet test server/test/WinUiXaml.Xaml.Tests: passed, 110 tests. Includes well-formedness cases and depth guards that parse at 512 and 5000 levels on a 1 MB thread.
  • dotnet test server/test/WinUiXaml.LanguageServer.Tests: passed, 1030 tests. Includes CR-only positions, surrogate replacement, deep outline and selection-range serialization through JsonRpcConnection, and an error reply for unserializable results.
  • node server/test/lsp-smoke/smoke.mjs: passed.
  • npm run compile-tsc: passed. npm run lint: no errors; the 10 warnings are in files this PR doesn't touch.
  • XAML unit tests via npx tsx --test: 68 passed, covering configuration, degraded notification, server stop handling, project context status and lifecycle. Full npm run test:unit: 5 manifest-validator tests fail locally only because schemas/ isn't synced on this machine; this PR doesn't touch them.
  • npx vscode-test with test/xaml-integration/client.test.js: 11 passed. One new test kills the real server 5 times, then checks that it stays stopped, that opening a XAML document doesn't restart it, and that Restart Language Server recovers it.
  • npx vscode-test with the false-positive sweep, nested markup, styles/templates, parser edges, formatting, outline, code actions and the new well-formedness-and-depth.test.js: 228 passed, no new false positives.

Not validated: I didn't build or install the packaged VSIX with the release AOT server, because this machine's package feed can't restore the AOT runtime packs. CI's bundled-server step covers that.

Known limits:

  • Content nested deeper than 512 levels gets one warning and isn't analyzed.
  • Outline and selection-range results flatten past 100 levels to keep responses bounded.

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.

- Report a server that stopped restarting with a Restart action instead of a spinning status (#363)
- Bound deep element nesting and always answer requests whose results fail to serialize (#366)
- Treat CR as a line break and replace lone surrogates in synced text (#360)
- Keep WinApp formatting on unless C# Dev Kit provides a XAML formatter (#359)
- Report XML well-formedness errors in XAML documents (#356)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@chiaramooney Chiara Mooney (chiaramooney) added agent-preparing Agent work in progress (feedback, validation, or CI) intellisense labels Nov 10, 2026
@chiaramooney
Chiara Mooney (chiaramooney) marked this pull request as ready for review November 13, 2026 17:34
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

VSIX Build

Artifact Baseline Current Delta
VS Code Extension (VSIX) 72.47 MB 72.49 MB 📈 +26.2 KB (+0.04%)

Updated 2026-11-13 19:05:31 UTC · commit d907598 · workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-preparing Agent work in progress (feedback, validation, or CI) intellisense

Projects

None yet

1 participant