Source Generators in .NET

.NET Source Generators are a C# compiler feature introduced in .NET 5 that allow code to be generated and injected into the compilation pipeline at build time. They enable boilerplate reduction and powerful metaprogramming patterns — but come with measurable build performance costs that are easy to overlook.

Source Generators: The Build Performance Killer Nobody Warned You About

Source Generators Hidden Costs

Source generators are powerful. They are also running on every single build, blocking IntelliSense, breaking Hot Reload, and multiplying their cost across every target framework you support. Nobody mentions this in the getting started guides. Here is how to measure the damage, find the culprits, and decide when source generators are actually worth it.