This project is read-only.

GetDirectives method for CSharpSyntaxNode


It seem like there should be a way to enumerate over all directives under a node's sub-tree. There are currently GetFirstDirective and GetLastDirective methods, but if I want to enumerate over all directives, I have to do something like this, which may not be the most efficient way to do it:
public static IEnumerable<DirectiveTriviaSyntax> GetDirectives(this CSharpSyntaxNode node)
    if (node.ContainsDirectives == false)
        yield break;

    var directive = node.GetFirstDirective();
    while (directive != null && node.FullSpan.Contains(directive.Span))
        yield return directive;
        directive = directive.GetNextDirective();
Please add a GetDirectives method to CSharpSyntaxNode for this purpose.