DryIoc icon indicating copy to clipboard operation
DryIoc copied to clipboard

[MS.DI] ISupportRequiredService is expected to be implemented together with IServiceProvider and not as capability

Open dadhi opened this issue 2 years ago • 1 comments

Currently, MS.DI GetRequiredService is implemented as extension method as following:

public static object GetRequiredService](this IServiceProvider provider, Type serviceType)
{
            if (provider is ISupportRequiredService requiredServiceSupportingProvider)
            {
                return requiredServiceSupportingProvider.GetRequiredService(serviceType);
            }
 
            object? service = provider.GetService(serviceType);
            if (service == null)
            {
                throw new InvalidOperationException(SR.Format(SR.NoServiceRegistered, serviceType));
            }
 
            return service;
}

But DryIocAdapter implements it as in the separate DryIocServiceProviderCapabilities so it would never be requested as GetService<ISupportRequiredService>().

dadhi avatar May 12 '22 12:05 dadhi

Possible with #494.

dadhi avatar Jul 01 '22 14:07 dadhi

done

dadhi avatar Jan 22 '24 21:01 dadhi