Skip to content

Fix #3845: Add option to expand XML documentation comments - #3855

Merged
siegfriedpammer merged 1 commit into
masterfrom
issue-3845-expand-xmldoc-comments
Jul 4, 2026
Merged

Fix #3845: Add option to expand XML documentation comments#3855
siegfriedpammer merged 1 commit into
masterfrom
issue-3845-expand-xmldoc-comments

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Fixes #3845.

Adds a Display option "Expand XML documentation comments after decompilation". Doc-comment folds were previously created with defaultCollapsed hardcoded to true; the new setting is bridged into DecompilerSettings like the existing expand flags (member definitions, using declarations) and drives the fold's default state. Changing it triggers a redecompile, and it is recorded/restored with bookmark view state.

Detecting the last line of a doc-comment block needs sibling navigation between trivia nodes, so trivia now carry parent/sibling-list/index state. Design: trivia is a separate navigation space, reachable only via LeadingTrivia/TrailingTrivia:

  • The sibling state lives on the Trivia subclass, so AstNode itself does not grow.
  • NextSibling/PrevSibling/Remove work within the owning trivia list; Slot is null; GetNextNode/GetPrevNode stop at the list boundary instead of escaping into the owner's child space.
  • Both ReplaceWith overloads throw for attached trivia instead of misinterpreting the trivia index in the parent's child-slot space.
  • Clone detaches the copy's sibling-list reference; CopyAnnotationsFrom deep-copies and reparents trivia instead of sharing the holder.
  • CheckInvariant (DEBUG) now validates trivia parent/list/index, and the doc-fold lookahead only continues a fold for a following Documentation comment, keeping folds balanced when regular comments follow.

Tests: new TriviaTests covering attach/prepend/remove/reattach, the ReplaceWith guards, clone detachment, navigation boundaries, and CopyAnnotationsFrom independence; TextTokenWriterTests covers the fold default and fold balancing. Verified locally: full ILSpy.sln build clean, PrettyTestRunner 1177 passed, ILSpy.Tests 973 passed.

🤖 Generated with Claude Code

Doc-comment folds were created with defaultCollapsed hardcoded to true,
so /// blocks always started collapsed. The new Display option is
bridged into DecompilerSettings like the other expand flags and drives
the fold's default state.

Detecting the last line of a doc-comment block requires sibling
navigation between trivia nodes, so trivia now carry parent, sibling
list, and index state. That state lives on the Trivia subclass to keep
AstNode's size unchanged, and the tree API treats trivia as a separate
navigation space: Next/PrevSibling and Remove work within the owning
list, Slot is null, ReplaceWith throws instead of aliasing the trivia
index into the parent's child slots, GetNextNode/GetPrevNode stop at
the list boundary, Clone and CopyAnnotationsFrom deep-copy and reparent
trivia, and CheckInvariant validates the trivia lists.

Assisted-by: Claude:claude-fable-5:Claude Code
@siegfriedpammer
siegfriedpammer merged commit 847324e into master Jul 4, 2026
13 checks passed
@siegfriedpammer
siegfriedpammer deleted the issue-3845-expand-xmldoc-comments branch July 4, 2026 08:49
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.

Expand everything please

1 participant