A conference talk walkthrough of .NET incremental source generators, covering how they hook into the Roslyn compiler pipeline to generate code at compile time. Practical examples include: generating strongly-typed ID structs from an attribute, auto-registering dependency injection services, binding and validating IOptions configuration classes from external schema files, and generating object-to-DTO mapping extension methods with compile-time type checking. The talk explains the scout/predicate/transformer/collect pipeline pattern for performance, how to emit diagnostics as compiler errors, and how to test generators using snapshot testing with the Verify library instead of the clunky two-Visual-Studio debugging approach.

55m watch time

Sort: