Skip to content

Instantly share code, notes, and snippets.

@jcouv
Created March 9, 2016 18:56
Show Gist options
  • Save jcouv/d20e55eb4804b791c7d4 to your computer and use it in GitHub Desktop.
Save jcouv/d20e55eb4804b791c7d4 to your computer and use it in GitHub Desktop.
Repro for #8625
public void SyntaxNodeContains()
{
var text = "a + (b - (c * (d / e)))";
var expression = SyntaxFactory.ParseExpression(text);
var a = expression.DescendantNodes().OfType<IdentifierNameSyntax>().First(n => n.Identifier.Text == "a");
var e = expression.DescendantNodes().OfType<IdentifierNameSyntax>().First(n => n.Identifier.Text == "e");
var firstParens = e.FirstAncestorOrSelf<ExpressionSyntax>(n => n.Kind() == SyntaxKind.ParenthesizedExpression);
Assert.False(firstParens.Contains(a)); // fixing #8625 allows this to return quicker
Assert.True(firstParens.Contains(e));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment