From Autofac 5, we will no longer provide a target for .NET 4.5. The minimum version of .NET Framework you can use Autofac with is .NET 4.6.1.
The full targeting list is now:
- netstandard2.1
- netstandard2.0
- net461
The Container Registry can no longer be updated after it has been built.
The ContainerBuilder.Update
method had already been marked as obsolete,
and has now been removed.
If you want to change registration behaviour, you should do it in a lifetime scope that overrides the behaviour from the root container.
Autofac Lifetime Scopes now implement the IAsyncDisposable interface, meaning that they can be disposed of asynchronously:
await using (var scope = container.BeginLifetimeScope())
{
var service = scope.Resolve<ServiceThatImplementsIAsyncDisposable>();
// When the scope disposes, any services that implement IAsyncDisposable will be
// Disposed of using DisposeAsync rather than Dispose.
}
PR #1037
The Autofac Library is now built with Nullable Reference Type annotations.
https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
The upshot of this is that users will get sensible compiler warnings if they also use nullable refence functionality, and then use a method like 'TryResolve', or pass null to Autofac where they shouldn't.
PR #1056
Fixes #985.
Build callbacks can now execute at the point of lifetime scope creation if new ones have been registered.
So, this works:
var scope = container.BeginLifetimeScope(cfg =>
{
cfg.RegisterBuildCallback(scope => { /* do something */ });
});
The callback will be invoked just prior to BeginLifetimeScope exiting, after any startable components are instantiated (same behaviour as the Container).
PR #1054
Fixes #1020.
Resolving a service from a lifetime scope will now check all parent scopes to make sure none of them have been disposed.
The effect of this is that disposing a parent scope, and then trying to resolve from
a child scope, will throw an ObjectDisposedException
,
whereas before it would 'sort of' work, until it didn't.
PR #1061
Fixes #1013.
Prevent Autofac injecting services onto static properties when auto-wiring of properties is enabled.
This may be a breaking change for anyone depending on the old accidental behaviour.
PR #1021