using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; // Create an instance of IASTFactory var astFactory = SyntaxFactory.GetFactory(LanguageNames.CSharp); // Create a new expression statement IExpressionStatementSyntax expressionStatement = astFactory.ExpressionStatement( astFactory.InvocationExpression( // Method being invoked astFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, astFactory.IdentifierName("Console"), astFactory.IdentifierName("WriteLine")), // Arguments to the method being invoked astFactory.ArgumentList( SyntaxFactory.SeparatedListIn the example above, we are creating a new instance of IASTFactory using the SyntaxFactory class from the Microsoft.CodeAnalysis package. We then create a new expression statement using the ExpressionStatement method provided by the IASTFactory interface. This expression statement represents a call to the Console.WriteLine method with the arguments "Hello World" and "myVariable".( new SyntaxNodeOrToken[]{ astFactory.LiteralExpression( SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal("Hello World")), SyntaxFactory.Token(SyntaxKind.CommaToken), astFactory.IdentifierName("myVariable") })))));