public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node)
                {
                    if (node != this.ContainerOfStatementsOrFieldToReplace)
                    {
                        return(base.VisitWhileStatement(node));
                    }

                    return(node.WithCondition(VisitNode(node.Condition))
                           .WithStatement(node.Statement));
                }
Esempio n. 2
0
        public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node)
        {
            var annotation = node.GetAnnotations(Annotations.AnnotationKind).FirstOrDefault();

            if (annotation == null)
            {
                return(base.VisitWhileStatement(node));
            }

            var instrumentedExpression = SyntaxFactory.BinaryExpression(SyntaxKind.LogicalAndExpression,
                                                                        SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression),
                                                                        node.Condition).WithAdditionalAnnotations(annotation);

            node = node.WithCondition(instrumentedExpression);

            return(base.VisitWhileStatement(node));
        }