Skip to content

Update dependency Autofac to 9.1.0#5378

Open
dependencyupdates[bot] wants to merge 1 commit intomasterfrom
renovate/autofac-9.x
Open

Update dependency Autofac to 9.1.0#5378
dependencyupdates[bot] wants to merge 1 commit intomasterfrom
renovate/autofac-9.x

Conversation

@dependencyupdates
Copy link
Contributor

@dependencyupdates dependencyupdates bot commented Mar 12, 2026

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
Autofac (source) 9.0.09.1.0 age adoption passing confidence

Release Notes

autofac/Autofac (Autofac)

v9.1.0

This is a pretty big release for Autofac with some major new functionality!

AnyKey Support

First, Autofac now natively supports the concept of AnyKey. It behaves the same way AnyKey works in Microsoft.Extensions.DependencyInjection, but it is native to Autofac directly. The unit tests here show some very detailed examples of usage, but on a high level:

var builder = new ContainerBuilder();
builder.RegisterType<Service>().Keyed<IService>(KeyedService.AnyKey);

var container = builder.Build();

// Registering as AnyKey allows it to respond to... any key!
var service = container.ResolveKeyed<IService>("service1");

Inject Service Key Into Constructors

The new [ServiceKey] attribute allows you to inject the service key provided during resolution. This is handy in conjunction with AnyKey. Again, this is similar to the construct in Microsoft.Extensions.DependencyInjection, but with native Autofac.

First, mark up your class to take the constructor parameter.

public class Service : IService
{
  private readonly string _id;
  public Service([ServiceKey] string id) => _id = id;
}

Then when you resolve the class, the service key will automatically be injected.

You can also make use of this in a lambda registration.

var builder = new ContainerBuilder();
builder.Register<Service>((ctx, p) => {
  var key = p.TryGetKeyedServiceKey(out string value) ? value : null;
  return new Service(key);
}).Keyed<Service>(KeyedService.AnyKey);

Metrics

Some metrics have been introduced that can allow you to capture counters on how long middleware is taking, how often lock contention occurs, and so on.

Set the AUTOFAC_METRICS environment variable in your process to true or 1 to enable this feature. You can see the set of counters that will become available here.

⚠️ This is NOT FREE. Collecting counters and metrics will incur a performance hit, so it's not something you want to leave on in production.

General Performance Improvements

A pass over the whole system was made with an eye to trying to claw back some performance. Some additional caching was introduced to help reduce lookups and calculations of reflection data; and a few hot-path optimizations were made for the common situations.

Full Changelog: autofac/Autofac@v9.0.0...v9.1.0


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot.

Commands to ignore dependencies

You can trigger dependency actions by commenting on this PR:

  • @particularbot ignore this major version
  • @particularbot ignore this minor version
  • @particularbot ignore this dependency

@dependencyupdates dependencyupdates bot added dependencies Pull requests that update a dependency file NuGet labels Mar 12, 2026
@dependencyupdates dependencyupdates bot force-pushed the renovate/autofac-9.x branch from 2d348b8 to 4343690 Compare March 13, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file NuGet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants