Shiny Mediator & AOT - Zero Reflection, Full Speed
Native AOT, trimming, and iOS’s no-JIT constraint make reflection a liability. Shiny Mediator has gone all-in on source generation, replacing every runtime introspection point with compile-time code. This deep dive walks through each source generator and the design decisions behind them.
What you’ll learn
- How
[MediatorSingleton]/[MediatorScoped]attributes replace assembly scanning with compile-time DI registration - How typed executors eliminate
MakeGenericTypeandActivator.CreateInstancefor request dispatch - The custom JSON serialization source generator that sidesteps the
System.Text.Jsonchaining limitation - How
[ContractKey]generates cache and offline storage keys without property reflection - How middleware attributes are extracted at compile time so
context.GetHandlerAttribute<T>()works withoutGetCustomAttributes() - OpenAPI HTTP client generation: contracts, handlers, JSON converters, and DI registration from a single MSBuild item
- ASP.NET endpoint source generation from handler method attributes