diff --git a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs index f1a6264683..c885b98c20 100644 --- a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs +++ b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs @@ -24,12 +24,10 @@ // OTHER DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; using Autofac.Builder; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Autofac; using Volo.Abp; using Volo.Abp.Modularity; @@ -189,7 +187,6 @@ namespace Autofac.Extensions.DependencyInjection .RegisterGeneric(descriptor.ImplementationType) .As(descriptor.ServiceType) .ConfigureLifecycle(descriptor.Lifetime, lifetimeScopeTagForSingletons) - .FindConstructorsWith(new AbpAutofacConstructorFinder()) .ConfigureAbpConventions(moduleContainer, registrationActionList); } else @@ -198,7 +195,6 @@ namespace Autofac.Extensions.DependencyInjection .RegisterType(descriptor.ImplementationType) .As(descriptor.ServiceType) .ConfigureLifecycle(descriptor.Lifetime, lifetimeScopeTagForSingletons) - .FindConstructorsWith(new AbpAutofacConstructorFinder()) .ConfigureAbpConventions(moduleContainer, registrationActionList); } } diff --git a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj index 05259475f3..7a103badfc 100644 --- a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj +++ b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacConstructorFinder.cs b/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacConstructorFinder.cs deleted file mode 100644 index a9d0b736a2..0000000000 --- a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacConstructorFinder.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Reflection; -using Autofac.Core.Activators.Reflection; - -namespace Volo.Abp.Autofac -{ - public class AbpAutofacConstructorFinder : IConstructorFinder - { - private const BindingFlags DeclaredOnlyPublicFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; //Remove static constructor, BindingFlags.Static - - private readonly Func _finder; - - private static readonly ConcurrentDictionary DefaultPublicConstructorsCache = new ConcurrentDictionary(); - - public AbpAutofacConstructorFinder() - : this(GetDefaultPublicConstructors) - { - } - - public AbpAutofacConstructorFinder(Func finder) - { - _finder = finder ?? throw new ArgumentNullException(nameof(finder)); - } - - public ConstructorInfo[] FindConstructors(Type targetType) - { - return _finder(targetType); - } - - private static ConstructorInfo[] GetDefaultPublicConstructors(Type type) - { - var retval = DefaultPublicConstructorsCache.GetOrAdd(type, t => t.GetConstructors(DeclaredOnlyPublicFlags)); - - if (retval.Length == 0) - { - throw new NoConstructorsFoundException(type); - } - - return retval; - } - } -}