Example #1
0
        ExpressionSyntax NameOfSyntax(SyntaxToken identifier)
        {
            if (LanguageVersion.SupportsNameOf())
            {
                return
                    (InvocationExpression(
                         IdentifierName("nameof"),
                         ArgumentList(
                             SingletonSeparatedList(
                                 Argument(
                                     IdentifierName(identifier)
                                     )))));
            }

            return
                (LiteralExpression(
                     SyntaxKind.StringLiteralExpression,
                     Literal(identifier.Text)
                     ));
        }