Developing Source Generators in C#
C# Source Generators can analyze your code and generate new C# code while your project is compiling. This course will teach you how to build and use C# Source Generators in your .NET applications.
What you'll learn
When building .NET applications, you often have to write repetitive code. Instead of manually writing that code, you can generate it with a C# Source Generator. In this course , Developing Source Generators in C#, you’ll learn how to use a C# Source Generator to analyze your code and to generate additional C# code while your project is compiling. First, you’ll explore what a C# Source Generator is and what problems it helps you to solve. Next, you will create a C# Source Generator. You will learn how to set it up, how to analyze the syntax of your code, how to generate a source file, and how to add that source file on the fly to the compilation. Finally, you’ll learn how to package the source generator in a NuGet package, so that you can use it in different .NET projects. When you're finished with this course, you’ll have the skills and knowledge of C# Source Generators needed to build and use C# Source Generators in your .NET projects.
Table of contents
- Introduction 1m
- Generate a Partial Class 5m
- Understand the Syntax API 8m
- Debug Your Source Generator 6m
- Grab the Namespace 4m
- Support File-scoped Namespaces 4m
- Generate a ToString Method 4m
- Split up the ToString Generation 4m
- Write out the Members 7m
- Check the Access Modifier 3m
- See Live How Code Is Generated 2m
- Summary 1m
- Introduction 1m
- The Problem with the Attribute 5m
- What Is the Semantic Model? 8m
- Check the Attribute 8m
- Another Case for the Semantic Model 5m
- Create a Model 3m
- Use the Model 7m
- Iterate over the Members 6m
- Analyze the Performance 5m
- Understand How the Cache Works 3m
- Implement Equals on the Model 7m
- Use Collect in the Pipeline 6m
- Summary 1m