Skip to content

Preserve indentation in XML doc comment CDATA sections - #84750

Open
HominoITea wants to merge 1 commit into
dotnet:mainfrom
HominoITea:fix-27150-cdata-indentation
Open

Preserve indentation in XML doc comment CDATA sections#84750
HominoITea wants to merge 1 commit into
dotnet:mainfrom
HominoITea:fix-27150-cdata-indentation

Conversation

@HominoITea

@HominoITea HominoITea commented Aug 4, 2026

Copy link
Copy Markdown

Fixes #27150

Summary

XML documentation formatting currently applies member indentation to every physical /// line, including content inside a CDATA section. Since whitespace inside CDATA is character data, this changes the authored indentation of code samples.

This change:

  • tracks CDATA boundaries while formatting single-line (///) documentation comments;
  • avoids adding compiler-generated indentation to CDATA content;
  • preserves the existing formatting behavior outside CDATA sections;
  • adds a regression test that compares the exact emitted XML documentation text.

Testing

  • CDataInCodeElementPreservesAuthoredIndentation
  • DocumentationCommentCompilerTests on net10.0
  • Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests on net10.0
  • Compiler test suite on CoreCLR via Compilers.slnf
  • Compilers.slnf build on Linux
Microsoft Reviewers: Open in CodeFlow

@HominoITea
HominoITea requested a review from a team as a code owner August 4, 2026 07:18
@azure-pipelines

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

@dotnet-policy-service dotnet-policy-service Bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Aug 4, 2026
@HominoITea

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

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

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML Doc Comment incorrectly indents code CDATA section

2 participants