public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
            {
                if (node == null)
                {
                    throw new ArgumentNullException(nameof(node));
                }

                if (_previousIf?.Equals(node.GetPreviousIf()) != false)
                {
                    if (node.Statement?.IsKind(SyntaxKind.Block) == false)
                    {
                        IfStatementSyntax ifStatement = node.WithStatement(SyntaxFactory.Block(node.Statement));

                        _previousIf = ifStatement;

                        return(base.VisitIfStatement(ifStatement));
                    }
                    else
                    {
                        _previousIf = node;
                    }
                }

                return(base.VisitIfStatement(node));
            }
예제 #2
0
            public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
            {
                if (node == null)
                {
                    throw new ArgumentNullException(nameof(node));
                }

                if (_previousIf == null ||
                    _previousIf.Equals(node.GetPreviousIf()))
                {
                    if (node.Statement?.IsKind(SyntaxKind.Block) == true)
                    {
                        IfStatementSyntax ifStatement = node.WithStatement(((BlockSyntax)node.Statement).Statements[0]);

                        _previousIf = ifStatement;

                        return(base.VisitIfStatement(ifStatement));
                    }
                    else
                    {
                        _previousIf = node;
                    }
                }

                return(base.VisitIfStatement(node));
            }
            public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
            {
                if (_previousIf?.Equals(node.GetPreviousIf()) != false)
                {
                    if (node.Statement?.Kind() == SyntaxKind.Block)
                    {
                        IfStatementSyntax ifStatement = node.WithStatement(((BlockSyntax)node.Statement).Statements[0]);

                        _previousIf = ifStatement;

                        return(base.VisitIfStatement(ifStatement));
                    }
                    else
                    {
                        _previousIf = node;
                    }
                }

                return(base.VisitIfStatement(node));
            }