From d2780734b248537eab281d52e0efc41a42303641 Mon Sep 17 00:00:00 2001 From: Dorin Andreica Date: Tue, 19 Apr 2016 11:38:32 +0200 Subject: [PATCH] Rebased #713 on latest aspnet/Hosting --- .../WebHostBuilderExtensions.cs | 2 +- .../WebHostBuilderTests.cs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs b/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs index c0681690ee..d40a861bcf 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Hosting throw new ArgumentNullException(nameof(configureApp)); } - var startupAssemblyName = configureApp.Target.GetType().GetTypeInfo().Assembly.GetName().Name; + var startupAssemblyName = configureApp.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name; return hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName) .ConfigureServices(services => diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs index acbb665877..bcbf2f2940 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting.Fakes; using Microsoft.AspNetCore.Hosting.Internal; using Microsoft.AspNetCore.Hosting.Server; @@ -478,6 +479,21 @@ namespace Microsoft.AspNetCore.Hosting Assert.Equal(PlatformServices.Default.Application.ApplicationBasePath, appEnv.ApplicationBasePath); } + [Fact] + public void Configure_SupportsStaticMethodDelegate() + { + var host = new WebHostBuilder() + .UseServer(new TestServer()) + .Configure(StaticConfigureMethod) + .Build(); + + var hostingEnv = host.Services.GetService(); + Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName); + } + + private static void StaticConfigureMethod(IApplicationBuilder app) + { } + private IWebHostBuilder CreateWebHostBuilder() { var vals = new Dictionary