The async-first dependency injection container for .NET.
Awaiten is a Roslyn source generator that wires your object graph at build time. There is no runtime reflection, the generated code is plain readable C#, and your container is native-AOT clean. The configuration is verified by the compiler: missing, cyclic, ambiguous, and lifetime-mismatched registrations are build errors.
Its headline feature is async initialization. Services that need asynchronous setup after construction, like opening a connection or handshaking with hardware, are tracked through the graph. Reaching one before it is ready is a compile error.
using Awaiten;
[Container]
[Singleton<EspressoMachine>]
[Scoped<Order>]
[Transient<Cup>]
public static partial class CoffeeShop;
await using var shop = new CoffeeShop.Root();
await shop.InitializeAsync(); // async-initialized services are warmed up
var cup = shop.Resolve<Cup>();Install with:
dotnet add package Awaiten- Async initialization.
IAsyncInitializableservices are initialized in dependency order, and reaching one synchronously is a compile error. - Compile-time safety. Around 70 diagnostics turn wiring mistakes into build errors instead of startup crashes.
- No reflection. The generated code is plain C#, so the container is native-AOT clean and trim-safe.
- A full toolbox. Lifetimes, scopes, keyed services, decorators, composites, open generics, collections, factories, modules, assembly scanning, property injection, and
Owned<T>for disposable transients. - MS.DI interop. A separate package bridges into Microsoft.Extensions.DependencyInjection for ASP.NET Core and the generic host.
| Package | Description |
|---|---|
Awaiten |
The core: attributes, the source generator, and the runtime seams. No third-party dependencies. |
Awaiten.Extensions.DependencyInjection |
Microsoft.Extensions.DependencyInjection interop (ASP.NET Core, generic host, and other containers). |
Full documentation lives at docs.testably.org/Awaiten.
- Getting started
- Registration: lifetimes, factories and instances, decorators, composites, keyed services, open generics, scanning, modules
- Resolution: resolving services, relationships, collections, keyed dictionaries, property injection, runtime arguments, context-aware factories
- Async initialization
- Lifetime and disposal: scopes, disposal, owned, lifetime safety, lifecycle hooks
- Advanced: external services, generic variance
- MS.DI bridge
- Diagnostics
- Complete example