Autofac v6.0.0 Release Notes
Release Date: 2020-09-28 // about 4 years ago-
π Version 6.0.0 represents a major update in the Autofac internals. While every effort has been made to ensure code using version 5.x will continue to work exactly as you expect, you should be aware of the breaking changes and test things out. For the majority case, things should just continue to work; breaking changes are primarily in more rare advanced usage scenarios.
π Check out the release blog post! Also, the documentation has been updated and is ready!
π > β οΈ Starting with Autofac 6.0, we now only target
netstandard20
andnetstandard21
; we have removed the explicit target fornet461
.π > The impact to you is that, while Autofac will still work on .NET Framework 4.6.1 as it did before, we strongly encourage you to upgrade to .NET Framework 4.7.2 or higher, as per the .NET Standard Documentation, to avoid any of the known dependency issues when using .NET Standard packages in .NET Framework 4.6.1.
π New Features
π There are a lot of new features, but the big ones are here. Other features and fixes will be outlined in the Issues section, below.
- Pipelines : This is the major change in Autofac v6 - all resolution activities internally now flow through pipelines, similar to how ASP.NET Core requests flow through pipelines. This allows for better customization in how things get resolved as well as enabling support for more new features.
- Composites : The composite pattern allows a collection of objects to be treated as though it's a single object.
- Diagnostics : Autofac v6 adds support for
DiagnosticSource
diagnostics. The core Autofac package ships with a default text-based diagnostic tracer and the newAutofac.Diagnostics.DotGraph
package adds graphic tracing using DOT and Graphviz. - Generic Delegate Registrations : You can now register an open generic associated with a delegate/lambda expression, allowing you to provide a custom factory to resolve generics just like you do with non-generic types.
- π Concurrency Performance Improvements : We focused a lot on performance and have removed a lot of locking. In some highly-concurrent cases, we've seen a 4x speed increase.
Issues and PRs
The following issues have been addressed in v6:
- π #718: Circular dependency support using property injection and relationships like
Lazy<T>
should now work. - π¦ #788: DOT graph support has been added via the
Autofac.Diagnostics.DotGraph
package. - π #798 / #1148: Circular dependency handling uses the .NET runtime to check stack depth when checking for circular dependencies rather than using a fixed stack depth.
- #828: The
ILifetimeScope.LifetimeScopeEnding
event is raised and completes before the scope is disposed. - π #970: The composite pattern is now supported.
- #1069 / #1172: Core Autofac events are now async-friendly.
- #1120 / #1128:
ContainerBuilder
is nowsealed
. - #1123: Explicitly injected properties can now be declared using an expression.
- #1126 / #1169: Diagnostics are handled via
DiagnosticSource
. - π¦ #1162: A new "pooled" lifetime type has been added via the
Autofac.Pooling
package.
π₯ Breaking Changes
π We'll do our best to keep an upgrade guide with breaking changes available and up to date. We're pretty sure we caught them all, but if you find a gotcha, let us know on the Documentation repo.
A summary of the breaking changes is as follows:
net461
is no longer targeted ; Autofac now targetsnetstandard2.0
andnetstandard2.1
.- Activation events are no longer exposed - this all happens through middleware now.
- If you were using an Autofac module to attach to activation events and inject parameters, similar to the way the
log4net
module example is shown in the document, this now needs to happen through middleware. Thelog4net
module example has been updated to show you the new way it works. RegistrationBuilder.RegistrationData
no longer exposes activation handlers. TheCoreEventMiddleware
is the source of events now.IComponentRegistration
no longer exposes activation events. TheCoreEventMiddleware
is the source of events now.
- If you were using an Autofac module to attach to activation events and inject parameters, similar to the way the
- Interface changes :
IConstructorSelector
implementations need to switch to useBoundConstructor
instead ofConstructorParameterBinding
.IRegistrationSource
implementations need to update theRegistrationsFor
method signature.IInstanceActivator
implementations no longer have anActivateInstance
method and instead have aConfigurePipeline
method.IComponentRegistry
no longer supplies aDecoratorsFor
method to check decorators. UseIComponentRegistry.ServiceMiddlewareFor
instead.- The
ResolveRequest
constructor now takes aServiceRegistration
instead of anIComponentRegistration
.
ContainerBuilder
is nowsealed
.
Still Todo
π¦ We're working hard to get all of the ~25 integration packages pushed to NuGet as quickly as we can, so please bear with us while we get these sorted.
π¦ Some of this is sitting in branches ready to go, other things need to be done now that we have this core package out there.
If your favorite integration isnβt ready yet, weβre doing our best. Rather than filing "When will this be ready?" issues, consider pull requests with the required updates.