Validation and Native AOT

Validate

container.Validate();

Validate walks every registration’s constructor without creating anything and throws an AggregateException with one InvalidOperationException per problem:

Factory registrations can’t be inspected and are skipped. Use ContainerBuilder { ValidateOnBuild = true } or new YoctoServiceProviderFactory(validateOnBuild: true) to validate automatically.

At runtime, circular dependencies are also detected and reported instead of overflowing the stack.

Native AOT and trimming

yocto is built with IsAotCompatible, and its public API carries [DynamicallyAccessedMembers] annotations, so the trimmer keeps the constructors you register:

container.Register<IGreeter, Greeter>();   // Greeter's public constructors are preserved
<PublishAot>true</PublishAot>

Constructors are invoked with ConstructorInvoker — no Reflection.Emit. Caveats:

Next: Migrating to yocto 3 →

Last reviewed October 13, 2026 · yocto 3.0.0