1

Closed

Should allow custom DependencyResolver.GetServices to return null

description

Create a custom dependency resolver:
public class CustomServiceDependencyResolver : IDependencyResolver
{
    public IDependencyScope BeginScope()
    {
        return this;
    }

    public object GetService(Type serviceType)
    {
        return null;
    }

    public IEnumerable<object> GetServices(Type serviceType)
    {
        // Won't work 

        return null;
    }

    public void Dispose()
    {
    }
}
When running web api with this resolver, it will reports an error. In DefaultServices, it doesn't check null from dependency resolver GetServices.

Work around is to return new object[0]; instead.
Closed May 12, 2012 at 4:40 PM by BradWilson
Won't fix.

This usage violates the contract of the interface.

comments