private InstanceProducer TryBuildInstanceProducerForCollection(Type serviceType)
        {
            if (!Helpers.IsGenericCollectionType(serviceType))
            {
                return(null);
            }

            // We don't auto-register collections for ambiguous types.
            if (Helpers.IsAmbiguousOrValueType(serviceType.GetGenericArguments()[0]))
            {
                return(null);
            }

            lock (this.emptyAndRedirectedCollectionRegistrationCache)
            {
                InstanceProducer producer;

                // We need to cache these generated producers, to prevent getting duplicate producers; which
                // will cause (incorrect) diagnostic warnings.
                if (!this.emptyAndRedirectedCollectionRegistrationCache.TryGetValue(serviceType, out producer))
                {
                    producer = this.TryBuildCollectionInstanceProducer(serviceType)
                               ?? this.TryBuildEmptyCollectionInstanceProducerForEnumerable(serviceType);

                    this.emptyAndRedirectedCollectionRegistrationCache[serviceType] = producer;
                }

                return(producer);
            }
        }
 // NOTE: MakeGenericType will fail for IEnumerable<T> when T is a pointer.
 private bool ContainsCollectionRegistrationFor(Type serviceType) =>
 !Helpers.IsGenericCollectionType(serviceType) && !serviceType.IsPointer &&
 this.ContainsExplicitRegistrationFor(typeof(IEnumerable <>).MakeGenericType(serviceType));
 private bool ContainsOneToOneRegistrationForCollectionType(Type collectionServiceType) =>
 Helpers.IsGenericCollectionType(collectionServiceType) &&
 this.ContainsExplicitRegistrationFor(collectionServiceType.GetGenericArguments()[0]);