Roslyn Source Generators Never send a human to do a machine's job
summary
Explains concrete mechanics: C# 9 adds partial methods with visibility and module initializers that let Roslyn generators emit implementations at compile time; .NET 6 ships System.Text.Json source generator and logging generators to remove reflection. Shows generator anatomy (ISourceGenerator, Initialize/Execute or Incremental generators in Roslyn 4.0), testing with Microsoft.CodeAnalysis.Testing, packaging to NuGet (analyzers under analyzers/netstandard2.0), debugging tips, and a benchmark where generated enum-to-string runs ~1.6ns vs 25ns for reflection.
AI-written summary · about
chapters (14)
- 0:00Start
- 3:43Support for Source Generators
- 5:47Module Initializers
- 7:15The Laws of Source Generation with Rustling
- 11:19Vlogging
- 19:34Syntax Receiver
- 24:24Testing
- 31:54Syntax Visualizer
- 33:54Debugging
- 34:41Define a Launch Profile
- 40:09Versioning
- 45:33Syntax Provider
- 46:46Incremental Source Generators
- 55:10Are There any Reasons Not To Always Use the Incremental Generator
related talks
54mExploring Source Generators
01h 12mC# Source Generators in Action
01h 04mLet's Code an incremental source generator with Roslyn
01h 00mLet's Code an incremental source generator with Roslyn
01h 15mLet’s Build an Incremental Source Generator With Roslyn
42mC# Code Generators: Writing Code That Writes Code
50mImproving Source Code with Roslyn
59mAutomating Observability With Roslyn Source Generators
