Source Generators in Action
summary
Shows how to implement a real .NET source generator: project settings (class library targeting netstandard2.0, NuGet attributes), required workarounds (copying System.Text.Json DLLs into the build so the generator can access external files), and usage of templating libraries (Mustache, Scriban). Demonstrates generating mapper code from JSON for hundreds of API types, viewing the generated files in the IDE, debugging generators in Rider and Visual Studio, and compares use cases — one‑off bulk generation versus long‑running generators that replace runtime reflection (for example in Mediator) to improve execution speed.
AI-written summary · about
chapters (18)
- 0:00Source Generators intro
- 1:50Source Generators purpose
- 6:14How Source Generators work
- 7:20First Source Generator
- 12:08Code generation from files
- 14:20Generation templates
- 15:44Dependencies and troubleshooting
- 16:51Debugging in VS
- 18:00Debugging in Rider
- 20:31Automatic debugging
- 21:55Viewing generated files
- 22:40Generated files in project
- 23:23Practical use cases
- 27:05Single vs. multiple scenarios
- 28:08Compile time impact
- 29:12Why hard to develop
- 30:42Comparison with old methods
- 31:24Source Generators future
related talks
33mMastering Source Generators
59mC# Source Generators - Write code that writes code
55mCode that writes code - .NET Source generators
52mCode that writes code - .NET Source generators
59mSource generators v2.0 — Incremental Generators
51mGenerate You Some Code for Great Good
01h 02mUse your source code to document your application
37mThings I learned after a decade of writing code generators
