Add documentation formatting and typing support - #85726
davidwengier wants to merge 5 commits into
Conversation
|
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. |
|
Copilot can't stop running |
a64ba08 to
79039c5
Compare
There was a problem hiding this comment.
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. |
79039c5 to
f0b3333
Compare
There was a problem hiding this comment.
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
Open (4)
The condition has become fairly dense (type checks + directive-kind check + two different… · New This file/class is now hosting a very large, directive-specific test suite for@documentation,… · New The “existing brace placement is preserved” phrasing could be interpreted as “no whitespace… · New Line-ending normalization via repeated.Replace("\r\n", "\n")is duplicated across many tests in… · New
f0b3333 to
74382cf
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The synthetic line-mapping logic is regression-sensitive, existing review threads remain unresolved, and current checks are still in progress.
Review effort: Balanced
Findings: 2
Open (4)
This file/class is now hosting a very large, directive-specific test suite for@documentation,… The condition has become fairly dense (type checks + directive-kind check + two different… Line-ending normalization via repeated.Replace("\r\n", "\n")is duplicated across many tests in… The “existing brace placement is preserved” phrasing could be interpreted as “no whitespace…
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.
74382cf to
3f67675
Compare
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.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Warning-bearing documentation blocks bypass brace formatting, and the user-facing option text remains outdated.
Review effort: Balanced
Findings: 1
Open (2)
Resolved since last review (4)
This file/class is now hosting a very large, directive-specific test suite for@documentation,… The condition has become fairly dense (type checks + directive-kind check + two different… Line-ending normalization via repeated.Replace("\r\n", "\n")is duplicated across many tests in… The “existing brace placement is preserved” phrasing could be interpreted as “no whitespace…
|
@dibarbet for re-review after rebase |


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.0andnetstandard2.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