Injectio icon indicating copy to clipboard operation
Injectio copied to clipboard

Use generic method from `ServiceDescriptor`

Open Cologler opened this issue 1 year ago • 0 comments

Currently, Injectio generated ServiceDescriptor.Describe for each service:

ServiceCollectionDescriptorExtensions.TryAdd(
    serviceCollection,
    ServiceDescriptor.Describe(
        typeof(TService),
        typeof(TImplementation), 
        ServiceLifetime.Scoped
    )
);

Switching to ServiceDescriptor.Scoped<TService, TImplementation> where TImplementation : TService can detect type errors at compile time.

Cologler avatar Jun 22 '24 06:06 Cologler