public override SyntaxNode VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
        {
            if (Fields != null)
            {
                return(node);
            }

            Fields = RewritersHelper.ExtractFields(node);

            return(node);
        }
Exemple #2
0
        public override SyntaxNode VisitQueryBody(QueryBodySyntax node)
        {
            if (Fields != null)
            {
                return(node);
            }

            var last = node.DescendantNodes(descendIntoChildren: syntaxNode => true)
                       .LastOrDefault(x => x.IsKind(SyntaxKind.AnonymousObjectCreationExpression)) as AnonymousObjectCreationExpressionSyntax;

            if (last == null)
            {
                return(node);
            }

            // check if maybe we are nested
            var parent = last.Ancestors(ascendOutOfTrivia: true)
                         .FirstOrDefault(x => x.IsKind(SyntaxKind.AnonymousObjectCreationExpression)) as AnonymousObjectCreationExpressionSyntax;

            Fields = RewritersHelper.ExtractFields(parent ?? last);

            return(node);
        }