Skip to content

Releases: autofac/Autofac.Extensions.DependencyInjection

v11.0.1

Choose a tag to compare

@tillig tillig released this 17 Jun 22:11

What's Changed

  • Updated Autofac from 9.1.0 to 9.2.0.
  • Updated Microsoft.Extensions.DependencyInjection.Abstractions from 10.0.4 to 10.0.9.

v11.0.0

Choose a tag to compare

@tillig tillig released this 31 Mar 16:34
303d9a8

Breaking Changes

  • Drop .NET 6 and .NET 7 targeting.
  • Add .NET 10 target.
  • Change the AnyKey support to use the new native support for AnyKey in core Autofac - this removes some of the custom internals used to support keyed services and moves that to core Autofac.

Other Changes

  • Updated benchmark suite to test more scenarios.
  • Executed some targeted performance improvements in the "glue" that maps M.E.DI behaviors to Autofac.
  • Updated Autofac dependency to v9.1.0.

Full Changelog: v10.0.0...v11.0.0

v10.0.0

Choose a tag to compare

@tillig tillig released this 02 Sep 03:43

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

v9.0.0

Choose a tag to compare

@tillig tillig released this 16 Jan 18:30

Breaking Changes

Additional Changes

  • Added keyed service support (IKeyedServiceProvider, IServiceProviderIsKeyedService, support for AnyKey) to match Microsoft.Extensions.DependencyInjection feature updates for .NET 8. (#115)

Full Changelog: v8.0.0...v9.0.0

v8.0.0

Choose a tag to compare

@tillig tillig released this 25 May 22:06

BREAKING CHANGE: IServiceScopeFactory is now a singleton and child scopes are flat, not hierarchical. Based on #83 and dotnet/runtime#67391, the IServiceScopeFactory is now registered as a singleton. Any scope you create from it is a peer, not a hierarchy like you might see in core Autofac. Even if you create a scope from a scope, it'll use the singleton factory under the covers and all scopes will be peers.

If you are using scopes to isolate units of work, be aware that this breaks the parent/child lifetime scope relationship.

// Based on an IServiceProvider...
IServiceProvider provider = CreateServiceProvider();

// You might want to create nested scopes to track work...
var unitOfWorkOutside = provider.CreateScope();

// And later have a sub-unit-of-work scope inside that...
var unitOfWorkInside = unitOfWorkOutside.ServiceProvider.CreateScope();

// But they're NOT RELATED! They don't share a resolution hierarchy
// so cached instances in the outer scope won't be seen in the inner
// scope. You can dispose that "outer scope" without affecting the
// "inner scope" at all because they're peers, not parent/child.
unitOfWorkOutside.Dispose();

// Still works because it's not a hierarchy!
unitOfWorkInside.ServiceProvider.GetRequiredService<MyService>();

If you need to create hierarchical scopes, you will need to use native Autofac constructs.

// Based on an IServiceProvider...
IServiceProvider provider = CreateServiceProvider();

// You'll need to get an Autofac lifetime scope.
var autofacScope = provider.GetService<ILifetimeScope>();

// Use the Autofac constructs to create hierarchical lifetimes.
var unitOfWorkOutside = autofacScope.BeginLifetimeScope();

// And later have a sub-unit-of-work scope inside that...
var unitOfWorkInside = unitOfWorkOutside.BeginLifetimeScope();

// Now they're related so they'll share a hierarchy. If you dispose the outer scope...
unitOfWorkOutside.Dispose();

// ...stuff in the inner scope will not resolve because you disposed its parent.
unitOfWorkInside.Resolve<MyService>();

BREAKING CHANGE: The Microsoft.Extensions.DependencyInjection dependency is now set at 6.0.0 for all target frameworks. M.E.DI v6 is compatible with all the frameworks Autofac.Extensions.DependencyInjection targets, so your application should be able to allow this through transitive dependencies. However, if you have a hard requirement to stay on an older version of M.E.DI for some reason, you won't be able to take this upgrade.

Autofac.AspNetCore.Multitenant has been updated to account for these changes. If you are using the multitenant ASP.NET Core support and update Autofac.Extensions.DependencyInjection, also be sure to take the latest Autofac.AspNetCore.Multitenant package.

The Autofac core version reference has also been updated to 6.4.0 to make sure fixes and features from the latest are included by default. This should not be a breaking change.

Full Changelog: v7.2.0...v8.0.0

v7.2.0

Choose a tag to compare

@alistairjevans alistairjevans released this 09 Nov 10:17

What's Changed

Full Changelog: v7.1.0...v7.2.0

v7.2.0-preview.1

v7.2.0-preview.1 Pre-release
Pre-release

Choose a tag to compare

@alistairjevans alistairjevans released this 15 Jul 19:55
553f288

Preview release for supporting .NET 6 Preview 6; adds support for IServiceProviderIsService.

v7.1.0

Choose a tag to compare

@alexmg alexmg released this 29 Oct 13:09
  • Fixes #82 - Allow the ContainerBuilderOptions to be provided when using the AutofacServiceProviderFactory

v7.0.2

Choose a tag to compare

@tillig tillig released this 06 Oct 14:14

Resolves #11: Assembly was incorrectly delay-signed for release. The assembly is now properly signed.

v7.0.1

Choose a tag to compare

@alistairjevans alistairjevans released this 28 Sep 20:27

This release fixes the missing package icon in the 7.0.0 release.