Skip to content

'DocumentationCommentTriviaSyntax.Ancestors(true)' does not return any ancestors but 'AncestorsAndSelf(true)' does #46964

@RalfKoban

Description

@RalfKoban

Version Used:
3.6

Steps to Reproduce:

  1. Get the DocumentationCommentTriviaSyntax that represents the comment in following snippet:
public class TestMe
{
    /// <summary>
    /// Some summary.
    /// </summary>
    /// <value>
    /// Some value.
    /// </value>
    private int i;
}
  1. Invoke SyntaxNode.Ancestors() and SyntaxNode.AncestorsAndSelf(true) on the DocumentationCommentTriviaSyntax.
  2. Compare the results and find out that Ancestors() does neither return the FieldDeclarationSyntax, nor the ClassDeclarationSyntax, nor the CompilationUnitSyntax.
    In contrast, AncestorsAndSelf() returns them all.

Expected Behavior:
Invoking SyntaxNode.Ancestors(true) on a DocumentationCommentTriviaSyntax returns all ancestors, similar to SyntaxNode.AncestorsAndSelf(true), except the trivia (no self).

Actual Behavior:
SyntaxNode.Ancestors(true) invoked on a DocumentationCommentTriviaSyntax returns no ancestors.

SyntaxNode.AncestorsAndSelf(true) invoked on the same DocumentationCommentTriviaSyntax not only returns the trivia as expected, but also all the other ancestors that SyntaxNode.Ancestors(true) is missing to return.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions