Exemplo n.º 1
0
        public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            var newList = new List<StatementSyntax>();
            foreach (var statement in node.Body.ChildNodes().OfType<StatementSyntax>())
            {
                if (statement.DescendantNodes().OfType<LambdaExpressionSyntax>().Any() ||
                    statement.DescendantNodes().OfType<SimpleLambdaExpressionSyntax>().Any())
                    newList.Add(GetConsoleWriteLine().WithTriviaFrom(statement));
                newList.Add(statement);
            }
            var newBlockNode = Block(newList).WithTriviaFrom(node.Body);

            var blockNode = node.Body;
            node = node.ReplaceNode(blockNode, newBlockNode);
            return base.VisitMethodDeclaration(node);
        }