JasperFx / lamar

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

Add support for .NET 8 keyed services #388

Closed Simble closed 7 months ago

Simble commented 9 months 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 8 months 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 7 months ago

plz fix your library it's blocking MediatR from releasing

rizi commented 7 months 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 7 months ago

The package explicitly excludes 8.0 in its version ranges

lt-nvos commented 7 months 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 7 months 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 7 months ago

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

jeremydmiller commented 7 months 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 7 months ago

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