diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index 0ffbc644a8..a81da00b98 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -12,9 +12,9 @@ Basic configuration is simple. Just configure `AbpAspNetCoreMvcOptions` and use [DependsOn(BookStoreApplicationModule)] public class BookStoreWebModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) + public override void PreConfigureServices(ServiceConfigurationContext context) { - Configure(options => + PreConfigure(options => { options .ConventionalControllers diff --git a/docs/en/Integration-Services.md b/docs/en/Integration-Services.md index 98e3e593e5..6c31fb69bf 100644 --- a/docs/en/Integration-Services.md +++ b/docs/en/Integration-Services.md @@ -93,7 +93,7 @@ Configure(options => You can filter integration services (or non-integration services) while creating [Auto API Controllers](API/Auto-API-Controllers.md), using the `ApplicationServiceTypes` option of the `ConventionalControllerSetting` by configuring the `AbpAspNetCoreMvcOptions` as shown below: ```csharp -Configure(options => +PreConfigure(options => { options.ConventionalControllers.Create( typeof(MyApplicationModule).Assembly, diff --git a/docs/zh-Hans/API/Auto-API-Controllers.md b/docs/zh-Hans/API/Auto-API-Controllers.md index c3f5d44d71..e284d05c3d 100644 --- a/docs/zh-Hans/API/Auto-API-Controllers.md +++ b/docs/zh-Hans/API/Auto-API-Controllers.md @@ -12,9 +12,9 @@ ABP可以按照惯例 **自动** 将你的应用程序服务配置为API控制 [DependsOn(BookStoreApplicationModule)] public class BookStoreWebModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) + public override void PreConfigureServices(ServiceConfigurationContext context) { - Configure(options => + PreConfigure(options => { options .ConventionalControllers diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs index c9b5984843..4abeec13d1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs @@ -212,6 +212,17 @@ public class AbpAspNetCoreMvcModule : AbpModule context.Services.GetSingletonInstance(), context.Services.GetSingletonInstance() ); + + var preConfigureActions = context.Services.GetPreConfigureActions(); + + DynamicProxyIgnoreTypes.Add(preConfigureActions.Configure() + .ConventionalControllers + .ConventionalControllerSettings.SelectMany(x => x.ControllerTypes).ToArray()); + + Configure(options => + { + preConfigureActions.Configure(options); + }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) @@ -247,7 +258,7 @@ public class AbpAspNetCoreMvcModule : AbpModule .Distinct(); AddToApplicationParts(partManager, controllerAssemblies); - + var additionalAssemblies = moduleContainer .Modules .SelectMany(m => m.GetAdditionalAssemblies()) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs index a24d888b43..d14f64a55b 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/DynamicProxyIgnoreTypes.cs @@ -17,10 +17,23 @@ public static class DynamicProxyIgnoreTypes private static HashSet IgnoredTypes { get; } = new HashSet(); public static void Add() + { + Add(typeof(T)); + } + + public static void Add(Type type) + { + lock (IgnoredTypes) + { + IgnoredTypes.AddIfNotContains(type); + } + } + + public static void Add(params Type[] types) { lock (IgnoredTypes) { - IgnoredTypes.AddIfNotContains(typeof(T)); + IgnoredTypes.AddIfNotContains(types); } } diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs index 6051ae6520..d5a940e5de 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs @@ -44,6 +44,19 @@ public class AbpAspNetCoreMvcTestModule : AbpModule typeof(AbpAspNetCoreMvcTestModule).Assembly ); }); + + context.Services.PreConfigure(options => + { + options.ConventionalControllers.Create(typeof(TestAppModule).Assembly, opts => + { + opts.UrlActionNameNormalizer = urlActionNameNormalizerContext => + string.Equals(urlActionNameNormalizerContext.ActionNameInUrl, "phone", StringComparison.OrdinalIgnoreCase) + ? "phones" + : urlActionNameNormalizerContext.ActionNameInUrl; + }); + + options.ExposeIntegrationServices = true; + }); } public override void ConfigureServices(ServiceConfigurationContext context) @@ -79,19 +92,6 @@ public class AbpAspNetCoreMvcTestModule : AbpModule }); }); - Configure(options => - { - options.ConventionalControllers.Create(typeof(TestAppModule).Assembly, opts => - { - opts.UrlActionNameNormalizer = urlActionNameNormalizerContext => - string.Equals(urlActionNameNormalizerContext.ActionNameInUrl, "phone", StringComparison.OrdinalIgnoreCase) - ? "phones" - : urlActionNameNormalizerContext.ActionNameInUrl; - }); - - options.ExposeIntegrationServices = true; - }); - Configure(options => { options.FileSets.AddEmbedded();