JasperFx / lamar

Fast Inversion of Control Tool and Successor to StructureMap
https://jasperfx.github.io/lamar
MIT License
573 stars 119 forks source link

Add support for .NET 8 keyed services #388

Closed Simble closed 1 year ago

Simble commented 1 year ago

The .NET DI container now has support for keyed services. See: https://weblogs.asp.net/ricardoperes/net-8-dependency-injection-changes-keyed-services

However, Lamar's ServiceRegistry does not implement the new/required interface methods yet and therefore when trying to use a keyed service, you will run in to run time error of System.InvalidOperationException with message "This service descriptor is keyed. Your service provider may not support keyed services."

rizi commented 1 year ago

@jeremydmiller can we use the current version of lamar as long as we don't use keyed services in .net 8/aspnet.core 8 or does lamar needed to be extended? I want to upgrade to .net 8/aspnet.core 8 when it gets released (14. november)

Br

jbogard commented 1 year ago

plz fix your library it's blocking MediatR from releasing

rizi commented 1 year ago

plz fix your library it's blocking MediatR from releasing

@jbogard I'm curious, do you use KeyedServices explicitly or why isn't the current version of Lamar working (as long as you use "named registrations" instead of KeyedServices)

Br

jbogard commented 1 year ago

The package explicitly excludes 8.0 in its version ranges

lt-nvos commented 1 year ago

Lamar currently indeed restricts updating a project to .NET 8.0:

Lamar.Microsoft.DependencyInjection 12.0.1 -> Microsoft.Extensions.Options (>= 6.0.0 && < 8.0.0)

An update would be greatly appreciated.

jeremydmiller commented 1 year ago

@jeremydmiller can we use the current version of lamar as long as we don't use keyed services in .net 8/aspnet.core 8 or does lamar needed to be extended? I want to upgrade to .net 8/aspnet.core 8 when it gets released (14. november)

Br

To the best of my knowledge, yes

jeremydmiller commented 1 year ago

Folks, .NET 8 went GA yesterday. A little patience please.

jeremydmiller commented 1 year ago

https://weblogs.asp.net/ricardoperes/net-8-dependency-injection-changes-keyed-services

@Simble For the record, StructureMap/Lamar supported "keyed services" literally 20 years ago. But yes, I was already going to work on this support today for the .NET conforming container adapter.

Simble commented 1 year ago

@jeremydmiller, I'm aware of that, and been using it for years! Thanks for making it happen