Code that writes code - .NET Source generators
summary
Shows how .NET Source Generators use the Roslyn APIs and an IIncrementalGenerator pipeline to emit C# at compile time, eliminating reflection and boilerplate. Demonstrates generators for strongly typed IDs, service registration, options binding via an additional text provider, and compile‑time mapping that emits diagnostics on mismatches. Emission is deterministic, cached by Roslyn, and only regenerates changed pieces, so performance stays fast; debugging works via debugger attach or unit tests.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:07Source generation in .NET
- 3:14Incremental generators
- 7:33Strongly typed identifiers
- 19:00Pitfalls in source generators
- 20:04Debugging generators
- 21:52Service registrations
- 29:24Options bindings from schema
- 36:52Domain to DTO mapping
- 47:58Benefits and use cases
- 50:07Q&A
related talks
55mCode that writes code - .NET Source generators
59mC# Source Generators - Write code that writes code
33mSource Generators in Action
59mSource generators v2.0 — Incremental Generators
33mMastering Source Generators
59mAutomating Observability With Roslyn Source Generators
01h 01mWriting Code with Code: Getting Started with the Roslyn APIs
01h 00mAutomate Yourself Out of a Job with Roslyn
