Generating additional code for the Roslyn compiler
One of the most powerful capabilities of the Roslyn compiler platform is the ability to generate additional code at compile time. This means that we can create new C# code during the compilation process and have it compiled alongside the rest of our code.
We will look into how you can leverage Roslyn to generate additional code for the compiler. This is super helpful and can help increase your and your team’s productivity by removing the need for repetitive tasks. Since you’re working inside the compiler, you’ll have to work with the language the compiler understands and how it represents code – Abstract Syntax Trees (ASTs).
ASTs
An AST is a data structure used to represent the structure of source code. You can compare it to what you already find in the .NET Expression APIs, as we saw in Chapter 7, Reasoning about Expressions. It is a hierarchy consisting of nodes that represent the code elements...