Open RalfKoban opened 4 years ago
public IEnumerable<SyntaxNode> Ancestors(bool ascendOutOfTrivia = true)
{
return this.Parent?
.AncestorsAndSelf(ascendOutOfTrivia) ??
SpecializedCollections.EmptyEnumerable<SyntaxNode>();
}
should likely be updated to be:
public IEnumerable<SyntaxNode> Ancestors(bool ascendOutOfTrivia = true)
{
return GetParent(this, ascendOutOfTrivia)?
.AncestorsAndSelf(ascendOutOfTrivia) ??
SpecializedCollections.EmptyEnumerable<SyntaxNode>();
}
Version Used: 3.6
Steps to Reproduce:
DocumentationCommentTriviaSyntax
that represents the comment in following snippet:SyntaxNode.Ancestors()
andSyntaxNode.AncestorsAndSelf(true)
on theDocumentationCommentTriviaSyntax
.Ancestors()
does neither return theFieldDeclarationSyntax
, nor theClassDeclarationSyntax
, nor theCompilationUnitSyntax
. In contrast,AncestorsAndSelf()
returns them all.Expected Behavior: Invoking
SyntaxNode.Ancestors(true)
on aDocumentationCommentTriviaSyntax
returns all ancestors, similar toSyntaxNode.AncestorsAndSelf(true)
, except the trivia (no self).Actual Behavior:
SyntaxNode.Ancestors(true)
invoked on aDocumentationCommentTriviaSyntax
returns no ancestors.SyntaxNode.AncestorsAndSelf(true)
invoked on the sameDocumentationCommentTriviaSyntax
not only returns the trivia as expected, but also all the other ancestors thatSyntaxNode.Ancestors(true)
is missing to return.