Skip to content

Add documentation formatting and typing support - #85726

Open
davidwengier wants to merge 5 commits into
mainfrom
davidwengier/razor-doc-formatting
Open

davidwengier wants to merge 5 commits into
mainfrom
davidwengier/razor-doc-formatting

Conversation

@davidwengier

@davidwengier davidwengier commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Adds formatting and typing support for @documentation, using the existing documentation-comment formatter rather than treating the XML body as Razor code. Preserves XML text and source mappings, and honours the brace-placement option.

Builds on #85725. Part of #85414.

Remote builds for net10.0 and netstandard2.0. All 158 VS Code and 166 VS cases pass with analysers enabled, including the full 103-case formatting class in each host, auto-insert and VS on-type coverage. Product and tests are separate commits.

Microsoft Reviewers: Open in CodeFlow

@davidwengier
davidwengier requested a review from a team as a code owner September 21, 2026 11:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@davidwengier

davidwengier commented Sep 21, 2026 •

Copy link
Copy Markdown
Member Author

Copilot can't stop running git diff --check which flags mixed leading whitespace, so copilot fixes it, which makes the tests fail, so it put it back in weird ways, like {{"\t"}} etc. I'll fix that manually.

@davidwengier
davidwengier added this pull request to stack #85729 September 21, 2026 12:46
dibarbet
dibarbet previously approved these changes Sep 21, 2026
Copilot AI balanced review requested due to automatic review settings September 28, 2026 22:21
@davidwengier
davidwengier force-pushed the davidwengier/razor-doc-formatting branch from a64ba08 to 79039c5 Compare September 28, 2026 22:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation is focused, defensively handles malformed input, and has comprehensive cross-host coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds formatting and typing support for Razor @documentation blocks while preserving XML content.

Changes:

  • Projects documentation bodies as C# documentation comments for Roslyn formatting.
  • Supports brace-placement options and safe malformed-input handling.
  • Adds extensive formatting, on-type, and auto-insert coverage.
File Description
CohostOnTypeFormattingEndpointTest.cs Verifies XML is not formatted as C#.
CodeDirectiveFormattingTest.cs Covers formatting, braces, tabs, malformed input, and idempotence.
CohostOnAutoInsertEndpointTest.cs Prevents unwanted insertions while typing documentation.
RazorFormattingPass.cs Formats documentation directive brace structure.
CSharpFormattingPass.CSharpDocumentGenerator.cs Projects XML through Roslyn’s documentation formatter.
FormattingVisitor.cs Classifies documentation directives correctly.
documentation-directive.md Documents formatting and brace behavior.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 00:02
@davidwengier
davidwengier force-pushed the davidwengier/razor-doc-formatting branch from 79039c5 to f0b3333 Compare September 30, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 2 Low severity

Open (4)

Comment thread docs/razor/documentation-directive.md
Copilot stopped reviewing on behalf of davidwengier due to an error September 30, 2026 00:24
Copilot AI balanced review requested due to automatic review settings October 4, 2026 21:30
@davidwengier
davidwengier force-pushed the davidwengier/razor-doc-formatting branch from f0b3333 to 74382cf Compare October 4, 2026 21:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@davidwengier
davidwengier removed this pull request from stack #85729 October 4, 2026 21:37
The XML body should use the existing documentation-comment formatter, not Razor code formatting. Preserve source mappings and brace preferences so formatting and typing edits return to the right source spans.
Pin the Razor output for indentation, tabs, inline XML and malformed input in both file kinds. These tests exercise Razor's formatting and typing pipeline without separately testing Roslyn.
@davidwengier
davidwengier force-pushed the davidwengier/razor-doc-formatting branch from 74382cf to 3f67675 Compare October 4, 2026 22:39
@davidwengier
davidwengier changed the base branch from davidwengier/razor-doc-folding to main October 4, 2026 22:43
@davidwengier
davidwengier dismissed dibarbet’s stale review October 4, 2026 22:43

The base branch was changed.

Documentation directives can use the same diagnostic and directive-kind checks as other code block directives. Move IsDirectiveKind to the shared base so the formatting pass doesn't need a separate syntax type check.
Copilot AI balanced review requested due to automatic review settings October 5, 2026 00:56
@davidwengier
davidwengier requested a review from a team as a code owner October 5, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@davidwengier
davidwengier added this pull request to stack #85913 October 5, 2026 01:20
@davidwengier

Copy link
Copy Markdown
Member Author

@dibarbet for re-review after rebase

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants