C# Source Generators - let the machine do the programming
summary
C# 9 source generators run during compilation and actually emit code that the compiler immediately includes, they ship commonly as NuGet-distributed packages and give direct access to Roslyn syntax and semantic models. Examples show a working Hello generator, a CSV file→class generator using additional files, an AutoNotify generator that produces INotifyPropertyChanged boilerplate, and .NET 6 JSON/Regex generators that remove reflection overhead and speed deserialization. Limitations include additive only, no ordering between generators and generated code visibility for diagnostics.
AI-written summary · about
