Created
September 21, 2025 15:08
-
-
Save TheLeftExit/175e004beb280c43af69f3d796ecffc4 to your computer and use it in GitHub Desktop.
HelloWorldHelloWorld.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.CodeAnalysis; | |
| using Microsoft.CodeAnalysis.CSharp; | |
| using Microsoft.CodeAnalysis.CSharp.Syntax; | |
| using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; | |
| CompilationUnit() | |
| .WithUsings( | |
| SingletonList( | |
| UsingDirective( | |
| IdentifierName("System") | |
| ) | |
| ) | |
| ) | |
| .WithMembers( | |
| SingletonList<MemberDeclarationSyntax>( | |
| ClassDeclaration("Program") | |
| .WithModifiers( | |
| TokenList( | |
| Token(SyntaxKind.PublicKeyword), | |
| Token(SyntaxKind.StaticKeyword) | |
| ) | |
| ) | |
| .WithMembers( | |
| SingletonList<MemberDeclarationSyntax>( | |
| MethodDeclaration( | |
| PredefinedType( | |
| Token(SyntaxKind.VoidKeyword) | |
| ), | |
| "Main" | |
| ) | |
| .WithModifiers( | |
| TokenList( | |
| Token(SyntaxKind.PublicKeyword), | |
| Token(SyntaxKind.StaticKeyword) | |
| ) | |
| ) | |
| .WithBody( | |
| Block( | |
| ExpressionStatement( | |
| InvocationExpression( | |
| MemberAccessExpression( | |
| SyntaxKind.SimpleMemberAccessExpression, | |
| IdentifierName("Console"), | |
| IdentifierName("WriteLine") | |
| ) | |
| ) | |
| .WithArgumentList( | |
| ArgumentList( | |
| SingletonSeparatedList( | |
| Argument( | |
| LiteralExpression( | |
| SyntaxKind.StringLiteralExpression, | |
| Literal("Hello world!") | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| .NormalizeWhitespace() | |
| .WriteTo(Console.Out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment