Summary
In this chapter, we explored how to leverage Roslyn compiler extensions for generating code at compile time. We looked at the basics of generating additional code for the compiler. We also looked at how you can leverage the Roslyn source generators to generate files other than C#, which is a powerful technique that can increase productivity and also provide true business value.
You should now have an understanding of what C# code generators are and how you can implement one. And hopefully, you also have a few ideas brewing of what you can use it for.
As I mentioned in the chapter, we use the compiler’s extensibility and ability to generate code to actually generate TypeScript code. This has proven to be a major productivity boost for our developers. There are some code generators already out there that take OpenAPI definitions and convert them into JavaScript or TypeScript, but they’re then limited to what this standard supports. And if you want it to be...