Skip to main content

Awaiten Nuget

Awaiten logo

The async-first dependency injection container for .NET.

Awaiten is a Roslyn source generator. It wires your object graph at build time, so there is no runtime reflection and the generated code is plain, readable C#. Your container is native-AOT clean and trim-safe out of the box.

The configuration is verified by the compiler. Missing, cyclic, ambiguous, and lifetime-mismatched registrations are build errors, not surprises at startup. Awaiten ships around 90 diagnostics for this.

Its headline feature is async initialization. Some services need asynchronous setup after construction, like an espresso machine heating its boiler or a payment terminal connecting to the bank. Awaiten tracks those through the graph, and reaching one synchronously before it is ready is a compile error.

A first shot

Think of the container as a coffee shop. The espresso machine is shared, so it is a singleton. Each order gets its own scope. A cup is made fresh every time, so it is transient.

using Awaiten;

[Container]
[Singleton<EspressoMachine>]
[Scoped<Order>]
[Transient<Cup>]
public static partial class CoffeeShop;

await using var shop = new CoffeeShop.Root();
await shop.InitializeAsync(); // the espresso machine warms up

var cup = shop.Resolve<Cup>(); // a fresh cup, wired and ready

Why Awaiten

Reflection-based containersAwaiten
WiringAt runtime, via reflectionAt build time, as plain C#
Bad configurationFails at startup or first resolveFails at compile time
Async setupManual, easy to forgetTracked, enforced by the compiler
Native AOT / trimmingNeeds care, often breaksClean by construction

Getting started

  1. Install the package.
  2. Declare a [Container] and register your services.
  3. Create a Root and start resolving.

Where to go next

Packages

PackageDescription
AwaitenThe core: attributes, the source generator, and the runtime seams. No third-party dependencies.
Awaiten.Extensions.DependencyInjectionMicrosoft.Extensions.DependencyInjection interop for ASP.NET Core, the generic host, and other containers. See the MS.DI bridge.