Breaking Changes
All instance dependencies are now considered ExternallyOwned
which means if you register an object instance in the dependency injection container through this package, when you dispose of the container it will not dispose of the provided instance. This is different than default Autofac behavior. Autofac normally assumes control of registered instances, where the Microsoft DI container does not. This change only affects instances registered using the Microsoft syntax and then populated into Autofac; it does not change the underlying Autofac container.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// The instance `item` here WILL NOT be disposed when the container is disposed
// because it's registered using Microsoft syntax and will be imported into Autofac.
var item = new MyDisposableItem();
services.AddSingleton(item);
}
public void ConfigureContainer(ContainerBuilder builder)
{
// The instance `item` here WILL be disposed when the container is disposed
// because it's registered using Autofac syntax directly with Autofac.
var item = new MyDisposableItem();
builder.RegisterInstance(item);
}
}
Additional Changes
- Optimization for reflection-activated components to avoid adding a parameter in the resolve path if possible. (@alistairjevans #119)
- Updated Autofac dependency to 8.1.0.
Full Changelog: v9.0.0...v10.0.0