May 16, 2026 ยท ๐ ~6 min read
Adding a new plugin to this sample app is almost suspiciously easy. Drop a class into the project that implements ICommandPlugin or IStartupPlugin, build, and it just works. No services.AddSingleton<โฆ>() to write. No attribute required. No manifest file. No reflection scan at startup.
That's not magic โ it's a C# source generator doing what you'd otherwise do by hand: writing the DI registration code for you, at compile time, into a partial method the rest of the codebase already knows about.
This post walks through why that matters, using the SourceGeneratedDIRegistration sample as a hands-on example. It's small enough to read in an afternoon but hits every interesting corner of a real-world generator.
March 14, 2026 ยท ๐ ~6 min read
In the previous article we explored how the LoggerMessage attribute uses source generators to create high-performance logging code via static extension methods. That approach works great for shared log methods, but it requires you to pass the ILogger instance on every call. In this follow-up we'll look at two features that reduce boilerplate even further: non-static partial methods that access the logger from the primary constructor, and automatic exception recognition.
October 11, 2025 ยท ๐ ~5 min read
Logging is essential for monitoring and debugging applications, but it can become a performance bottleneck when not implemented efficiently. The LoggerMessage attribute, introduced in .NET 6, offers a powerful solution that combines high performance with developer-friendly APIs. In this article, we'll explore how this attribute reduces logging overhead, handles exceptions gracefully, and leverages source generators to create optimized code.