From 257ad413c12889b46e1ff6b74e75bda65a930d25 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 29 Aug 2023 15:44:16 +0800 Subject: [PATCH] Set `ApplicationName` as current `assembly name`. --- .../TestBase/WebApplicationBuilderExtensions.cs | 6 ++++++ .../Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs | 7 ------- .../Volo/Abp/AspNetCore/App/AbpSerilogTestModule.cs | 9 --------- .../Volo/Abp/Http/AbpHttpClientTestModule.cs | 9 --------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs index 026d4da2a5..403bbac7b1 100644 --- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs @@ -12,6 +12,12 @@ public static class WebApplicationBuilderExtensions public async static Task RunAbpModuleAsync(this WebApplicationBuilder builder, Action? optionsAction = null) where TModule : IAbpModule { + var assemblyName = typeof(TModule).Assembly.GetName()?.Name; + if (!assemblyName.IsNullOrWhiteSpace()) + { + // Set the application name as the assembly name of the module will automatically add assembly to the ApplicationParts of MVC application. + builder.Environment.ApplicationName = assemblyName!; + } builder.Host.UseAutofac(); await builder.AddApplicationAsync(optionsAction); var app = builder.Build(); 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 1b2901d304..6051ae6520 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 @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Security.Claims; using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; @@ -38,12 +37,6 @@ public class AbpAspNetCoreMvcTestModule : AbpModule public override void PreConfigureServices(ServiceConfigurationContext context) { - PreConfigure(mvcBuilder => - { - mvcBuilder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(AbpAspNetCoreMvcTestModule).Assembly)); - mvcBuilder.PartManager.ApplicationParts.Add(new CompiledRazorAssemblyPart(typeof(AbpAspNetCoreMvcTestModule).Assembly)); - }); - context.Services.PreConfigure(options => { options.AddAssemblyResource( diff --git a/framework/test/Volo.Abp.AspNetCore.Serilog.Tests/Volo/Abp/AspNetCore/App/AbpSerilogTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Serilog.Tests/Volo/Abp/AspNetCore/App/AbpSerilogTestModule.cs index 4088412b88..992800cda5 100644 --- a/framework/test/Volo.Abp.AspNetCore.Serilog.Tests/Volo/Abp/AspNetCore/App/AbpSerilogTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Serilog.Tests/Volo/Abp/AspNetCore/App/AbpSerilogTestModule.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Serilog; @@ -19,14 +18,6 @@ namespace Volo.Abp.AspNetCore.App; )] public class AbpSerilogTestModule : AbpModule { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpSerilogTestModule).Assembly); - }); - } - public override void ConfigureServices(ServiceConfigurationContext context) { Configure(options => { options.IsEnabled = true; }); diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs index 003cd065e2..5e9107a23b 100644 --- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs +++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/AbpHttpClientTestModule.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.Conventions; using Volo.Abp.Http.Client; using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.Http.DynamicProxying; @@ -21,14 +20,6 @@ namespace Volo.Abp.Http; )] public class AbpHttpClientTestModule : AbpModule { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpHttpClientTestModule).Assembly); - }); - } - public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddHttpClientProxies(typeof(TestAppModule).Assembly);