.NET Core, Roslyn and Code Generation

For ages I’ve been using T4 templates as main tool for code generation and scaffolding, but now that I’m an absolute fan of Visual Studio Code and .Net Core I need to explore other options such as Yeoman, Scripty and Roslyn. This post is just the result of my first and simplest experiment with .Net Core, Roslyn and Code Generation.

In the following sample we will take a class and replace the namespace with another. My intention is just to show you the tip of the iceberg of what you can accomplish with these tools…

1. Create the application
2. Replace the contents of project.json
3. Replace the contents of Program.cs
4. Run the application

Get a copy of the code here: https://github.com/cmendible/dotnetcore.samples/tree/master/roslyn.codegeneration

Hope it helps!

3 thoughts on “.NET Core, Roslyn and Code Generation

Leave a Reply