C# Source Generators in Action
summary
A live demo builds a .NET Standard 2.0 source generator in about 15 minutes that removes boilerplate by generating partial types from backing fields, exemplified by an INotifyPropertyChanged generator that compiles and fires correctly, and a log decorator via generated proxy that adds before/after logging. Implementation uses Roslyn semantic model APIs, sourcegen.dev for examples, tests by compiling sample code and running generators, and notes that generators run often (about three runs per symbol), cannot modify existing auto properties, and require diagnostics and cancellation handling to be safe and fast.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:01Why and what are Source Generators?
- 4:12Demo: INotifyPropertyChanged Source Generator
- 22:53Source Generators vs. ...
- 23:20Source Generators vs. IL weaving
- 30:30Source Generators vs. IL generation
- 31:32Source Generators vs. Reflection
- 33:26How will generators change metaprogramming?
- 34:32Common problems and best practices
- 35:02Sharing source generators with Nuget
- 36:27How do source generators fit together?
- 1:00:50Best practices
- 1:01:18Summary
- 1:03:25Q&A
related talks
54mExploring Source Generators
42mC# Code Generators: Writing Code That Writes Code
01h 02mRoslyn Source Generators Never send a human to do a machine's job
01h 00mLet's Code an incremental source generator with Roslyn
01h 15mLet’s Build an Incremental Source Generator With Roslyn
01h 04mLet's Code an incremental source generator with Roslyn
34mBlazorators: C# Source Generators for Blazor
59mAutomating Observability With Roslyn Source Generators
