public static SyntaxNode UnaryOperator(UnaryOperatorKind kind, SyntaxNode reference) { if (reference == null) { return(SyntaxFactory.EmptyStatement()); } SyntaxNode statement; var operatorKind = kind.ToSyntaxKind(); if (kind == UnaryOperatorKind.PostDecrement || kind == UnaryOperatorKind.PostIncrement) { statement = SyntaxFactory.PostfixUnaryExpression(operatorKind, reference as ExpressionSyntax); } else { statement = SyntaxFactory.PrefixUnaryExpression(operatorKind, reference as ExpressionSyntax); } return(statement); }