Skip to content

Fix formatting incorrect for void tag helpers#12802

Merged
davidwengier merged 4 commits intomainfrom
copilot/fix-void-tag-helpers-formatting
Feb 21, 2026
Merged

Fix formatting incorrect for void tag helpers#12802
davidwengier merged 4 commits intomainfrom
copilot/fix-void-tag-helpers-formatting

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

Summary of the changes

Void tag helpers (e.g., <input asp-for="AllowAuthorizationCodeFlow">) caused indentation to increase with each occurrence because CSharpDocumentGenerator.ElementCausesIndentation only recognized MarkupStartTagSyntax (plain HTML) as void — not MarkupTagHelperStartTagSyntax. This caused an unmatched { /* */ to be emitted in the generated C# document with no corresponding }, since void elements have no end tag.

  • BaseMarkupStartTagSyntax: Moved IsVoidElement() up from MarkupStartTagSyntax so both plain HTML and tag helper start tags inherit it
  • MarkupStartTagSyntax: Removed now-redundant IsVoidElement() override
  • CSharpDocumentGenerator.ElementCausesIndentation: Replaced type-checked node is MarkupStartTagSyntax startTag && startTag.IsVoidElement() with node.IsVoidElement() — fixing the unmatched brace emission for void tag helpers
  • Tests: Added VoidTagHelpers_NotIndented to HtmlFormattingTest in the VS Code shared formatting test project
Original prompt

This section details on the original issue you should resolve

<issue_title>Formatting incorrect for void tag helpers</issue_title>
<issue_description>Create a cshtml document with the following and then format:

<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">

<input type="checkbox" asp-for="AllowAuthorizationCodeFlow">
<input type="checkbox" asp-for="AllowAuthorizationCodeFlow">
<input type="checkbox" asp-for="AllowAuthorizationCodeFlow">
<input type="checkbox" asp-for="AllowAuthorizationCodeFlow">
<input type="checkbox" asp-for="AllowAuthorizationCodeFlow">

Expected: All indented to the same level
Actual: One the void tagHelpers are encountered, the indentation starts increasing.</issue_description>

Comments on the Issue (you are @copilot in this section)

@davidwengier You know, I've been wondering how copilot will go with formatting, now that all of the tests are shared and cross-platform. Let's find out!

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…lass and fixing CSharpDocumentGenerator and FormattingVisitor

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix formatting issue for void tag helpers Fix formatting incorrect for void tag helpers Feb 19, 2026
Copilot AI requested a review from davidwengier February 19, 2026 23:41
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 19, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • vb4vsblobprodcus33.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet test src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj --filter FullyQualifiedName~VoidTagHelpers -v minimal (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 19, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • vb4vsblobprodcus33.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet test src/Razor/test/Microsoft.VisualStudioCode.RazorExtension.Test/Microsoft.VisualStudioCode.RazorExtension.Test.csproj --filter FullyQualifiedName~VoidTagHelpers -v minimal (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidwengier davidwengier marked this pull request as ready for review February 20, 2026 00:14
@davidwengier davidwengier requested a review from a team as a code owner February 20, 2026 00:14
@davidwengier davidwengier merged commit 16a87c5 into main Feb 21, 2026
10 checks passed
@davidwengier davidwengier deleted the copilot/fix-void-tag-helpers-formatting branch February 21, 2026 02:38
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 21, 2026
@akhera99 akhera99 removed this from the Next milestone Feb 24, 2026
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.

HTML code indentation in Blazor is not working properly Formatting incorrect for void tag helpers

4 participants