Document ordering of SyntaxNode Ancestor methods#81857
Merged
CyrusNajmabadi merged 2 commits intomainfrom Jan 5, 2026
Merged
Conversation
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update documentation for SyntaxNode.Ancestors() order
Document ordering of SyntaxNode Ancestor methods
Jan 5, 2026
CyrusNajmabadi
approved these changes
Jan 5, 2026
Contributor
|
@dotnet/roslyn-compiler for more eyes. |
Member
FYI, the PR is in Draft state and doesn't have any labels |
Member
|
Can be merged with a single review single doc-only change. Thanks |
333fred
approved these changes
Jan 5, 2026
Contributor
Good to know. Thanks! |
This was referenced Jan 6, 2026
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.
The XML documentation for
Ancestors(),AncestorsAndSelf(), andFirstAncestorOrSelf()methods did not specify the traversal order, while similar methods likeDescendantNodes()explicitly document ordering as "in prefix document order."Changes
Updated XML documentation for four public methods in
SyntaxNode:Ancestors(): Returns "ancestor nodes in order from the innermost containing syntactic ancestor to the outermost"AncestorsAndSelf(): Returns "ancestor nodes (including this node) in order from this node to the outermost ancestor"FirstAncestorOrSelf<TNode>(): Clarifies "ancestors are searched in order from this node to the outermost ancestor"FirstAncestorOrSelf<TNode, TArg>(): Same clarification as aboveExample
This ordering allows reliable use of LINQ methods like
.First()to get the immediate parent or closest matching ancestor.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
kijvsblobprodcus387.vsblob.vsassets.io/usr/share/dotnet/dotnet dotnet build src/Compilers/Core/Portable/Microsoft.CodeAnalysis.csproj --no-incremental /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmSuccessEvaluationResult.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmCompilerId.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrAppDomain.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/IDkmClrFormatter.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationResultFlags.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Deb�� /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmDataItem.cs /home/REDACTED/work/roslyn/roslyn/src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmEvaluationFlags.cs(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.