Fix #3845: Add option to expand XML documentation comments - #3855
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3845.
Adds a Display option "Expand XML documentation comments after decompilation". Doc-comment folds were previously created with
defaultCollapsedhardcoded totrue; the new setting is bridged intoDecompilerSettingslike 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:Triviasubclass, soAstNodeitself does not grow.NextSibling/PrevSibling/Removework within the owning trivia list;Slotisnull;GetNextNode/GetPrevNodestop at the list boundary instead of escaping into the owner's child space.ReplaceWithoverloads throw for attached trivia instead of misinterpreting the trivia index in the parent's child-slot space.Clonedetaches the copy's sibling-list reference;CopyAnnotationsFromdeep-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 followingDocumentationcomment, keeping folds balanced when regular comments follow.Tests: new
TriviaTestscovering attach/prepend/remove/reattach, theReplaceWithguards, clone detachment, navigation boundaries, andCopyAnnotationsFromindependence;TextTokenWriterTestscovers the fold default and fold balancing. Verified locally: fullILSpy.slnbuild clean,PrettyTestRunner1177 passed,ILSpy.Tests973 passed.🤖 Generated with Claude Code