Dreamescaper / ServiceScan.SourceGenerator

Assembly scanning source generator for Microsoft.Extensions.DependencyInjection
MIT License
27 stars 2 forks source link

Add Scrutor AsSelf() functionality #5

Closed Genmutant closed 4 months ago

Genmutant commented 4 months ago

I need to register some classes as themself. They can be found by a specific interface, but I don't want to register them as such, as the specific implementations need to be injected.

If I understand correctly, this is currently not possible?

Dreamescaper commented 4 months ago

Currently not, but I already have a branch with this functionality, only need to clean it up a bit. Will let you know once it's published.

Dreamescaper commented 4 months ago

@Genmutant I've published updated nuget package: https://www.nuget.org/packages/ServiceScan.SourceGenerator/1.1.2

Now you can use AsSelf flag:

[GenerateServiceRegistrations(AssignableTo = typeof(IService), AsSelf = true)]

or

[GenerateServiceRegistrations(AssignableTo = typeof(IService), AsSelf = true, AsImplementedInterfaces = true)]
Genmutant commented 4 months ago

Works great, thanks!