diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml index 8b7ed03b87..6b488b0592 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml @@ -1,7 +1,7 @@ -@using Microsoft.AspNetCore.Hosting +@using Microsoft.AspNetCore.Hosting @using Microsoft.AspNetCore.Mvc.ViewEngines -@inject IHostingEnvironment Environment +@inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine @{ @@ -10,4 +10,4 @@ { Layout = "_Layout"; } -} \ No newline at end of file +} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml index 8b7ed03b87..6b488b0592 100644 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml +++ b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml @@ -1,7 +1,7 @@ -@using Microsoft.AspNetCore.Hosting +@using Microsoft.AspNetCore.Hosting @using Microsoft.AspNetCore.Mvc.ViewEngines -@inject IHostingEnvironment Environment +@inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine @{ @@ -10,4 +10,4 @@ { Layout = "_Layout"; } -} \ No newline at end of file +} diff --git a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs index 251b482fc6..4eaf1d834b 100644 --- a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs +++ b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; @@ -14,7 +14,7 @@ namespace AzureAD.WebSite services.AddMvc(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseAuthentication(); diff --git a/src/Components/Blazor/Cli/src/Server/Startup.cs b/src/Components/Blazor/Cli/src/Server/Startup.cs index 4400eb11de..6e148f8b20 100644 --- a/src/Components/Blazor/Cli/src/Server/Startup.cs +++ b/src/Components/Blazor/Cli/src/Server/Startup.cs @@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Blazor.Cli.Server private static string FindClientAssemblyPath(IApplicationBuilder app) { - var env = app.ApplicationServices.GetRequiredService(); + var env = app.ApplicationServices.GetRequiredService(); var contentRoot = env.ContentRootPath; var binDir = FindClientBinDir(contentRoot); var appName = Path.GetFileName(contentRoot); // TODO: Allow for the possibility that the assembly name has been overridden diff --git a/src/Components/Blazor/testassets/HostedInAspNet.Server/Startup.cs b/src/Components/Blazor/testassets/HostedInAspNet.Server/Startup.cs index ec093272b6..87b023f95b 100644 --- a/src/Components/Blazor/testassets/HostedInAspNet.Server/Startup.cs +++ b/src/Components/Blazor/testassets/HostedInAspNet.Server/Startup.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace HostedInAspNet.Server { @@ -16,7 +17,7 @@ namespace HostedInAspNet.Server } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Components/Blazor/testassets/MonoSanity/Startup.cs b/src/Components/Blazor/testassets/MonoSanity/Startup.cs index fc13003004..6457a5fce2 100644 --- a/src/Components/Blazor/testassets/MonoSanity/Startup.cs +++ b/src/Components/Blazor/testassets/MonoSanity/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; @@ -8,7 +8,7 @@ namespace MonoSanity { public class Startup { - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true }); diff --git a/src/Components/Server/src/Builder/BlazorApplicationBuilderExtensions.cs b/src/Components/Server/src/Builder/BlazorApplicationBuilderExtensions.cs index 1d3f4d0220..7c7048ed2c 100644 --- a/src/Components/Server/src/Builder/BlazorApplicationBuilderExtensions.cs +++ b/src/Components/Server/src/Builder/BlazorApplicationBuilderExtensions.cs @@ -10,6 +10,7 @@ using Microsoft.Net.Http.Headers; using System.Net.Mime; using System; using System.IO; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Builder { @@ -49,7 +50,7 @@ namespace Microsoft.AspNetCore.Builder // TODO: Make the .blazor.config file contents sane // Currently the items in it are bizarre and don't relate to their purpose, // hence all the path manipulation here. We shouldn't be hardcoding 'dist' here either. - var env = (IHostingEnvironment)app.ApplicationServices.GetService(typeof(IHostingEnvironment)); + var env = (IWebHostEnvironment)app.ApplicationServices.GetService(typeof(IWebHostEnvironment)); var config = BlazorConfig.Read(options.ClientAssemblyPath); if (env.IsDevelopment() && config.EnableAutoRebuilding) diff --git a/src/Components/test/testassets/ComponentsApp.Server/DefaultWeatherForecastService.cs b/src/Components/test/testassets/ComponentsApp.Server/DefaultWeatherForecastService.cs index 2b6abae1f8..c110daf3b6 100644 --- a/src/Components/test/testassets/ComponentsApp.Server/DefaultWeatherForecastService.cs +++ b/src/Components/test/testassets/ComponentsApp.Server/DefaultWeatherForecastService.cs @@ -11,9 +11,9 @@ namespace ComponentsApp.Server { public class DefaultWeatherForecastService : WeatherForecastService { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public DefaultWeatherForecastService(IHostingEnvironment hostingEnvironment) + public DefaultWeatherForecastService(IWebHostEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; } diff --git a/src/Components/test/testassets/ComponentsApp.Server/Startup.cs b/src/Components/test/testassets/ComponentsApp.Server/Startup.cs index 7c2f6e7f3c..f269649446 100644 --- a/src/Components/test/testassets/ComponentsApp.Server/Startup.cs +++ b/src/Components/test/testassets/ComponentsApp.Server/Startup.cs @@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components.Server.Circuits; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + namespace ComponentsApp.Server { @@ -17,7 +19,7 @@ namespace ComponentsApp.Server services.AddSingleton(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Components/test/testassets/TestServer/Startup.cs b/src/Components/test/testassets/TestServer/Startup.cs index dfe4ab2215..7b740845be 100644 --- a/src/Components/test/testassets/TestServer/Startup.cs +++ b/src/Components/test/testassets/TestServer/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace TestServer { @@ -27,7 +28,7 @@ namespace TestServer } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs b/src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs index 400d372418..819e9297c5 100644 --- a/src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs +++ b/src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs @@ -1,21 +1,21 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.DataProtection.Infrastructure; -using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.DataProtection.Internal { internal class HostingApplicationDiscriminator : IApplicationDiscriminator { - private readonly IHostingEnvironment _hosting; + private readonly IHostEnvironment _hosting; // the optional constructor for when IHostingEnvironment is not available from DI public HostingApplicationDiscriminator() { } - public HostingApplicationDiscriminator(IHostingEnvironment hosting) + public HostingApplicationDiscriminator(IHostEnvironment hosting) { _hosting = hosting; } diff --git a/src/DataProtection/DataProtection/test/DataProtectionUtilityExtensionsTests.cs b/src/DataProtection/DataProtection/test/DataProtectionUtilityExtensionsTests.cs index 5af33b1b25..868c70f1fe 100644 --- a/src/DataProtection/DataProtection/test/DataProtectionUtilityExtensionsTests.cs +++ b/src/DataProtection/DataProtection/test/DataProtectionUtilityExtensionsTests.cs @@ -5,6 +5,7 @@ using System; using Microsoft.AspNetCore.DataProtection.Infrastructure; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Moq; using Xunit; @@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.DataProtection public void GetApplicationUniqueIdentifierFromHosting(string contentRootPath, string expected) { // Arrange - var mockEnvironment = new Mock(); + var mockEnvironment = new Mock(); mockEnvironment.Setup(o => o.ContentRootPath).Returns(contentRootPath); var services = new ServiceCollection() @@ -47,7 +48,7 @@ namespace Microsoft.AspNetCore.DataProtection var mockAppDiscriminator = new Mock(); mockAppDiscriminator.Setup(o => o.Discriminator).Returns(discriminator); - var mockEnvironment = new Mock(); + var mockEnvironment = new Mock(); mockEnvironment.SetupGet(o => o.ContentRootPath).Throws(new InvalidOperationException("Hosting environment should not be checked")); var services = new ServiceCollection() diff --git a/src/DefaultBuilder/samples/SampleApp/Startup.cs b/src/DefaultBuilder/samples/SampleApp/Startup.cs index 287fffd27a..d5d74c5523 100644 --- a/src/DefaultBuilder/samples/SampleApp/Startup.cs +++ b/src/DefaultBuilder/samples/SampleApp/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; @@ -15,7 +15,7 @@ namespace SampleApp } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.Run(async (context) => { diff --git a/src/DefaultBuilder/src/WebHost.cs b/src/DefaultBuilder/src/WebHost.cs index c5573e80cd..78ec34847c 100644 --- a/src/DefaultBuilder/src/WebHost.cs +++ b/src/DefaultBuilder/src/WebHost.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -118,9 +119,9 @@ namespace Microsoft.AspNetCore /// /// The following defaults are applied to the returned : /// use Kestrel as the web server and configure it using the application's configuration providers, - /// set the to the result of , - /// load from 'appsettings.json' and 'appsettings.[].json', - /// load from User Secrets when is 'Development' using the entry assembly, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// configure the to log to the console and debug output, /// and enable IIS integration. @@ -135,9 +136,9 @@ namespace Microsoft.AspNetCore /// /// The following defaults are applied to the returned : /// use Kestrel as the web server and configure it using the application's configuration providers, - /// set the to the result of , - /// load from 'appsettings.json' and 'appsettings.[].json', - /// load from User Secrets when is 'Development' using the entry assembly, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// load from supplied command line args, /// configure the to log to the console and debug output, @@ -235,9 +236,9 @@ namespace Microsoft.AspNetCore /// /// The following defaults are applied to the returned : /// use Kestrel as the web server and configure it using the application's configuration providers, - /// set the to the result of , - /// load from 'appsettings.json' and 'appsettings.[].json', - /// load from User Secrets when is 'Development' using the entry assembly, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// load from supplied command line args, /// configure the to log to the console and debug output, diff --git a/src/DefaultBuilder/testassets/CreateDefaultBuilderApp/Program.cs b/src/DefaultBuilder/testassets/CreateDefaultBuilderApp/Program.cs index 5d58a6f97b..9a1e5bdfc5 100644 --- a/src/DefaultBuilder/testassets/CreateDefaultBuilderApp/Program.cs +++ b/src/DefaultBuilder/testassets/CreateDefaultBuilderApp/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -30,7 +30,7 @@ namespace CreateDefaultBuilderApp })) .Configure(app => app.Run(context => { - var hostingEnvironment = app.ApplicationServices.GetRequiredService(); + var hostingEnvironment = app.ApplicationServices.GetRequiredService(); return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); })) .Build().Run(); @@ -78,4 +78,4 @@ namespace CreateDefaultBuilderApp return null; } } -} \ No newline at end of file +} diff --git a/src/DefaultBuilder/testassets/CreateDefaultBuilderOfTApp/Program.cs b/src/DefaultBuilder/testassets/CreateDefaultBuilderOfTApp/Program.cs index 3419340dc3..ee07f647da 100644 --- a/src/DefaultBuilder/testassets/CreateDefaultBuilderOfTApp/Program.cs +++ b/src/DefaultBuilder/testassets/CreateDefaultBuilderOfTApp/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; namespace CreateDefaultBuilderOfTApp @@ -40,7 +41,7 @@ namespace CreateDefaultBuilderOfTApp responseMessage = "AllowedHosts not loaded into Options."; } - var hostingEnvironment = app.ApplicationServices.GetRequiredService(); + var hostingEnvironment = app.ApplicationServices.GetRequiredService(); return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); })) .Build() @@ -89,4 +90,4 @@ namespace CreateDefaultBuilderOfTApp return null; } } -} \ No newline at end of file +} diff --git a/src/DefaultBuilder/testassets/StartRequestDelegateUrlApp/Program.cs b/src/DefaultBuilder/testassets/StartRequestDelegateUrlApp/Program.cs index 351f870b56..23069a5366 100644 --- a/src/DefaultBuilder/testassets/StartRequestDelegateUrlApp/Program.cs +++ b/src/DefaultBuilder/testassets/StartRequestDelegateUrlApp/Program.cs @@ -1,13 +1,13 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading; using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace StartRequestDelegateUrlApp { @@ -20,7 +20,7 @@ namespace StartRequestDelegateUrlApp using (var host = WebHost.Start("http://127.0.0.1:0", async context => { // Respond with the ApplicationName. - var env = context.RequestServices.GetRequiredService(); + var env = context.RequestServices.GetRequiredService(); await context.Response.WriteAsync(env.ApplicationName); messageSent.Set(); })) @@ -40,4 +40,4 @@ namespace StartRequestDelegateUrlApp } } } -} \ No newline at end of file +} diff --git a/src/DefaultBuilder/testassets/StartRouteBuilderUrlApp/Program.cs b/src/DefaultBuilder/testassets/StartRouteBuilderUrlApp/Program.cs index 5aa13ea396..2f59a81811 100644 --- a/src/DefaultBuilder/testassets/StartRouteBuilderUrlApp/Program.cs +++ b/src/DefaultBuilder/testassets/StartRouteBuilderUrlApp/Program.cs @@ -1,14 +1,14 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading; using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace StartRequestDelegateUrlApp { @@ -21,7 +21,7 @@ namespace StartRequestDelegateUrlApp using (var host = WebHost.Start("http://127.0.0.1:0", router => router.MapGet("route", async (req, res, data) => { - var env = req.HttpContext.RequestServices.GetRequiredService(); + var env = req.HttpContext.RequestServices.GetRequiredService(); await res.WriteAsync(env.ApplicationName); messageSent.Set(); }))) @@ -40,4 +40,4 @@ namespace StartRequestDelegateUrlApp } } } -} \ No newline at end of file +} diff --git a/src/DefaultBuilder/testassets/StartWithIApplicationBuilderUrlApp/Program.cs b/src/DefaultBuilder/testassets/StartWithIApplicationBuilderUrlApp/Program.cs index f904dcff57..cf42cee87f 100644 --- a/src/DefaultBuilder/testassets/StartWithIApplicationBuilderUrlApp/Program.cs +++ b/src/DefaultBuilder/testassets/StartWithIApplicationBuilderUrlApp/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace StartWithIApplicationBuilderUrlApp { @@ -22,7 +23,7 @@ namespace StartWithIApplicationBuilderUrlApp { app.Run(async context => { - var env = context.RequestServices.GetRequiredService(); + var env = context.RequestServices.GetRequiredService(); await context.Response.WriteAsync(env.ApplicationName); messageSent.Set(); }); @@ -42,4 +43,4 @@ namespace StartWithIApplicationBuilderUrlApp } } } -} \ No newline at end of file +} diff --git a/src/Hosting/Abstractions/src/HostingEnvironmentExtensions.cs b/src/Hosting/Abstractions/src/HostingEnvironmentExtensions.cs index ad3269859d..5a3149bcb3 100644 --- a/src/Hosting/Abstractions/src/HostingEnvironmentExtensions.cs +++ b/src/Hosting/Abstractions/src/HostingEnvironmentExtensions.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.IO; +#pragma warning disable CS0618 // Type or member is obsolete namespace Microsoft.AspNetCore.Hosting { /// @@ -77,4 +77,5 @@ namespace Microsoft.AspNetCore.Hosting StringComparison.OrdinalIgnoreCase); } } -} \ No newline at end of file +} +#pragma warning restore CS0618 // Type or member is obsolete diff --git a/src/Hosting/Abstractions/src/IApplicationLifetime.cs b/src/Hosting/Abstractions/src/IApplicationLifetime.cs index f4613dd7d9..bdba9b904f 100644 --- a/src/Hosting/Abstractions/src/IApplicationLifetime.cs +++ b/src/Hosting/Abstractions/src/IApplicationLifetime.cs @@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting /// /// Allows consumers to perform cleanup during a graceful shutdown. /// + [System.Obsolete("Use Microsoft.Extensions.Hosting.IHostApplicationLifetime instead.", error: false)] public interface IApplicationLifetime { /// diff --git a/src/Hosting/Abstractions/src/IHostingEnvironment.cs b/src/Hosting/Abstractions/src/IHostingEnvironment.cs index 5feeb38eb7..864c52c7b6 100644 --- a/src/Hosting/Abstractions/src/IHostingEnvironment.cs +++ b/src/Hosting/Abstractions/src/IHostingEnvironment.cs @@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting /// /// Provides information about the web hosting environment an application is running in. /// + [System.Obsolete("Use IWebHostEnvironment instead.", error: false)] public interface IHostingEnvironment { /// diff --git a/src/Hosting/Abstractions/src/IWebHostEnvironment.cs b/src/Hosting/Abstractions/src/IWebHostEnvironment.cs new file mode 100644 index 0000000000..d07103fe2d --- /dev/null +++ b/src/Hosting/Abstractions/src/IWebHostEnvironment.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; + +namespace Microsoft.AspNetCore.Hosting +{ + /// + /// Provides information about the web hosting environment an application is running in. + /// + public interface IWebHostEnvironment : IHostEnvironment + { + /// + /// Gets or sets the absolute path to the directory that contains the web-servable application content files. + /// + string WebRootPath { get; set; } + + /// + /// Gets or sets an pointing at . + /// + IFileProvider WebRootFileProvider { get; set; } + } +} diff --git a/src/Hosting/Abstractions/src/WebHostBuilderContext.cs b/src/Hosting/Abstractions/src/WebHostBuilderContext.cs index 58e8d0798b..23de0ad07c 100644 --- a/src/Hosting/Abstractions/src/WebHostBuilderContext.cs +++ b/src/Hosting/Abstractions/src/WebHostBuilderContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; @@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Hosting public class WebHostBuilderContext { /// - /// The initialized by the . + /// The initialized by the . /// - public IHostingEnvironment HostingEnvironment { get; set; } + public IWebHostEnvironment HostingEnvironment { get; set; } /// /// The containing the merged configuration of the application and the . diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostApplicationLifetime.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostApplicationLifetime.cs index 53fe0132b7..1fbb66771b 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostApplicationLifetime.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostApplicationLifetime.cs @@ -2,15 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting.Internal { - internal class GenericWebHostApplicationLifetime : IApplicationLifetime - { #pragma warning disable CS0618 // Type or member is obsolete - private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime; - public GenericWebHostApplicationLifetime(Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime) + internal class GenericWebHostApplicationLifetime : IApplicationLifetime #pragma warning restore CS0618 // Type or member is obsolete + { + private readonly IHostApplicationLifetime _applicationLifetime; + public GenericWebHostApplicationLifetime(IHostApplicationLifetime applicationLifetime) { _applicationLifetime = applicationLifetime; } diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs index 5f04798c41..d463c5b36d 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs @@ -71,7 +71,10 @@ namespace Microsoft.AspNetCore.Hosting.Internal // Add the IHostingEnvironment and IApplicationLifetime from Microsoft.AspNetCore.Hosting services.AddSingleton(webhostContext.HostingEnvironment); +#pragma warning disable CS0618 // Type or member is obsolete + services.AddSingleton((AspNetCore.Hosting.IHostingEnvironment)webhostContext.HostingEnvironment); services.AddSingleton(); +#pragma warning restore CS0618 // Type or member is obsolete services.Configure(options => { @@ -318,14 +321,12 @@ namespace Microsoft.AspNetCore.Hosting.Internal if (!context.Properties.TryGetValue(typeof(WebHostBuilderContext), out var contextVal)) { var options = new WebHostOptions(context.Configuration, Assembly.GetEntryAssembly()?.GetName().Name); - var hostingEnvironment = new HostingEnvironment(); - hostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options); - var webHostBuilderContext = new WebHostBuilderContext { Configuration = context.Configuration, - HostingEnvironment = hostingEnvironment + HostingEnvironment = new HostingEnvironment(), }; + webHostBuilderContext.HostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options); context.Properties[typeof(WebHostBuilderContext)] = webHostBuilderContext; context.Properties[typeof(WebHostOptions)] = options; return webHostBuilderContext; @@ -361,7 +362,13 @@ namespace Microsoft.AspNetCore.Hosting.Internal public object GetService(Type serviceType) { // The implementation of the HostingEnvironment supports both interfaces - if (serviceType == typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment) || serviceType == typeof(IHostingEnvironment)) +#pragma warning disable CS0618 // Type or member is obsolete + if (serviceType == typeof(Microsoft.Extensions.Hosting.IHostingEnvironment) + || serviceType == typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment) +#pragma warning restore CS0618 // Type or member is obsolete + || serviceType == typeof(IWebHostEnvironment) + || serviceType == typeof(IHostEnvironment) + ) { return _context.HostingEnvironment; } diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs index a9ebccaaa0..881cb1b2fc 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal IApplicationBuilderFactory applicationBuilderFactory, IEnumerable startupFilters, IConfiguration configuration, - IHostingEnvironment hostingEnvironment) + IWebHostEnvironment hostingEnvironment) { Options = options.Value; Server = server; @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal public IApplicationBuilderFactory ApplicationBuilderFactory { get; } public IEnumerable StartupFilters { get; } public IConfiguration Configuration { get; } - public IHostingEnvironment HostingEnvironment { get; } + public IWebHostEnvironment HostingEnvironment { get; } public async Task StartAsync(CancellationToken cancellationToken) { diff --git a/src/Hosting/Hosting/src/Internal/ApplicationLifetime.cs b/src/Hosting/Hosting/src/Internal/ApplicationLifetime.cs index 342ba6485b..ac19e8b052 100644 --- a/src/Hosting/Hosting/src/Internal/ApplicationLifetime.cs +++ b/src/Hosting/Hosting/src/Internal/ApplicationLifetime.cs @@ -3,6 +3,7 @@ using System; using System.Threading; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Hosting.Internal @@ -11,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal /// Allows consumers to perform cleanup during a graceful shutdown. /// #pragma warning disable CS0618 // Type or member is obsolete - public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime + public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime, IHostApplicationLifetime #pragma warning restore CS0618 // Type or member is obsolete { private readonly CancellationTokenSource _startedSource = new CancellationTokenSource(); diff --git a/src/Hosting/Hosting/src/Internal/HostingEnvironment.cs b/src/Hosting/Hosting/src/Internal/HostingEnvironment.cs index 6bd7d57632..ee1ab42cdd 100644 --- a/src/Hosting/Hosting/src/Internal/HostingEnvironment.cs +++ b/src/Hosting/Hosting/src/Internal/HostingEnvironment.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.FileProviders; namespace Microsoft.AspNetCore.Hosting.Internal { #pragma warning disable CS0618 // Type or member is obsolete - public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment + public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment, IWebHostEnvironment #pragma warning restore CS0618 // Type or member is obsolete { public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production; diff --git a/src/Hosting/Hosting/src/Internal/HostingEnvironmentExtensions.cs b/src/Hosting/Hosting/src/Internal/HostingEnvironmentExtensions.cs index c12d0bcdd6..1670aa8d09 100644 --- a/src/Hosting/Hosting/src/Internal/HostingEnvironmentExtensions.cs +++ b/src/Hosting/Hosting/src/Internal/HostingEnvironmentExtensions.cs @@ -9,7 +9,62 @@ namespace Microsoft.AspNetCore.Hosting.Internal { public static class HostingEnvironmentExtensions { +#pragma warning disable CS0618 // Type or member is obsolete public static void Initialize(this IHostingEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options) +#pragma warning restore CS0618 // Type or member is obsolete + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + if (string.IsNullOrEmpty(contentRootPath)) + { + throw new ArgumentException("A valid non-empty content root must be provided.", nameof(contentRootPath)); + } + if (!Directory.Exists(contentRootPath)) + { + throw new ArgumentException($"The content root '{contentRootPath}' does not exist.", nameof(contentRootPath)); + } + + hostingEnvironment.ApplicationName = options.ApplicationName; + hostingEnvironment.ContentRootPath = contentRootPath; + hostingEnvironment.ContentRootFileProvider = new PhysicalFileProvider(hostingEnvironment.ContentRootPath); + + var webRoot = options.WebRoot; + if (webRoot == null) + { + // Default to /wwwroot if it exists. + var wwwroot = Path.Combine(hostingEnvironment.ContentRootPath, "wwwroot"); + if (Directory.Exists(wwwroot)) + { + hostingEnvironment.WebRootPath = wwwroot; + } + } + else + { + hostingEnvironment.WebRootPath = Path.Combine(hostingEnvironment.ContentRootPath, webRoot); + } + + if (!string.IsNullOrEmpty(hostingEnvironment.WebRootPath)) + { + hostingEnvironment.WebRootPath = Path.GetFullPath(hostingEnvironment.WebRootPath); + if (!Directory.Exists(hostingEnvironment.WebRootPath)) + { + Directory.CreateDirectory(hostingEnvironment.WebRootPath); + } + hostingEnvironment.WebRootFileProvider = new PhysicalFileProvider(hostingEnvironment.WebRootPath); + } + else + { + hostingEnvironment.WebRootFileProvider = new NullFileProvider(); + } + + hostingEnvironment.EnvironmentName = + options.Environment ?? + hostingEnvironment.EnvironmentName; + } + + public static void Initialize(this IWebHostEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options) { if (options == null) { @@ -62,4 +117,4 @@ namespace Microsoft.AspNetCore.Hosting.Internal hostingEnvironment.EnvironmentName; } } -} \ No newline at end of file +} diff --git a/src/Hosting/Hosting/src/Internal/WebHost.cs b/src/Hosting/Hosting/src/Internal/WebHost.cs index b32726cbb5..6ddb0ca871 100644 --- a/src/Hosting/Hosting/src/Internal/WebHost.cs +++ b/src/Hosting/Hosting/src/Internal/WebHost.cs @@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.StackTrace.Sources; @@ -76,14 +77,16 @@ namespace Microsoft.AspNetCore.Hosting.Internal _options = options; _applicationServiceCollection = appServices; _hostingServiceProvider = hostingServiceProvider; - _applicationServiceCollection.AddSingleton(); + _applicationServiceCollection.AddSingleton(); // There's no way to to register multiple service types per definition. See https://github.com/aspnet/DependencyInjection/issues/360 - _applicationServiceCollection.AddSingleton(sp => - { + _applicationServiceCollection.AddSingleton(services + => services.GetService() as IHostApplicationLifetime); #pragma warning disable CS0618 // Type or member is obsolete - return sp.GetRequiredService() as Extensions.Hosting.IApplicationLifetime; + _applicationServiceCollection.AddSingleton(services + => services.GetService() as AspNetCore.Hosting.IApplicationLifetime); + _applicationServiceCollection.AddSingleton(services + => services.GetService() as Extensions.Hosting.IApplicationLifetime); #pragma warning restore CS0618 // Type or member is obsolete - }); _applicationServiceCollection.AddSingleton(); } @@ -141,7 +144,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal var application = BuildApplication(); - _applicationLifetime = _applicationServices.GetRequiredService() as ApplicationLifetime; + _applicationLifetime = _applicationServices.GetRequiredService(); _hostedServiceExecutor = _applicationServices.GetRequiredService(); var diagnosticSource = _applicationServices.GetRequiredService(); var httpContextFactory = _applicationServices.GetRequiredService(); @@ -238,7 +241,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal EnsureServer(); // Generate an HTML error page. - var hostingEnv = _applicationServices.GetRequiredService(); + var hostingEnv = _applicationServices.GetRequiredService(); var showDetailedErrors = hostingEnv.IsDevelopment() || _options.DetailedErrors; var model = new ErrorPageModel diff --git a/src/Hosting/Hosting/src/WebHostBuilder.cs b/src/Hosting/Hosting/src/WebHostBuilder.cs index ddce2b8116..da27a76c3c 100644 --- a/src/Hosting/Hosting/src/WebHostBuilder.cs +++ b/src/Hosting/Hosting/src/WebHostBuilder.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.ObjectPool; @@ -248,13 +249,15 @@ namespace Microsoft.AspNetCore.Hosting var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, AppContext.BaseDirectory); // Initialize the hosting environment - _hostingEnvironment.Initialize(contentRootPath, _options); + ((IWebHostEnvironment)_hostingEnvironment).Initialize(contentRootPath, _options); _context.HostingEnvironment = _hostingEnvironment; var services = new ServiceCollection(); services.AddSingleton(_options); - services.AddSingleton(_hostingEnvironment); + services.AddSingleton(_hostingEnvironment); + services.AddSingleton(_hostingEnvironment); #pragma warning disable CS0618 // Type or member is obsolete + services.AddSingleton(_hostingEnvironment); services.AddSingleton(_hostingEnvironment); #pragma warning restore CS0618 // Type or member is obsolete services.AddSingleton(_context); @@ -295,7 +298,7 @@ namespace Microsoft.AspNetCore.Hosting { services.AddSingleton(typeof(IStartup), sp => { - var hostingEnvironment = sp.GetRequiredService(); + var hostingEnvironment = sp.GetRequiredService(); var methods = StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName); return new ConventionBasedStartup(methods); }); diff --git a/src/Hosting/Hosting/src/WebHostBuilderExtensions.cs b/src/Hosting/Hosting/src/WebHostBuilderExtensions.cs index 63dd3257b8..60acc075fa 100644 --- a/src/Hosting/Hosting/src/WebHostBuilderExtensions.cs +++ b/src/Hosting/Hosting/src/WebHostBuilderExtensions.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Hosting @@ -76,7 +77,7 @@ namespace Microsoft.AspNetCore.Hosting { services.AddSingleton(typeof(IStartup), sp => { - var hostingEnvironment = sp.GetRequiredService(); + var hostingEnvironment = sp.GetRequiredService(); return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName)); }); } diff --git a/src/Hosting/Hosting/src/WebHostExtensions.cs b/src/Hosting/Hosting/src/WebHostExtensions.cs index a7f5e5ec2a..2af27f880e 100644 --- a/src/Hosting/Hosting/src/WebHostExtensions.cs +++ b/src/Hosting/Hosting/src/WebHostExtensions.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting.Internal; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting { @@ -105,7 +106,7 @@ namespace Microsoft.AspNetCore.Hosting { await host.StartAsync(token); - var hostingEnvironment = host.Services.GetService(); + var hostingEnvironment = host.Services.GetService(); var options = host.Services.GetRequiredService(); if (!options.SuppressStatusMessages) @@ -146,11 +147,11 @@ namespace Microsoft.AspNetCore.Hosting private static async Task WaitForTokenShutdownAsync(this IWebHost host, CancellationToken token) { - var applicationLifetime = host.Services.GetService(); + var applicationLifetime = host.Services.GetService(); token.Register(state => { - ((IApplicationLifetime)state).StopApplication(); + ((IHostApplicationLifetime)state).StopApplication(); }, applicationLifetime); diff --git a/src/Hosting/Hosting/test/Fakes/StartupWithHostingEnvironment.cs b/src/Hosting/Hosting/test/Fakes/StartupWithHostingEnvironment.cs index c4a5776502..cdd3cc7ac3 100644 --- a/src/Hosting/Hosting/test/Fakes/StartupWithHostingEnvironment.cs +++ b/src/Hosting/Hosting/test/Fakes/StartupWithHostingEnvironment.cs @@ -1,18 +1,18 @@ -using System; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting.Tests.Fakes { public class StartupWithHostingEnvironment { - public StartupWithHostingEnvironment(IHostingEnvironment env) + public StartupWithHostingEnvironment(IHostEnvironment env) { env.EnvironmentName = "Changed"; } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { } } -} \ No newline at end of file +} diff --git a/src/Hosting/Hosting/test/HostingEnvironmentExtensionsTests.cs b/src/Hosting/Hosting/test/HostingEnvironmentExtensionsTests.cs index 3a646b005b..c0eeffdaec 100644 --- a/src/Hosting/Hosting/test/HostingEnvironmentExtensionsTests.cs +++ b/src/Hosting/Hosting/test/HostingEnvironmentExtensionsTests.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests [Fact] public void SetsFullPathToWwwroot() { - var env = new HostingEnvironment(); + IWebHostEnvironment env = new HostingEnvironment(); env.Initialize(Path.GetFullPath("."), new WebHostOptions() { WebRoot = "testroot" }); @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests [Fact] public void DefaultsToWwwrootSubdir() { - var env = new HostingEnvironment(); + IWebHostEnvironment env = new HostingEnvironment(); env.Initialize(Path.GetFullPath("testroot"), new WebHostOptions()); @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests [Fact] public void DefaultsToNullFileProvider() { - var env = new HostingEnvironment(); + IWebHostEnvironment env = new HostingEnvironment(); env.Initialize(Path.GetFullPath(Path.Combine("testroot", "wwwroot")), new WebHostOptions()); @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests [Fact] public void OverridesEnvironmentFromConfig() { - var env = new HostingEnvironment(); + IWebHostEnvironment env = new HostingEnvironment(); env.EnvironmentName = "SomeName"; env.Initialize(Path.GetFullPath("."), new WebHostOptions() { Environment = "NewName" }); diff --git a/src/Hosting/Hosting/test/WebHostBuilderTests.cs b/src/Hosting/Hosting/test/WebHostBuilderTests.cs index e04434bb70..0c962c5848 100644 --- a/src/Hosting/Hosting/test/WebHostBuilderTests.cs +++ b/src/Hosting/Hosting/test/WebHostBuilderTests.cs @@ -98,14 +98,14 @@ namespace Microsoft.AspNetCore.Hosting [Theory] [MemberData(nameof(DefaultWebHostBuildersWithConfig))] - public async Task IApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder) + public async Task IHostApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder) { var server = new TestServer(); var host = builder.UseServer(server).UseStartup().Build(); using (host) { await host.StartAsync(); - var services = host.Services.GetServices(); + var services = host.Services.GetServices(); Assert.NotNull(services); Assert.NotEmpty(services); @@ -551,8 +551,10 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup("Microsoft.AspNetCore.Hosting.Tests") .Build()) { - Assert.Equal(expected, host.Services.GetService().EnvironmentName); + Assert.Equal(expected, host.Services.GetService().EnvironmentName); + Assert.Equal(expected, host.Services.GetService().EnvironmentName); #pragma warning disable CS0618 // Type or member is obsolete + Assert.Equal(expected, host.Services.GetService().EnvironmentName); Assert.Equal(expected, host.Services.GetService().EnvironmentName); #pragma warning restore CS0618 // Type or member is obsolete } @@ -598,8 +600,10 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup("Microsoft.AspNetCore.Hosting.Tests") .Build()) { - Assert.Equal("/", host.Services.GetService().ContentRootPath); + Assert.Equal("/", host.Services.GetService().ContentRootPath); + Assert.Equal("/", host.Services.GetService().ContentRootPath); #pragma warning disable CS0618 // Type or member is obsolete + Assert.Equal("/", host.Services.GetService().ContentRootPath); Assert.Equal("/", host.Services.GetService().ContentRootPath); #pragma warning restore CS0618 // Type or member is obsolete } @@ -615,9 +619,9 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup("Microsoft.AspNetCore.Hosting.Tests") .Build()) { - var basePath = host.Services.GetRequiredService().ContentRootPath; + var basePath = host.Services.GetRequiredService().ContentRootPath; #pragma warning disable CS0618 // Type or member is obsolete - var basePath2 = host.Services.GetService().ContentRootPath; + var basePath2 = host.Services.GetService().ContentRootPath; #pragma warning restore CS0618 // Type or member is obsolete Assert.True(Path.IsPathRooted(basePath)); @@ -638,9 +642,9 @@ namespace Microsoft.AspNetCore.Hosting .Build()) { var appBase = AppContext.BaseDirectory; - Assert.Equal(appBase, host.Services.GetService().ContentRootPath); + Assert.Equal(appBase, host.Services.GetService().ContentRootPath); #pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal(appBase, host.Services.GetService().ContentRootPath); + Assert.Equal(appBase, host.Services.GetService().ContentRootPath); #pragma warning restore CS0618 // Type or member is obsolete } } @@ -666,9 +670,9 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup(typeof(Startup).Assembly.GetName().Name) .Build()) { - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var hostingEnv2 = host.Services.GetService(); + var hostingEnv2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv.ApplicationName); Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv2.ApplicationName); @@ -684,9 +688,9 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup() .Build()) { - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var hostingEnv2 = host.Services.GetService(); + var hostingEnv2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName); Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv2.ApplicationName); @@ -702,7 +706,7 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup(typeof(StartupNoServicesNoInterface)) .Build(); - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName); } @@ -715,7 +719,7 @@ namespace Microsoft.AspNetCore.Hosting .Configure(app => { }) .Build()) { - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); // Should be the assembly containing this test, because that's where the delegate comes from Assert.Equal(typeof(WebHostBuilderTests).Assembly.GetName().Name, hostingEnv.ApplicationName); @@ -731,7 +735,7 @@ namespace Microsoft.AspNetCore.Hosting .Configure(app => { }) .Build()) { - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName); } } @@ -745,7 +749,7 @@ namespace Microsoft.AspNetCore.Hosting .Configure(StaticConfigureMethod) .Build()) { - var hostingEnv = host.Services.GetService(); + var hostingEnv = host.Services.GetService(); Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName); } } diff --git a/src/Hosting/Hosting/test/WebHostTests.cs b/src/Hosting/Hosting/test/WebHostTests.cs index ed4ee43c1e..177ec6c8cd 100644 --- a/src/Hosting/Hosting/test/WebHostTests.cs +++ b/src/Hosting/Hosting/test/WebHostTests.cs @@ -167,9 +167,9 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup("Microsoft.AspNetCore.Hosting.Tests") .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); #pragma warning disable CS0618 // Type or member is obsolete - var lifetime2 = host.Services.GetRequiredService(); + var lifetime2 = host.Services.GetRequiredService(); #pragma warning restore CS0618 // Type or member is obsolete var server = (FakeServer)host.Services.GetRequiredService(); @@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup("Microsoft.AspNetCore.Hosting.Tests") .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); var applicationStartedEvent = new ManualResetEventSlim(false); var applicationStoppingEvent = new ManualResetEventSlim(false); var applicationStoppedEvent = new ManualResetEventSlim(false); @@ -416,9 +416,9 @@ namespace Microsoft.AspNetCore.Hosting .UseFakeServer() .Build()) { - var applicationLifetime = host.Services.GetService(); + var applicationLifetime = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var applicationLifetime2 = host.Services.GetService(); + var applicationLifetime2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.False(applicationLifetime.ApplicationStarted.IsCancellationRequested); @@ -437,9 +437,9 @@ namespace Microsoft.AspNetCore.Hosting .UseFakeServer() .Build()) { - var applicationLifetime = host.Services.GetService(); + var applicationLifetime = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var applicationLifetime2 = host.Services.GetService(); + var applicationLifetime2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted); @@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); lifetime.StopApplication(); await host.StartAsync(); @@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); lifetime.StopApplication(); await host.StartAsync(); @@ -562,7 +562,7 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); lifetime.StopApplication(); var svc = (TestHostedService)host.Services.GetRequiredService(); @@ -605,7 +605,7 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); Assert.Equal(0, startedCalls); @@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var lifetime = host.Services.GetRequiredService(); + var lifetime = host.Services.GetRequiredService(); Assert.Equal(0, startedCalls); await host.StartAsync(); @@ -687,9 +687,9 @@ namespace Microsoft.AspNetCore.Hosting }) .Build()) { - var applicationLifetime = host.Services.GetService(); + var applicationLifetime = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var applicationLifetime2 = host.Services.GetService(); + var applicationLifetime2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted); @@ -721,9 +721,9 @@ namespace Microsoft.AspNetCore.Hosting .Build()) { await host.StartAsync(); - var env = host.Services.GetService(); + var env = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var env2 = host.Services.GetService(); + var env2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal("Changed", env.EnvironmentName); Assert.Equal("Changed", env2.EnvironmentName); @@ -808,9 +808,9 @@ namespace Microsoft.AspNetCore.Hosting { using (var host = CreateBuilder().UseFakeServer().Build()) { - var env = host.Services.GetService(); + var env = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var env2 = host.Services.GetService(); + var env2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(EnvironmentName.Production, env.EnvironmentName); Assert.Equal(EnvironmentName.Production, env2.EnvironmentName); @@ -831,9 +831,9 @@ namespace Microsoft.AspNetCore.Hosting using (var host = CreateBuilder(config).UseFakeServer().Build()) { - var env = host.Services.GetService(); + var env = host.Services.GetService(); #pragma warning disable CS0618 // Type or member is obsolete - var env2 = host.Services.GetService(); + var env2 = host.Services.GetService(); #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(EnvironmentName.Staging, env.EnvironmentName); Assert.Equal(EnvironmentName.Staging, env.EnvironmentName); @@ -854,9 +854,15 @@ namespace Microsoft.AspNetCore.Hosting using (var host = CreateBuilder(config).UseFakeServer().Build()) { - var env = host.Services.GetService(); + var env = host.Services.GetService(); Assert.Equal(Path.GetFullPath("testroot"), env.WebRootPath); Assert.True(env.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists); + +#pragma warning disable CS0618 // Type or member is obsolete + var env1 = host.Services.GetService(); +#pragma warning restore CS0618 // Type or member is obsolete + Assert.Equal(Path.GetFullPath("testroot"), env1.WebRootPath); + Assert.True(env1.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists); } } @@ -866,7 +872,7 @@ namespace Microsoft.AspNetCore.Hosting using (var host = CreateBuilder().UseFakeServer().Build()) { await host.StartAsync(); - var env = host.Services.GetRequiredService(); + var env = host.Services.GetRequiredService(); Assert.True(env.IsEnvironment(EnvironmentName.Production)); Assert.True(env.IsEnvironment("producTion")); } @@ -1034,10 +1040,12 @@ namespace Microsoft.AspNetCore.Hosting private class TestHostedService : IHostedService, IDisposable { - private readonly IApplicationLifetime _lifetime; + private readonly IHostApplicationLifetime _lifetime; #pragma warning disable CS0618 // Type or member is obsolete - public TestHostedService(IApplicationLifetime lifetime, Extensions.Hosting.IApplicationLifetime lifetime2) + public TestHostedService(IHostApplicationLifetime lifetime, + AspNetCore.Hosting.IApplicationLifetime lifetime1, + Extensions.Hosting.IApplicationLifetime lifetime2) #pragma warning restore CS0618 // Type or member is obsolete { _lifetime = lifetime; diff --git a/src/Hosting/WindowsServices/src/WebHostService.cs b/src/Hosting/WindowsServices/src/WebHostService.cs index 016c877bc2..452c116e2f 100644 --- a/src/Hosting/WindowsServices/src/WebHostService.cs +++ b/src/Hosting/WindowsServices/src/WebHostService.cs @@ -5,6 +5,7 @@ using System; using System.ComponentModel; using System.ServiceProcess; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting.WindowsServices { @@ -44,7 +45,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices // race conditions. _host .Services - .GetRequiredService() + .GetRequiredService() .ApplicationStopping .Register(() => { diff --git a/src/Hosting/WindowsServices/test/WebHostServiceTests.cs b/src/Hosting/WindowsServices/test/WebHostServiceTests.cs index df341fc830..10bc54cfe2 100644 --- a/src/Hosting/WindowsServices/test/WebHostServiceTests.cs +++ b/src/Hosting/WindowsServices/test/WebHostServiceTests.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Testing.xunit; using Xunit; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting { @@ -25,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting { var host = new WebHostBuilder().UseServer(new FakeServer()).Configure(x => { }).Build(); var webHostService = new WebHostService(host); - var applicationLifetime = host.Services.GetRequiredService(); + var applicationLifetime = host.Services.GetRequiredService(); applicationLifetime.StopApplication(); webHostService.Start(); @@ -39,7 +40,7 @@ namespace Microsoft.AspNetCore.Hosting { var host = new WebHostBuilder().UseServer( new FakeServer() ).Configure( x => { } ).Build(); var webHostService = new WebHostService(host); - var applicationLifetime = host.Services.GetRequiredService(); + var applicationLifetime = host.Services.GetRequiredService(); webHostService.Start(); applicationLifetime.StopApplication(); diff --git a/src/Hosting/test/testassets/IStartupInjectionAssemblyName/Program.cs b/src/Hosting/test/testassets/IStartupInjectionAssemblyName/Program.cs index 405ec1fba0..4db38cff4a 100644 --- a/src/Hosting/test/testassets/IStartupInjectionAssemblyName/Program.cs +++ b/src/Hosting/test/testassets/IStartupInjectionAssemblyName/Program.cs @@ -1,11 +1,10 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace IStartupInjectionAssemblyName { @@ -14,7 +13,7 @@ namespace IStartupInjectionAssemblyName public static void Main(string[] args) { var webHost = CreateWebHostBuilder(args).Build(); - var applicationName = webHost.Services.GetRequiredService().ApplicationName; + var applicationName = webHost.Services.GetRequiredService().ApplicationName; Console.WriteLine(applicationName); Console.ReadKey(); } diff --git a/src/Hosting/test/testassets/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs b/src/Hosting/test/testassets/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs index 8b223d9e5a..1c24852b65 100644 --- a/src/Hosting/test/testassets/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs +++ b/src/Hosting/test/testassets/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs @@ -4,13 +4,14 @@ using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Hosting.TestSites { public class StartupShutdown { - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationLifetime lifetime) + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostApplicationLifetime lifetime) { lifetime.ApplicationStarted.Register(() => { diff --git a/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Program.cs b/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Program.cs index 70080426f5..590dd23a95 100644 --- a/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Program.cs +++ b/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Program.cs @@ -1,5 +1,6 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using System.IO; diff --git a/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Startup.cs b/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Startup.cs index a73137de4f..2e346e9c21 100644 --- a/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Startup.cs +++ b/src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using ApiAuthSample.Data; using ApiAuthSample.Models; @@ -42,7 +43,7 @@ namespace ApiAuthSample } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Identity/ApiAuthorization.IdentityServer/src/Authentication/AuthenticationBuilderExtensions.cs b/src/Identity/ApiAuthorization.IdentityServer/src/Authentication/AuthenticationBuilderExtensions.cs index 457160ae38..65d2c327fa 100644 --- a/src/Identity/ApiAuthorization.IdentityServer/src/Authentication/AuthenticationBuilderExtensions.cs +++ b/src/Identity/ApiAuthorization.IdentityServer/src/Authentication/AuthenticationBuilderExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Authentication var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme; var localApiDescriptor = sp.GetRequiredService(); - var hostingEnvironment = sp.GetRequiredService(); + var hostingEnvironment = sp.GetRequiredService(); var apiName = hostingEnvironment.ApplicationName + IdentityServerJwtNameSuffix; return new IdentityServerJwtBearerOptionsConfiguration(schemeName, apiName, localApiDescriptor); diff --git a/src/Identity/ApiAuthorization.IdentityServer/src/Configuration/IdentityServerJwtApiDescriptor.cs b/src/Identity/ApiAuthorization.IdentityServer/src/Configuration/IdentityServerJwtApiDescriptor.cs index 6653c53408..e2ebfb5b8b 100644 --- a/src/Identity/ApiAuthorization.IdentityServer/src/Configuration/IdentityServerJwtApiDescriptor.cs +++ b/src/Identity/ApiAuthorization.IdentityServer/src/Configuration/IdentityServerJwtApiDescriptor.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Hosting; @@ -8,12 +8,12 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration { internal class IdentityServerJwtDescriptor : IIdentityServerJwtDescriptor { - public IdentityServerJwtDescriptor(IHostingEnvironment environment) + public IdentityServerJwtDescriptor(IWebHostEnvironment environment) { Environment = environment; } - public IHostingEnvironment Environment { get; } + public IWebHostEnvironment Environment { get; } public IDictionary GetResourceDefinitions() { diff --git a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/LocalApiDescriptorTests.cs b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/LocalApiDescriptorTests.cs index 9537fa9e18..368e7130f4 100644 --- a/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/LocalApiDescriptorTests.cs +++ b/src/Identity/ApiAuthorization.IdentityServer/test/Configuration/LocalApiDescriptorTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Hosting; @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration public void LocalApiDescriptor_DefinesApiResources() { // Arrange - var environment = new Mock(); + var environment = new Mock(); environment.SetupGet(e => e.ApplicationName).Returns("Test"); var descriptor = new IdentityServerJwtDescriptor(environment.Object); diff --git a/src/Identity/UI/src/Areas/Identity/Pages/V3/_Layout.cshtml b/src/Identity/UI/src/Areas/Identity/Pages/V3/_Layout.cshtml index e647595e6f..de50192426 100644 --- a/src/Identity/UI/src/Areas/Identity/Pages/V3/_Layout.cshtml +++ b/src/Identity/UI/src/Areas/Identity/Pages/V3/_Layout.cshtml @@ -1,6 +1,6 @@ @using Microsoft.AspNetCore.Hosting @using Microsoft.AspNetCore.Mvc.ViewEngines -@inject IHostingEnvironment Environment +@inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine diff --git a/src/Identity/UI/src/Areas/Identity/Pages/V4/_Layout.cshtml b/src/Identity/UI/src/Areas/Identity/Pages/V4/_Layout.cshtml index 461668be88..34ca1dcd54 100644 --- a/src/Identity/UI/src/Areas/Identity/Pages/V4/_Layout.cshtml +++ b/src/Identity/UI/src/Areas/Identity/Pages/V4/_Layout.cshtml @@ -1,6 +1,6 @@ -@using Microsoft.AspNetCore.Hosting +@using Microsoft.AspNetCore.Hosting @using Microsoft.AspNetCore.Mvc.ViewEngines -@inject IHostingEnvironment Environment +@inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine diff --git a/src/Identity/UI/src/IdentityDefaultUIConfigureOptions.cs b/src/Identity/UI/src/IdentityDefaultUIConfigureOptions.cs index d2a83b900d..0a35d53a27 100644 --- a/src/Identity/UI/src/IdentityDefaultUIConfigureOptions.cs +++ b/src/Identity/UI/src/IdentityDefaultUIConfigureOptions.cs @@ -22,14 +22,14 @@ namespace Microsoft.AspNetCore.Identity.UI private const string IdentityUIDefaultAreaName = "Identity"; public IdentityDefaultUIConfigureOptions( - IHostingEnvironment environment, + IWebHostEnvironment environment, IOptions uiOptions) { Environment = environment; UiOptions = uiOptions; } - public IHostingEnvironment Environment { get; } + public IWebHostEnvironment Environment { get; } public IOptions UiOptions { get; } public void PostConfigure(string name, RazorPagesOptions options) diff --git a/src/Identity/samples/IdentitySample.DefaultUI/Startup.cs b/src/Identity/samples/IdentitySample.DefaultUI/Startup.cs index 2fd942e066..12854864ce 100644 --- a/src/Identity/samples/IdentitySample.DefaultUI/Startup.cs +++ b/src/Identity/samples/IdentitySample.DefaultUI/Startup.cs @@ -6,13 +6,14 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace IdentitySample.DefaultUI { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) @@ -43,7 +44,7 @@ namespace IdentitySample.DefaultUI // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { diff --git a/src/Identity/samples/IdentitySample.Mvc/Startup.cs b/src/Identity/samples/IdentitySample.Mvc/Startup.cs index 15db01da7f..117e996e66 100644 --- a/src/Identity/samples/IdentitySample.Mvc/Startup.cs +++ b/src/Identity/samples/IdentitySample.Mvc/Startup.cs @@ -7,13 +7,14 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace IdentitySample { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) @@ -55,7 +56,7 @@ namespace IdentitySample } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { diff --git a/src/Identity/testassets/Identity.DefaultUI.WebSite/NoIdentityStartup.cs b/src/Identity/testassets/Identity.DefaultUI.WebSite/NoIdentityStartup.cs index 3122315479..cfe2e87fce 100644 --- a/src/Identity/testassets/Identity.DefaultUI.WebSite/NoIdentityStartup.cs +++ b/src/Identity/testassets/Identity.DefaultUI.WebSite/NoIdentityStartup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Identity.DefaultUI.WebSite { @@ -39,7 +40,7 @@ namespace Identity.DefaultUI.WebSite } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Identity/testassets/Identity.DefaultUI.WebSite/Program.cs b/src/Identity/testassets/Identity.DefaultUI.WebSite/Program.cs index 01391c8d9b..313e5546ce 100644 --- a/src/Identity/testassets/Identity.DefaultUI.WebSite/Program.cs +++ b/src/Identity/testassets/Identity.DefaultUI.WebSite/Program.cs @@ -1,10 +1,11 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; using System.Reflection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Identity.DefaultUI.WebSite diff --git a/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs b/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs index 3fb53fa2e8..e7138842db 100644 --- a/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs +++ b/src/Identity/testassets/Identity.DefaultUI.WebSite/StartupBase.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; @@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; namespace Identity.DefaultUI.WebSite { @@ -53,7 +54,7 @@ namespace Identity.DefaultUI.WebSite } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Middleware/CORS/samples/SampleDestination/Startup.cs b/src/Middleware/CORS/samples/SampleDestination/Startup.cs index b17c504ad8..740346cfde 100644 --- a/src/Middleware/CORS/samples/SampleDestination/Startup.cs +++ b/src/Middleware/CORS/samples/SampleDestination/Startup.cs @@ -56,7 +56,7 @@ namespace SampleDestination services.AddRouting(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseRouting(routing => { diff --git a/src/Middleware/CORS/samples/SampleDestination/StartupWithoutEndpointRouting.cs b/src/Middleware/CORS/samples/SampleDestination/StartupWithoutEndpointRouting.cs index fcc817585e..590d26c0f8 100644 --- a/src/Middleware/CORS/samples/SampleDestination/StartupWithoutEndpointRouting.cs +++ b/src/Middleware/CORS/samples/SampleDestination/StartupWithoutEndpointRouting.cs @@ -26,7 +26,7 @@ namespace SampleDestination services.AddCors(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.Map("/allow-origin", innerBuilder => { diff --git a/src/Middleware/CORS/samples/SampleOrigin/Startup.cs b/src/Middleware/CORS/samples/SampleOrigin/Startup.cs index 37f49bdee0..6ac4cf1621 100644 --- a/src/Middleware/CORS/samples/SampleOrigin/Startup.cs +++ b/src/Middleware/CORS/samples/SampleOrigin/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; @@ -15,7 +15,7 @@ namespace SampleOrigin { } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseDefaultFiles(); app.UseStaticFiles(); diff --git a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs index d1d40b2e07..ea568010ca 100644 --- a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs +++ b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Diagnostics RequestDelegate next, IOptions options, ILoggerFactory loggerFactory, - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, DiagnosticSource diagnosticSource) { if (next == null) diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/BasicStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/BasicStartup.cs index c89d78c8e5..e4473417bc 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/BasicStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/BasicStartup.cs @@ -14,7 +14,7 @@ namespace HealthChecksSample services.AddHealthChecks(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware at the URL /health. // diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/CustomWriterStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/CustomWriterStartup.cs index 6e37b1c6ff..ad5776068b 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/CustomWriterStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/CustomWriterStartup.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; @@ -23,7 +23,7 @@ namespace HealthChecksSample .AddGCInfoCheck("GCInfo"); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware at the URL /health // diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DBHealthStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DBHealthStartup.cs index 46639d26ea..40c7c050d1 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DBHealthStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DBHealthStartup.cs @@ -1,4 +1,4 @@ - + using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -25,7 +25,7 @@ namespace HealthChecksSample .AddCheck("MyDatabase", new SqlConnectionHealthCheck(Configuration["ConnectionStrings:DefaultConnection"])); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware at the URL /health. // diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DbContextHealthStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DbContextHealthStartup.cs index 5f04ea0ea0..2a4dedf763 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DbContextHealthStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/DbContextHealthStartup.cs @@ -38,7 +38,7 @@ namespace HealthChecksSample }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware at the URL /health. // diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/LivenessProbeStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/LivenessProbeStartup.cs index 82676221ce..9de0648238 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/LivenessProbeStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/LivenessProbeStartup.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Hosting; @@ -18,7 +18,7 @@ namespace HealthChecksSample .AddCheck("Slow", failureStatus: null, tags: new[] { "ready", }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware twice: // - at /health/ready for 'readiness' diff --git a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/ManagementPortStartup.cs b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/ManagementPortStartup.cs index 79b38dc875..1272e08e30 100644 --- a/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/ManagementPortStartup.cs +++ b/src/Middleware/HealthChecks/test/testassets/HealthChecksSample/ManagementPortStartup.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; @@ -22,7 +22,7 @@ namespace HealthChecksSample services.AddHealthChecks(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { // This will register the health checks middleware at the URL /health but only on the specified port. // diff --git a/src/Middleware/HostFiltering/sample/Startup.cs b/src/Middleware/HostFiltering/sample/Startup.cs index 283d8ee7f9..ca0d74ccbd 100644 --- a/src/Middleware/HostFiltering/sample/Startup.cs +++ b/src/Middleware/HostFiltering/sample/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -44,7 +44,7 @@ namespace HostFilteringSample services.AddSingleton>(new ConfigurationChangeTokenSource(Config)); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseHostFiltering(); diff --git a/src/Middleware/HttpsPolicy/sample/Startup.cs b/src/Middleware/HttpsPolicy/sample/Startup.cs index 91888a01b4..6f2f5f7eb5 100644 --- a/src/Middleware/HttpsPolicy/sample/Startup.cs +++ b/src/Middleware/HttpsPolicy/sample/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace HttpsSample @@ -33,7 +34,7 @@ namespace HttpsSample }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment environment) + public void Configure(IApplicationBuilder app, IWebHostEnvironment environment) { if (!environment.IsDevelopment()) { diff --git a/src/Middleware/Middleware.sln b/src/Middleware/Middleware.sln index 7b193f6521..8bde720ff9 100644 --- a/src/Middleware/Middleware.sln +++ b/src/Middleware/Middleware.sln @@ -253,6 +253,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleOrigin", "CORS\sample EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NodeServices", "NodeServices", "{17B409B3-7EC6-49D8-847E-CFAA319E01B5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeServicesExamples", "NodeServices\samples\NodeServicesExamples\NodeServicesExamples.csproj", "{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.NodeServices", "NodeServices\src\Microsoft.AspNetCore.NodeServices.csproj", "{40951683-DBC4-437A-BBAB-2FA7147E11EA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SpaServices", "SpaServices", "{D6FA4ABE-E685-4EDD-8B06-D8777E76B472}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Webpack", "SpaServices\samples\Webpack\Webpack.csproj", "{121DFA13-E965-4C91-A175-19EF20DFD5AC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices", "SpaServices\src\Microsoft.AspNetCore.SpaServices.csproj", "{D9D02772-1D53-45C3-B2CC-888F9978958C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices.Extensions", "SpaServices.Extensions\src\Microsoft.AspNetCore.SpaServices.Extensions.csproj", "{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1391,6 +1405,66 @@ Global {47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x64.Build.0 = Release|Any CPU {47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.ActiveCfg = Release|Any CPU {47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.Build.0 = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x64.Build.0 = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x86.Build.0 = Debug|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|Any CPU.Build.0 = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x64.ActiveCfg = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x64.Build.0 = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x86.ActiveCfg = Release|Any CPU + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x86.Build.0 = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x64.ActiveCfg = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x64.Build.0 = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x86.ActiveCfg = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x86.Build.0 = Debug|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|Any CPU.Build.0 = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x64.ActiveCfg = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x64.Build.0 = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.ActiveCfg = Release|Any CPU + {40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.Build.0 = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.ActiveCfg = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.Build.0 = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.ActiveCfg = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.Build.0 = Debug|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.Build.0 = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.ActiveCfg = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.Build.0 = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.ActiveCfg = Release|Any CPU + {121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.Build.0 = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x64.ActiveCfg = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x64.Build.0 = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x86.ActiveCfg = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x86.Build.0 = Debug|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|Any CPU.Build.0 = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x64.ActiveCfg = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x64.Build.0 = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x86.ActiveCfg = Release|Any CPU + {D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x86.Build.0 = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x64.ActiveCfg = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x64.Build.0 = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x86.ActiveCfg = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x86.Build.0 = Debug|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|Any CPU.Build.0 = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x64.ActiveCfg = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x64.Build.0 = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x86.ActiveCfg = Release|Any CPU + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1501,6 +1575,11 @@ Global {52CDD110-77DD-4C4D-8C72-4570F6EF20DD} = {7CF63806-4C4F-4C48-8922-A75113975308} {198FFE3B-0346-4856-A6C9-8752D51C4EB3} = {7CF63806-4C4F-4C48-8922-A75113975308} {47B6636D-09A3-47AE-9303-9F5D15EEE9D8} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0} + {C801B6A3-906F-406F-BA25-EAE0B4BCE5C9} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5} + {40951683-DBC4-437A-BBAB-2FA7147E11EA} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5} + {121DFA13-E965-4C91-A175-19EF20DFD5AC} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472} + {D9D02772-1D53-45C3-B2CC-888F9978958C} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472} + {5D5B7E54-9323-498A-8983-E9BDFA3B2D07} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA} diff --git a/src/Middleware/NodeServices/samples/NodeServicesExamples/Startup.cs b/src/Middleware/NodeServices/samples/NodeServicesExamples/Startup.cs index 26f2ae86c4..934d39e512 100644 --- a/src/Middleware/NodeServices/samples/NodeServicesExamples/Startup.cs +++ b/src/Middleware/NodeServices/samples/NodeServicesExamples/Startup.cs @@ -21,7 +21,7 @@ namespace NodeServicesExamples } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, INodeServices nodeServices) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, INodeServices nodeServices) { app.UseDeveloperExceptionPage(); diff --git a/src/Middleware/NodeServices/src/Configuration/NodeServicesOptions.cs b/src/Middleware/NodeServices/src/Configuration/NodeServicesOptions.cs index 6a72b0023b..4d8d2e6a2b 100644 --- a/src/Middleware/NodeServices/src/Configuration/NodeServicesOptions.cs +++ b/src/Middleware/NodeServices/src/Configuration/NodeServicesOptions.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.NodeServices { @@ -35,7 +36,7 @@ namespace Microsoft.AspNetCore.NodeServices InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds; WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone(); - var hostEnv = serviceProvider.GetService(); + var hostEnv = serviceProvider.GetService(); if (hostEnv != null) { // In an ASP.NET environment, we can use the IHostingEnvironment data to auto-populate a few @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.NodeServices ProjectPath = Directory.GetCurrentDirectory(); } - var applicationLifetime = serviceProvider.GetService(); + var applicationLifetime = serviceProvider.GetService(); if (applicationLifetime != null) { ApplicationStoppingToken = applicationLifetime.ApplicationStopping; @@ -110,4 +111,4 @@ namespace Microsoft.AspNetCore.NodeServices /// public CancellationToken ApplicationStoppingToken { get; set; } } -} \ No newline at end of file +} diff --git a/src/Middleware/Rewrite/sample/Startup.cs b/src/Middleware/Rewrite/sample/Startup.cs index fcf3a93314..5a50edd9d8 100644 --- a/src/Middleware/Rewrite/sample/Startup.cs +++ b/src/Middleware/Rewrite/sample/Startup.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; @@ -13,12 +13,12 @@ namespace RewriteSample { public class Startup { - public Startup(IHostingEnvironment environment) + public Startup(IWebHostEnvironment environment) { Environment = environment; } - public IHostingEnvironment Environment { get; private set; } + public IWebHostEnvironment Environment { get; private set; } public void ConfigureServices(IServiceCollection services) { @@ -32,7 +32,7 @@ namespace RewriteSample }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseRewriter(); diff --git a/src/Middleware/Rewrite/src/RewriteMiddleware.cs b/src/Middleware/Rewrite/src/RewriteMiddleware.cs index df62984425..8854ec775d 100644 --- a/src/Middleware/Rewrite/src/RewriteMiddleware.cs +++ b/src/Middleware/Rewrite/src/RewriteMiddleware.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Rewrite /// The middleware options, containing the rules to apply. public RewriteMiddleware( RequestDelegate next, - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, ILoggerFactory loggerFactory, IOptions options) { diff --git a/src/Middleware/Session/samples/Startup.cs b/src/Middleware/Session/samples/Startup.cs index 38d8199d93..c776d8e2ff 100644 --- a/src/Middleware/Session/samples/Startup.cs +++ b/src/Middleware/Session/samples/Startup.cs @@ -5,7 +5,6 @@ using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -13,22 +12,10 @@ namespace SessionSample { public class Startup { - public Startup(IHostingEnvironment env) + public Startup() { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json"); - - if (env.IsDevelopment()) - { - builder.AddUserSecrets(); - } - - Configuration = builder.Build(); } - public IConfigurationRoot Configuration { get; set; } - public void ConfigureServices(IServiceCollection services) { // Uncomment the following line to use the in-memory implementation of IDistributedCache diff --git a/src/Middleware/SpaServices.Extensions/src/Prerendering/SpaPrerenderingExtensions.cs b/src/Middleware/SpaServices.Extensions/src/Prerendering/SpaPrerenderingExtensions.cs index b791b3a6f0..3b817494d7 100644 --- a/src/Middleware/SpaServices.Extensions/src/Prerendering/SpaPrerenderingExtensions.cs +++ b/src/Middleware/SpaServices.Extensions/src/Prerendering/SpaPrerenderingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Hosting; @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.SpaServices; using Microsoft.AspNetCore.SpaServices.Extensions.Util; using Microsoft.AspNetCore.SpaServices.Prerendering; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Net.Http.Headers; using System; using System.Collections.Generic; @@ -61,9 +62,9 @@ namespace Microsoft.AspNetCore.Builder var applicationBuilder = spaBuilder.ApplicationBuilder; var serviceProvider = applicationBuilder.ApplicationServices; var nodeServices = GetNodeServices(serviceProvider); - var applicationStoppingToken = serviceProvider.GetRequiredService() + var applicationStoppingToken = serviceProvider.GetRequiredService() .ApplicationStopping; - var applicationBasePath = serviceProvider.GetRequiredService() + var applicationBasePath = serviceProvider.GetRequiredService() .ContentRootPath; var moduleExport = new JavaScriptModuleExport(capturedBootModulePath); var excludePathStrings = (options.ExcludeUrls ?? Array.Empty()) diff --git a/src/Middleware/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs b/src/Middleware/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs index 96f62ce756..99cc8c4ca8 100644 --- a/src/Middleware/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs +++ b/src/Middleware/SpaServices.Extensions/src/Proxying/ConditionalProxyMiddleware.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Hosting; using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy { @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy string pathPrefix, TimeSpan requestTimeout, Task baseUriTask, - IApplicationLifetime applicationLifetime) + IHostApplicationLifetime applicationLifetime) { if (!pathPrefix.StartsWith("/")) { diff --git a/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxyingExtensions.cs b/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxyingExtensions.cs index 3270c1b8aa..1a41ce0308 100644 --- a/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxyingExtensions.cs +++ b/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxyingExtensions.cs @@ -1,9 +1,10 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices; using Microsoft.AspNetCore.SpaServices.Extensions.Proxy; +using Microsoft.Extensions.Hosting; using System; using System.Threading; using System.Threading.Tasks; @@ -85,8 +86,8 @@ namespace Microsoft.AspNetCore.Builder { var applicationLifetime = appBuilder .ApplicationServices - .GetService(typeof(IApplicationLifetime)); - return ((IApplicationLifetime)applicationLifetime).ApplicationStopping; + .GetService(typeof(IHostApplicationLifetime)); + return ((IHostApplicationLifetime)applicationLifetime).ApplicationStopping; } } } diff --git a/src/Middleware/SpaServices.Extensions/src/SpaDefaultPageMiddleware.cs b/src/Middleware/SpaServices.Extensions/src/SpaDefaultPageMiddleware.cs index c3c540b150..e07c7e28b7 100644 --- a/src/Middleware/SpaServices.Extensions/src/SpaDefaultPageMiddleware.cs +++ b/src/Middleware/SpaServices.Extensions/src/SpaDefaultPageMiddleware.cs @@ -1,9 +1,10 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using System; namespace Microsoft.AspNetCore.SpaServices @@ -45,7 +46,7 @@ namespace Microsoft.AspNetCore.SpaServices // Try to clarify the common scenario where someone runs an application in // Production environment without first publishing the whole application // or at least building the SPA. - var hostEnvironment = (IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment)); + var hostEnvironment = (IWebHostEnvironment)context.RequestServices.GetService(typeof(IWebHostEnvironment)); if (hostEnvironment != null && hostEnvironment.IsProduction()) { message += "Your application is running in Production mode, so make sure it has " + diff --git a/src/Middleware/SpaServices.Extensions/src/StaticFiles/DefaultSpaStaticFileProvider.cs b/src/Middleware/SpaServices.Extensions/src/StaticFiles/DefaultSpaStaticFileProvider.cs index 0c2348feaa..4631b8939c 100644 --- a/src/Middleware/SpaServices.Extensions/src/StaticFiles/DefaultSpaStaticFileProvider.cs +++ b/src/Middleware/SpaServices.Extensions/src/StaticFiles/DefaultSpaStaticFileProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Hosting; @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.SpaServices.StaticFiles $"of {nameof(options)} cannot be null or empty."); } - var env = serviceProvider.GetRequiredService(); + var env = serviceProvider.GetRequiredService(); var absoluteRootPath = Path.Combine( env.ContentRootPath, options.RootPath); diff --git a/src/Middleware/SpaServices/samples/Webpack/ActionResults/PrerenderResult.cs b/src/Middleware/SpaServices/samples/Webpack/ActionResults/PrerenderResult.cs index 4f2c8f50c9..b44d761b01 100644 --- a/src/Middleware/SpaServices/samples/Webpack/ActionResults/PrerenderResult.cs +++ b/src/Middleware/SpaServices/samples/Webpack/ActionResults/PrerenderResult.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.NodeServices; using Microsoft.AspNetCore.SpaServices.Prerendering; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Webpack.ActionResults { @@ -26,8 +27,8 @@ namespace Webpack.ActionResults public override async Task ExecuteResultAsync(ActionContext context) { var nodeServices = context.HttpContext.RequestServices.GetRequiredService(); - var hostEnv = context.HttpContext.RequestServices.GetRequiredService(); - var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService(); + var hostEnv = context.HttpContext.RequestServices.GetRequiredService(); + var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService(); var applicationBasePath = hostEnv.ContentRootPath; var request = context.HttpContext.Request; var response = context.HttpContext.Response; @@ -48,4 +49,4 @@ namespace Webpack.ActionResults await response.WriteAsync(prerenderedHtml.Html); } } -} \ No newline at end of file +} diff --git a/src/Middleware/SpaServices/samples/Webpack/Startup.cs b/src/Middleware/SpaServices/samples/Webpack/Startup.cs index a471781e09..c6e91d2fe7 100644 --- a/src/Middleware/SpaServices/samples/Webpack/Startup.cs +++ b/src/Middleware/SpaServices/samples/Webpack/Startup.cs @@ -19,7 +19,7 @@ namespace Webpack } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseDeveloperExceptionPage(); diff --git a/src/Middleware/SpaServices/src/Prerendering/DefaultSpaPrerenderer.cs b/src/Middleware/SpaServices/src/Prerendering/DefaultSpaPrerenderer.cs index 946f96d360..022c39fc01 100644 --- a/src/Middleware/SpaServices/src/Prerendering/DefaultSpaPrerenderer.cs +++ b/src/Middleware/SpaServices/src/Prerendering/DefaultSpaPrerenderer.cs @@ -1,8 +1,9 @@ -using System.Threading; +using System.Threading; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.NodeServices; using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.SpaServices.Prerendering { @@ -20,8 +21,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering public DefaultSpaPrerenderer( INodeServices nodeServices, - IApplicationLifetime applicationLifetime, - IHostingEnvironment hostingEnvironment, + IHostApplicationLifetime applicationLifetime, + IWebHostEnvironment hostingEnvironment, IHttpContextAccessor httpContextAccessor) { _applicationBasePath = hostingEnvironment.ContentRootPath; diff --git a/src/Middleware/SpaServices/src/Prerendering/PrerenderTagHelper.cs b/src/Middleware/SpaServices/src/Prerendering/PrerenderTagHelper.cs index 4e35228579..665fbff8ef 100644 --- a/src/Middleware/SpaServices/src/Prerendering/PrerenderTagHelper.cs +++ b/src/Middleware/SpaServices/src/Prerendering/PrerenderTagHelper.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.NodeServices; using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.SpaServices.Prerendering { @@ -31,11 +32,11 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering /// The . public PrerenderTagHelper(IServiceProvider serviceProvider) { - var hostEnv = (IHostingEnvironment)serviceProvider.GetService(typeof(IHostingEnvironment)); + var hostEnv = (IWebHostEnvironment)serviceProvider.GetService(typeof(IWebHostEnvironment)); _nodeServices = (INodeServices)serviceProvider.GetService(typeof(INodeServices)) ?? _fallbackNodeServices; _applicationBasePath = hostEnv.ContentRootPath; - var applicationLifetime = (IApplicationLifetime)serviceProvider.GetService(typeof(IApplicationLifetime)); + var applicationLifetime = (IHostApplicationLifetime)serviceProvider.GetService(typeof(IHostApplicationLifetime)); _applicationStoppingToken = applicationLifetime.ApplicationStopping; // Consider removing the following. Having it means you can get away with not putting app.AddNodeServices() diff --git a/src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs b/src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs index e731022e1f..861b7c396e 100644 --- a/src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs +++ b/src/Middleware/StaticFiles/samples/StaticFileSample/Startup.cs @@ -14,7 +14,7 @@ namespace StaticFilesSample services.AddDirectoryBrowser(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment host) + public void Configure(IApplicationBuilder app, IWebHostEnvironment host) { Console.WriteLine("webroot: " + host.WebRootPath); diff --git a/src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs b/src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs index 3c3a1c60b8..1f020dbe1c 100644 --- a/src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs +++ b/src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs @@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles /// Creates a new instance of the DefaultFilesMiddleware. /// /// The next middleware in the pipeline. - /// The used by this middleware. + /// The used by this middleware. /// The configuration options for this middleware. - public DefaultFilesMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions options) + public DefaultFilesMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions options) { if (next == null) { diff --git a/src/Middleware/StaticFiles/src/DirectoryBrowserMiddleware.cs b/src/Middleware/StaticFiles/src/DirectoryBrowserMiddleware.cs index 0ac1258c83..1ac950ebe9 100644 --- a/src/Middleware/StaticFiles/src/DirectoryBrowserMiddleware.cs +++ b/src/Middleware/StaticFiles/src/DirectoryBrowserMiddleware.cs @@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles /// Creates a new instance of the SendFileMiddleware. Using instance. /// /// The next middleware in the pipeline. - /// The used by this middleware. + /// The used by this middleware. /// The configuration for this middleware. - public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions options) + public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions options) : this(next, hostingEnv, HtmlEncoder.Default, options) { } @@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.StaticFiles /// Creates a new instance of the SendFileMiddleware. /// /// The next middleware in the pipeline. - /// The used by this middleware. + /// The used by this middleware. /// The used by the default . /// The configuration for this middleware. - public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, HtmlEncoder encoder, IOptions options) + public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, HtmlEncoder encoder, IOptions options) { if (next == null) { @@ -104,4 +104,4 @@ namespace Microsoft.AspNetCore.StaticFiles return contents.Exists; } } -} \ No newline at end of file +} diff --git a/src/Middleware/StaticFiles/src/Helpers.cs b/src/Middleware/StaticFiles/src/Helpers.cs index 733377cef3..a7a49e9070 100644 --- a/src/Middleware/StaticFiles/src/Helpers.cs +++ b/src/Middleware/StaticFiles/src/Helpers.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.StaticFiles { internal static class Helpers { - internal static IFileProvider ResolveFileProvider(IHostingEnvironment hostingEnv) + internal static IFileProvider ResolveFileProvider(IWebHostEnvironment hostingEnv) { if (hostingEnv.WebRootFileProvider == null) { throw new InvalidOperationException("Missing FileProvider."); diff --git a/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs b/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs index f35bf453f1..1a97a5e90a 100644 --- a/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs +++ b/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs @@ -30,10 +30,10 @@ namespace Microsoft.AspNetCore.StaticFiles /// Creates a new instance of the StaticFileMiddleware. /// /// The next middleware in the pipeline. - /// The used by this middleware. + /// The used by this middleware. /// The configuration options. /// An instance used to create loggers. - public StaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions options, ILoggerFactory loggerFactory) + public StaticFileMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions options, ILoggerFactory loggerFactory) { if (next == null) { diff --git a/src/Middleware/StaticFiles/test/FunctionalTests/StaticFileMiddlewareTests.cs b/src/Middleware/StaticFiles/test/FunctionalTests/StaticFileMiddlewareTests.cs index 0f9be47e97..7e55b79b78 100644 --- a/src/Middleware/StaticFiles/test/FunctionalTests/StaticFileMiddlewareTests.cs +++ b/src/Middleware/StaticFiles/test/FunctionalTests/StaticFileMiddlewareTests.cs @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.StaticFiles using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel))) { - var hostingEnvironment = server.Services.GetService(); + var hostingEnvironment = server.Services.GetService(); using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) }) { @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.StaticFiles using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel))) { - var hostingEnvironment = server.Services.GetService(); + var hostingEnvironment = server.Services.GetService(); using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) }) { diff --git a/src/Middleware/WebSockets/test/ConformanceTests/AutobahnTestApp/Startup.cs b/src/Middleware/WebSockets/test/ConformanceTests/AutobahnTestApp/Startup.cs index f244e76358..6c94e5e22b 100644 --- a/src/Middleware/WebSockets/test/ConformanceTests/AutobahnTestApp/Startup.cs +++ b/src/Middleware/WebSockets/test/ConformanceTests/AutobahnTestApp/Startup.cs @@ -12,7 +12,7 @@ namespace AutobahnTestApp public class Startup { // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { app.UseWebSockets(); diff --git a/src/MusicStore/samples/MusicStore/Controllers/AccountController.cs b/src/MusicStore/samples/MusicStore/Controllers/AccountController.cs index 25e5e43013..6551c4f7a3 100644 --- a/src/MusicStore/samples/MusicStore/Controllers/AccountController.cs +++ b/src/MusicStore/samples/MusicStore/Controllers/AccountController.cs @@ -458,7 +458,7 @@ namespace MusicStore.Controllers // TODO: Currently SignInManager.SignOut does not sign out OpenIdc and does not have a way to pass in a specific // AuthType to sign out. - var appEnv = HttpContext.RequestServices.GetService(); + var appEnv = HttpContext.RequestServices.GetService(); if (appEnv.EnvironmentName.StartsWith("OpenIdConnect")) { return new SignOutResult("OpenIdConnect", new AuthenticationProperties @@ -509,4 +509,4 @@ namespace MusicStore.Controllers #endregion } -} \ No newline at end of file +} diff --git a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/OpenIdConnect/OpenIdConnectBackChannelHttpHandler.cs b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/OpenIdConnect/OpenIdConnectBackChannelHttpHandler.cs index d29e51bdbf..7c2b85ab1a 100644 --- a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/OpenIdConnect/OpenIdConnectBackChannelHttpHandler.cs +++ b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/OpenIdConnect/OpenIdConnectBackChannelHttpHandler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Net.Http; using System.Threading; @@ -9,9 +9,9 @@ namespace MusicStore.Mocks.OpenIdConnect { internal class OpenIdConnectBackChannelHttpHandler : HttpMessageHandler { - private IHostingEnvironment _env; + private IWebHostEnvironment _env; - public OpenIdConnectBackChannelHttpHandler(IHostingEnvironment env) + public OpenIdConnectBackChannelHttpHandler(IWebHostEnvironment env) { _env = env; } diff --git a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs index 7b8384077e..4ddecfa7df 100644 --- a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs +++ b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs @@ -25,7 +25,7 @@ namespace MusicStore { private readonly Platform _platform; - public StartupOpenIdConnectTesting(IHostingEnvironment env) + public StartupOpenIdConnectTesting(IWebHostEnvironment env) { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. @@ -40,7 +40,7 @@ namespace MusicStore } public IConfiguration Configuration { get; private set; } - public IHostingEnvironment Env { get; } + public IWebHostEnvironment Env { get; } public void ConfigureServices(IServiceCollection services) { diff --git a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs index ffe81ad572..16744a703e 100644 --- a/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs +++ b/src/MusicStore/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs @@ -29,7 +29,7 @@ namespace MusicStore { private readonly Platform _platform; - public StartupSocialTesting(IHostingEnvironment hostingEnvironment) + public StartupSocialTesting(IWebHostEnvironment hostingEnvironment) { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. diff --git a/src/MusicStore/samples/MusicStore/Models/SampleData.cs b/src/MusicStore/samples/MusicStore/Models/SampleData.cs index 959c2679f1..b0364c8e50 100644 --- a/src/MusicStore/samples/MusicStore/Models/SampleData.cs +++ b/src/MusicStore/samples/MusicStore/Models/SampleData.cs @@ -79,7 +79,7 @@ namespace MusicStore.Models /// private static async Task CreateAdminUser(IServiceProvider serviceProvider) { - var env = serviceProvider.GetService(); + var env = serviceProvider.GetService(); var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) diff --git a/src/MusicStore/samples/MusicStore/Startup.cs b/src/MusicStore/samples/MusicStore/Startup.cs index df643e027b..1e33ec67e6 100644 --- a/src/MusicStore/samples/MusicStore/Startup.cs +++ b/src/MusicStore/samples/MusicStore/Startup.cs @@ -18,7 +18,7 @@ namespace MusicStore { private readonly Platform _platform; - public Startup(IHostingEnvironment hostingEnvironment) + public Startup(IWebHostEnvironment hostingEnvironment) { // Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' // is found in both the registered sources, then the later source will win. By this way a Local config @@ -220,4 +220,4 @@ namespace MusicStore SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait(); } } -} \ No newline at end of file +} diff --git a/src/MusicStore/samples/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/samples/MusicStore/StartupNtlmAuthentication.cs index c6c57e540e..36e6947e0b 100644 --- a/src/MusicStore/samples/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/samples/MusicStore/StartupNtlmAuthentication.cs @@ -36,7 +36,7 @@ namespace MusicStore /// public class StartupNtlmAuthentication { - public StartupNtlmAuthentication(IHostingEnvironment hostingEnvironment) + public StartupNtlmAuthentication(IWebHostEnvironment hostingEnvironment) { // Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' // is found in both the registered sources, then the later source will win. By this way a Local config diff --git a/src/MusicStore/samples/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/samples/MusicStore/StartupOpenIdConnect.cs index cb1a15aa87..e1ab91928d 100644 --- a/src/MusicStore/samples/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/samples/MusicStore/StartupOpenIdConnect.cs @@ -35,7 +35,7 @@ namespace MusicStore { private readonly Platform _platform; - public StartupOpenIdConnect(IHostingEnvironment hostingEnvironment) + public StartupOpenIdConnect(IWebHostEnvironment hostingEnvironment) { // Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' // is found in both the registered sources, then the later source will win. By this way a Local config can diff --git a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs index dfd4fc09d8..1a309d3e8f 100644 --- a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs +++ b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs @@ -78,7 +78,7 @@ namespace Microsoft.Extensions.DependencyInjection { manager = new ApplicationPartManager(); - var environment = GetServiceFromCollection(services); + var environment = GetServiceFromCollection(services); var entryAssemblyName = environment?.ApplicationName; if (string.IsNullOrEmpty(entryAssemblyName)) { diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/VirtualFileResultExecutor.cs b/src/Mvc/Mvc.Core/src/Infrastructure/VirtualFileResultExecutor.cs index 97a0584b9f..69a3607c5e 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/VirtualFileResultExecutor.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/VirtualFileResultExecutor.cs @@ -16,9 +16,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure { public class VirtualFileResultExecutor : FileResultExecutorBase, IActionResultExecutor { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public VirtualFileResultExecutor(ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) + public VirtualFileResultExecutor(ILoggerFactory loggerFactory, IWebHostEnvironment hostingEnvironment) : base(CreateLogger(loggerFactory)) { if (hostingEnvironment == null) diff --git a/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs b/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs index e89e151509..9f434c1f14 100644 --- a/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs +++ b/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs @@ -152,9 +152,9 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - var environment = new Mock(MockBehavior.Strict); + var environment = new Mock(MockBehavior.Strict); environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable(); - services.AddSingleton(environment.Object); + services.AddSingleton(environment.Object); // Act var builder = services.AddMvcCore(); @@ -173,12 +173,12 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - var environment = new Mock(MockBehavior.Strict); - services.AddSingleton(environment.Object); + var environment = new Mock(MockBehavior.Strict); + services.AddSingleton(environment.Object); - environment = new Mock(MockBehavior.Strict); + environment = new Mock(MockBehavior.Strict); environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable(); - services.AddSingleton(environment.Object); + services.AddSingleton(environment.Object); // Act var builder = services.AddMvcCore(); @@ -196,11 +196,11 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - var environment = new Mock(MockBehavior.Strict); + var environment = new Mock(MockBehavior.Strict); var assemblyName = typeof(MvcCoreServiceCollectionExtensionsTest).GetTypeInfo().Assembly.GetName(); var applicationName = assemblyName.FullName; environment.SetupGet(e => e.ApplicationName).Returns(applicationName).Verifiable(); - services.AddSingleton(environment.Object); + services.AddSingleton(environment.Object); // Act var builder = services.AddMvcCore(); diff --git a/src/Mvc/Mvc.Core/test/Filters/MiddlewareFilterConfigurationProviderTest.cs b/src/Mvc/Mvc.Core/test/Filters/MiddlewareFilterConfigurationProviderTest.cs index fb55e04bcd..e2e1dd24db 100644 --- a/src/Mvc/Mvc.Core/test/Filters/MiddlewareFilterConfigurationProviderTest.cs +++ b/src/Mvc/Mvc.Core/test/Filters/MiddlewareFilterConfigurationProviderTest.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters var loggerFactory = Mock.Of(); var services = new ServiceCollection(); services.AddSingleton(loggerFactory); - services.AddSingleton(Mock.Of()); + services.AddSingleton(Mock.Of()); var applicationBuilder = GetApplicationBuilder(services); var provider = new MiddlewareFilterConfigurationProvider(); @@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters { public void Configure( IApplicationBuilder appBuilder, - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, ILoggerFactory loggerFactory) { if (hostingEnvironment == null) @@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters { public void ConfigureProduction( IApplicationBuilder appBuilder, - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, ILoggerFactory loggerFactory) { if (hostingEnvironment == null) diff --git a/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs b/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs index 899b0a5404..7f7f6b78c1 100644 --- a/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs +++ b/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Mvc var path = Path.GetFullPath("helllo.txt"); var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -197,7 +197,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -285,7 +285,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -329,7 +329,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -371,7 +371,7 @@ namespace Microsoft.AspNetCore.Mvc var contentType = "text/plain; charset=us-ascii; p1=p1-value"; var result = new TestVirtualFileResult(path, contentType); result.EnableRangeProcessing = true; - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -412,7 +412,7 @@ namespace Microsoft.AspNetCore.Mvc var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt"); var result = new TestVirtualFileResult(path, "text/plain"); - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); @@ -504,7 +504,7 @@ namespace Microsoft.AspNetCore.Mvc var httpContext = GetHttpContext(); httpContext.Features.Set(sendFile); var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var appEnvironment = new Mock(); + var appEnvironment = new Mock(); appEnvironment.Setup(app => app.WebRootFileProvider) .Returns(GetFileProvider(path)); httpContext.RequestServices = new ServiceCollection() @@ -708,7 +708,7 @@ namespace Microsoft.AspNetCore.Mvc { var services = new ServiceCollection(); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); services.AddSingleton, TestVirtualFileResultExecutor>(); if (executorType != null) @@ -716,7 +716,7 @@ namespace Microsoft.AspNetCore.Mvc services.AddSingleton(typeof(IActionResultExecutor), executorType); } - services.AddSingleton(hostingEnvironment.Object); + services.AddSingleton(hostingEnvironment.Object); services.AddSingleton(NullLoggerFactory.Instance); return services; @@ -768,7 +768,7 @@ namespace Microsoft.AspNetCore.Mvc private class TestVirtualFileResultExecutor : VirtualFileResultExecutor { - public TestVirtualFileResultExecutor(ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) + public TestVirtualFileResultExecutor(ILoggerFactory loggerFactory, IWebHostEnvironment hostingEnvironment) : base(loggerFactory, hostingEnvironment) { } diff --git a/src/Mvc/Mvc.DataAnnotations/test/MvcDataAnnotationsMvcOptionsSetup.cs b/src/Mvc/Mvc.DataAnnotations/test/MvcDataAnnotationsMvcOptionsSetup.cs index 312f7d9aeb..6aae172e63 100644 --- a/src/Mvc/Mvc.DataAnnotations/test/MvcDataAnnotationsMvcOptionsSetup.cs +++ b/src/Mvc/Mvc.DataAnnotations/test/MvcDataAnnotationsMvcOptionsSetup.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Test // Arrange var services = new ServiceCollection(); - services.AddSingleton(Mock.Of()); + services.AddSingleton(Mock.Of()); services.AddSingleton(); services.AddSingleton>( Options.Create(new MvcDataAnnotationsLocalizationOptions())); diff --git a/src/Mvc/Mvc.Localization/src/ViewLocalizer.cs b/src/Mvc/Mvc.Localization/src/ViewLocalizer.cs index 3ec50fe965..f8e86c4c38 100644 --- a/src/Mvc/Mvc.Localization/src/ViewLocalizer.cs +++ b/src/Mvc/Mvc.Localization/src/ViewLocalizer.cs @@ -28,8 +28,8 @@ namespace Microsoft.AspNetCore.Mvc.Localization /// Creates a new . /// /// The . - /// The . - public ViewLocalizer(IHtmlLocalizerFactory localizerFactory, IHostingEnvironment hostingEnvironment) + /// The . + public ViewLocalizer(IHtmlLocalizerFactory localizerFactory, IWebHostEnvironment hostingEnvironment) { if (localizerFactory == null) { diff --git a/src/Mvc/Mvc.Localization/test/ViewLocalizerTest.cs b/src/Mvc/Mvc.Localization/test/ViewLocalizerTest.cs index ae1afa5ce2..991abf81db 100644 --- a/src/Mvc/Mvc.Localization/test/ViewLocalizerTest.cs +++ b/src/Mvc/Mvc.Localization/test/ViewLocalizerTest.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test public void ViewLocalizer_LooksForCorrectResourceBaseNameLocation(string appName, string viewPath, string executingPath, string expectedBaseName) { // Arrange - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns(appName); var htmlLocalizerFactory = new Mock(MockBehavior.Loose); var view = new Mock(); @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test public void ViewLocalizer_UseIndexer_ReturnsLocalizedHtmlString() { // Arrange - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var localizedString = new LocalizedHtmlString("Hello", "Bonjour"); @@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test public void ViewLocalizer_UseIndexerWithArguments_ReturnsLocalizedHtmlString() { // Arrange - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var localizedString = new LocalizedHtmlString("Hello", "Bonjour test"); @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -244,7 +244,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); @@ -268,7 +268,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Test // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.Object); diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/CSharpCompiler.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/CSharpCompiler.cs index 4aeb006421..ec1ea76ac0 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/CSharpCompiler.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/CSharpCompiler.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Emit; using Microsoft.CodeAnalysis.Text; using Microsoft.Extensions.DependencyModel; +using Microsoft.Extensions.Hosting; using DependencyContextCompilationOptions = Microsoft.Extensions.DependencyModel.CompilationOptions; namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation @@ -19,14 +20,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation internal class CSharpCompiler { private readonly RazorReferenceManager _referenceManager; - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; private bool _optionsInitialized; private CSharpParseOptions _parseOptions; private CSharpCompilationOptions _compilationOptions; private EmitOptions _emitOptions; private bool _emitPdb; - public CSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment) + public CSharpCompiler(RazorReferenceManager manager, IWebHostEnvironment hostingEnvironment) { _referenceManager = manager ?? throw new ArgumentNullException(nameof(manager)); _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); @@ -153,7 +154,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation } private static CSharpCompilationOptions GetCompilationOptions( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, DependencyContextCompilationOptions dependencyContextOptions) { var csharpCompilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); @@ -200,7 +201,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation } private static CSharpParseOptions GetParseOptions( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, DependencyContextCompilationOptions dependencyContextOptions) { var configurationSymbol = hostingEnvironment.IsDevelopment() ? "DEBUG" : "RELEASE"; diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/MvcRazorRuntimeCompilationOptionsSetup.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/MvcRazorRuntimeCompilationOptionsSetup.cs index e18689ccb3..9c19d20513 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/MvcRazorRuntimeCompilationOptionsSetup.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/MvcRazorRuntimeCompilationOptionsSetup.cs @@ -9,9 +9,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { internal class MvcRazorRuntimeCompilationOptionsSetup : IConfigureOptions { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public MvcRazorRuntimeCompilationOptionsSetup(IHostingEnvironment hostingEnvironment) + public MvcRazorRuntimeCompilationOptionsSetup(IWebHostEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); } diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectFileSystem.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectFileSystem.cs index f15d523b21..2a677d944d 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectFileSystem.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectFileSystem.cs @@ -14,9 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { private const string RazorFileExtension = ".cshtml"; private readonly RuntimeCompilationFileProvider _fileProvider; - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public FileProviderRazorProjectFileSystem(RuntimeCompilationFileProvider fileProvider, IHostingEnvironment hostingEnvironment) + public FileProviderRazorProjectFileSystem(RuntimeCompilationFileProvider fileProvider, IWebHostEnvironment hostingEnvironment) { if (fileProvider == null) { diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/CSharpCompilerTest.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/CSharpCompilerTest.cs index 3f87554209..9cfaffef56 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/CSharpCompilerTest.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/CSharpCompilerTest.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public void GetCompilationOptions_ReturnsDefaultOptionsIfApplicationNameIsNullOrEmpty(string name) { // Arrange - var hostingEnvironment = Mock.Of(e => e.ApplicationName == name); + var hostingEnvironment = Mock.Of(e => e.ApplicationName == name); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment); // Act @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public void GetCompilationOptions_ReturnsDefaultOptionsIfApplicationDoesNotHaveDependencyContext() { // Arrange - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment); // Act @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var options = new RazorViewEngineOptions(); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupGet(e => e.EnvironmentName) .Returns(environment); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object); @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var options = new RazorViewEngineOptions(); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupGet(e => e.EnvironmentName) .Returns(environment); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment.Object); @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public void EnsureOptions_ConfiguresDefaultCompilationOptions() { // Arrange - var hostingEnvironment = Mock.Of(h => h.EnvironmentName == "Development"); + var hostingEnvironment = Mock.Of(h => h.EnvironmentName == "Development"); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment); // Act & Assert @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public void EnsureOptions_ConfiguresDefaultParseOptions() { // Arrange - var hostingEnvironment = Mock.Of(h => h.EnvironmentName == "Development"); + var hostingEnvironment = Mock.Of(h => h.EnvironmentName == "Development"); var compiler = new CSharpCompiler(ReferenceManager, hostingEnvironment); // Act & Assert @@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public void Constructor_ConfiguresPreprocessorSymbolNames() { // Arrange - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var dependencyContextOptions = GetDependencyContextCompilationOptions("SOME_TEST_DEFINE"); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(languageVersion: "7.1"); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(debugType: "portable"); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(debugType: "embedded"); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(debugType: "none"); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(allowUnsafe: true); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(warningsAsErrors: true); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -233,7 +233,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions(optimize: true); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); @@ -247,7 +247,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation { // Arrange var dependencyContextOptions = GetDependencyContextCompilationOptions("MyDefine"); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); // Act & Assert @@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation var content = "public class Test {}"; var define = "MY_CUSTOM_DEFINE"; var dependencyContextOptions = GetDependencyContextCompilationOptions(define); - var hostingEnvironment = Mock.Of(); + var hostingEnvironment = Mock.Of(); var compiler = new TestCSharpCompiler(ReferenceManager, hostingEnvironment, dependencyContextOptions); // Act @@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation public TestCSharpCompiler( RazorReferenceManager referenceManager, - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, DependencyContextCompilationOptions options) : base(referenceManager, hostingEnvironment) { diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/FileProviderRazorProjectFileSystemTest.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/FileProviderRazorProjectFileSystemTest.cs index 94abf8068a..37f5895c52 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/FileProviderRazorProjectFileSystemTest.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/FileProviderRazorProjectFileSystemTest.cs @@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation var compilationFileProvider = new RuntimeCompilationFileProvider(options); var fileSystem = new FileProviderRazorProjectFileSystem( compilationFileProvider, - Mock.Of(e => e.ContentRootPath == contentRootPath)); + Mock.Of(e => e.ContentRootPath == contentRootPath)); return fileSystem; } } diff --git a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs index 5ac9e61bed..e9f22da610 100644 --- a/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs +++ b/src/Mvc/Mvc.Razor.RuntimeCompilation/test/RuntimeViewCompilerTest.cs @@ -783,7 +783,7 @@ this should fail"; { // Arrange var referenceManager = CreateReferenceManager(); - var csharpCompiler = new TestCSharpCompiler(referenceManager, Mock.Of()) + var csharpCompiler = new TestCSharpCompiler(referenceManager, Mock.Of()) { EmitOptionsSettable = new EmitOptions(debugInformationFormat: DebugInformationFormat.Embedded), }; @@ -803,7 +803,7 @@ this should fail"; { // Arrange var referenceManager = CreateReferenceManager(); - var csharpCompiler = new TestCSharpCompiler(referenceManager, Mock.Of()) + var csharpCompiler = new TestCSharpCompiler(referenceManager, Mock.Of()) { EmitPdbSettable = false, }; @@ -835,7 +835,7 @@ this should fail"; referenceManager = referenceManager ?? CreateReferenceManager(); precompiledViews = precompiledViews ?? Array.Empty(); - var hostingEnvironment = Mock.Of(e => e.ContentRootPath == "BasePath"); + var hostingEnvironment = Mock.Of(e => e.ContentRootPath == "BasePath"); var fileSystem = new FileProviderRazorProjectFileSystem(compilationFileProvider, hostingEnvironment); var projectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, builder => { @@ -891,7 +891,7 @@ this should fail"; private class TestCSharpCompiler : CSharpCompiler { - public TestCSharpCompiler(RazorReferenceManager manager, IHostingEnvironment hostingEnvironment) + public TestCSharpCompiler(RazorReferenceManager manager, IWebHostEnvironment hostingEnvironment) : base(manager, hostingEnvironment) { } diff --git a/src/Mvc/Mvc.Razor/src/Infrastructure/DefaultFileVersionProvider.cs b/src/Mvc/Mvc.Razor/src/Infrastructure/DefaultFileVersionProvider.cs index ae4bd7c1a6..a58bf6252d 100644 --- a/src/Mvc/Mvc.Razor/src/Infrastructure/DefaultFileVersionProvider.cs +++ b/src/Mvc/Mvc.Razor/src/Infrastructure/DefaultFileVersionProvider.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Infrastructure private static readonly char[] QueryStringAndFragmentTokens = new [] { '?', '#' }; public DefaultFileVersionProvider( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider) { if (hostingEnvironment == null) diff --git a/src/Mvc/Mvc.Razor/src/RazorViewEngineOptionsSetup.cs b/src/Mvc/Mvc.Razor/src/RazorViewEngineOptionsSetup.cs index d6ffc66da3..96849670e7 100644 --- a/src/Mvc/Mvc.Razor/src/RazorViewEngineOptionsSetup.cs +++ b/src/Mvc/Mvc.Razor/src/RazorViewEngineOptionsSetup.cs @@ -9,13 +9,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor { internal class RazorViewEngineOptionsSetup : IConfigureOptions { - private readonly IHostingEnvironment _hostingEnvironment; - - public RazorViewEngineOptionsSetup(IHostingEnvironment hostingEnvironment) - { - _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); - } - public void Configure(RazorViewEngineOptions options) { if (options == null) diff --git a/src/Mvc/Mvc.Razor/test/DependencyInjection/MvcRazorMvcCoreBuilderExtensionsTest.cs b/src/Mvc/Mvc.Razor/test/DependencyInjection/MvcRazorMvcCoreBuilderExtensionsTest.cs index ad46856f30..f7aa99fdcb 100644 --- a/src/Mvc/Mvc.Razor/test/DependencyInjection/MvcRazorMvcCoreBuilderExtensionsTest.cs +++ b/src/Mvc/Mvc.Razor/test/DependencyInjection/MvcRazorMvcCoreBuilderExtensionsTest.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection // Arrange var services = new ServiceCollection(); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment .Setup(h => h.ApplicationName) .Returns(applicationName); diff --git a/src/Mvc/Mvc.Razor/test/RazorViewEngineTest.cs b/src/Mvc/Mvc.Razor/test/RazorViewEngineTest.cs index 619b8ed283..dea493c874 100644 --- a/src/Mvc/Mvc.Razor/test/RazorViewEngineTest.cs +++ b/src/Mvc/Mvc.Razor/test/RazorViewEngineTest.cs @@ -1908,7 +1908,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor IEnumerable areaViewLocationFormats = null, IEnumerable pageViewLocationFormats = null) { - var optionsSetup = new RazorViewEngineOptionsSetup(Mock.Of()); + var optionsSetup = new RazorViewEngineOptionsSetup(); var options = new RazorViewEngineOptions(); optionsSetup.Configure(options); diff --git a/src/Mvc/Mvc.RazorPages/test/DependencyInjection/RazorPagesRazorViewEngineOptionsSetupTest.cs b/src/Mvc/Mvc.RazorPages/test/DependencyInjection/RazorPagesRazorViewEngineOptionsSetupTest.cs index d9add6f374..be687be1f9 100644 --- a/src/Mvc/Mvc.RazorPages/test/DependencyInjection/RazorPagesRazorViewEngineOptionsSetupTest.cs +++ b/src/Mvc/Mvc.RazorPages/test/DependencyInjection/RazorPagesRazorViewEngineOptionsSetupTest.cs @@ -185,7 +185,7 @@ namespace Microsoft.Extensions.DependencyInjection private static RazorViewEngineOptions GetViewEngineOptions() { - var defaultSetup = new RazorViewEngineOptionsSetup(Mock.Of()); + var defaultSetup = new RazorViewEngineOptionsSetup(); var options = new RazorViewEngineOptions(); defaultSetup.Configure(options); diff --git a/src/Mvc/Mvc.TagHelpers/src/EnvironmentTagHelper.cs b/src/Mvc/Mvc.TagHelpers/src/EnvironmentTagHelper.cs index b45a518eb7..1c96aec479 100644 --- a/src/Mvc/Mvc.TagHelpers/src/EnvironmentTagHelper.cs +++ b/src/Mvc/Mvc.TagHelpers/src/EnvironmentTagHelper.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers /// Creates a new . /// /// The . - public EnvironmentTagHelper(IHostingEnvironment hostingEnvironment) + public EnvironmentTagHelper(IWebHostEnvironment hostingEnvironment) { HostingEnvironment = hostingEnvironment; } @@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers /// public string Exclude { get; set; } - protected IHostingEnvironment HostingEnvironment { get; } + protected IWebHostEnvironment HostingEnvironment { get; } /// public override void Process(TagHelperContext context, TagHelperOutput output) diff --git a/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs b/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs index 2ba6cd719c..2b60c637e9 100644 --- a/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs +++ b/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // Decorated with ActivatorUtilitiesConstructor since we want to influence tag helper activation // to use this constructor in the default case. public ImageTagHelper( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers [HtmlAttributeName(AppendVersionAttributeName)] public bool AppendVersion { get; set; } - protected internal IHostingEnvironment HostingEnvironment { get; } + protected internal IWebHostEnvironment HostingEnvironment { get; } protected internal IMemoryCache Cache { get; } diff --git a/src/Mvc/Mvc.TagHelpers/src/LinkTagHelper.cs b/src/Mvc/Mvc.TagHelpers/src/LinkTagHelper.cs index 0e56388796..4bd68aea49 100644 --- a/src/Mvc/Mvc.TagHelpers/src/LinkTagHelper.cs +++ b/src/Mvc/Mvc.TagHelpers/src/LinkTagHelper.cs @@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // Decorated with ActivatorUtilitiesConstructor since we want to influence tag helper activation // to use this constructor in the default case. public LinkTagHelper( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, @@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers [HtmlAttributeName(FallbackTestValueAttributeName)] public string FallbackTestValue { get; set; } - protected internal IHostingEnvironment HostingEnvironment { get; } + protected internal IWebHostEnvironment HostingEnvironment { get; } protected internal IMemoryCache Cache { get; } diff --git a/src/Mvc/Mvc.TagHelpers/src/ScriptTagHelper.cs b/src/Mvc/Mvc.TagHelpers/src/ScriptTagHelper.cs index e3f425ee6c..629d2a9f37 100644 --- a/src/Mvc/Mvc.TagHelpers/src/ScriptTagHelper.cs +++ b/src/Mvc/Mvc.TagHelpers/src/ScriptTagHelper.cs @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // Decorated with ActivatorUtilitiesConstructor since we want to influence tag helper activation // to use this constructor in the default case. public ScriptTagHelper( - IHostingEnvironment hostingEnvironment, + IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, @@ -176,7 +176,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers [HtmlAttributeName(FallbackTestExpressionAttributeName)] public string FallbackTestExpression { get; set; } - protected internal IHostingEnvironment HostingEnvironment { get; } + protected internal IWebHostEnvironment HostingEnvironment { get; } protected internal IMemoryCache Cache { get; private set; } diff --git a/src/Mvc/Mvc.TagHelpers/test/DefaultFileVersionProviderTest.cs b/src/Mvc/Mvc.TagHelpers/test/DefaultFileVersionProviderTest.cs index 9446703636..c13805fd3d 100644 --- a/src/Mvc/Mvc.TagHelpers/test/DefaultFileVersionProviderTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/DefaultFileVersionProviderTest.cs @@ -290,7 +290,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers IFileProvider fileProvider, IMemoryCache memoryCache = null) { - var hostingEnv = Mock.Of(e => e.WebRootFileProvider == fileProvider); + var hostingEnv = Mock.Of(e => e.WebRootFileProvider == fileProvider); var cacheProvider = new TagHelperMemoryCacheProvider(); if (memoryCache != null) { diff --git a/src/Mvc/Mvc.TagHelpers/test/DefaultTagHelperActivatorTest.cs b/src/Mvc/Mvc.TagHelpers/test/DefaultTagHelperActivatorTest.cs index a047bca10e..8688ac1e1f 100644 --- a/src/Mvc/Mvc.TagHelpers/test/DefaultTagHelperActivatorTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/DefaultTagHelperActivatorTest.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal { private readonly TagHelperMemoryCacheProvider CacheProvider = new TagHelperMemoryCacheProvider(); private readonly IMemoryCache MemoryCache = new MemoryCache(new MemoryCacheOptions()); - private readonly IHostingEnvironment HostingEnvironment = Mock.Of(); + private readonly IWebHostEnvironment HostingEnvironment = Mock.Of(); private readonly IFileVersionProvider FileVersionProvider = Mock.Of(); [Fact] diff --git a/src/Mvc/Mvc.TagHelpers/test/EnvironmentTagHelperTest.cs b/src/Mvc/Mvc.TagHelpers/test/EnvironmentTagHelperTest.cs index be53a4f6b9..cdf4eb31bd 100644 --- a/src/Mvc/Mvc.TagHelpers/test/EnvironmentTagHelperTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/EnvironmentTagHelperTest.cs @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Test { "exclude", excludeAttribute }, }); var output = MakeTagHelperOutput("environment", childContent: content); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupProperty(h => h.EnvironmentName, "Development"); // Act @@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Test { "exclude", excludeAttribute }, }); var output = MakeTagHelperOutput("environment", childContent: content); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupProperty(h => h.EnvironmentName, "Development"); // Act @@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Test var content = "content"; var context = MakeTagHelperContext(attributes: new TagHelperAttributeList { { "names", namesAttribute } }); var output = MakeTagHelperOutput("environment", childContent: content); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupProperty(h => h.EnvironmentName, environmentName); // Act @@ -194,7 +194,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Test var context = MakeTagHelperContext( attributes: new TagHelperAttributeList { { "names", namesAttribute } }); var output = MakeTagHelperOutput("environment", childContent: content); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupProperty(h => h.EnvironmentName, environmentName); // Act diff --git a/src/Mvc/Mvc.TagHelpers/test/ImageTagHelperTest.cs b/src/Mvc/Mvc.TagHelpers/test/ImageTagHelperTest.cs index 1c8a307c4a..35b012cc95 100644 --- a/src/Mvc/Mvc.TagHelpers/test/ImageTagHelperTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/ImageTagHelperTest.cs @@ -252,7 +252,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } private static ImageTagHelper GetHelper( - IHostingEnvironment hostingEnvironment = null, + IWebHostEnvironment hostingEnvironment = null, IUrlHelperFactory urlHelperFactory = null, ViewContext viewContext = null) { @@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers }); } - private static IHostingEnvironment MakeHostingEnvironment() + private static IWebHostEnvironment MakeHostingEnvironment() { var emptyDirectoryContents = new Mock(); emptyDirectoryContents.Setup(dc => dc.GetEnumerator()) @@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers .Returns(mockFile.Object); mockFileProvider.Setup(fp => fp.Watch(It.IsAny())) .Returns(new TestFileChangeToken()); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object); return hostingEnvironment.Object; diff --git a/src/Mvc/Mvc.TagHelpers/test/LinkTagHelperTest.cs b/src/Mvc/Mvc.TagHelpers/test/LinkTagHelperTest.cs index a34affa443..a1ff4d41ab 100644 --- a/src/Mvc/Mvc.TagHelpers/test/LinkTagHelperTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/LinkTagHelperTest.cs @@ -929,7 +929,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } private static LinkTagHelper GetHelper( - IHostingEnvironment hostingEnvironment = null, + IWebHostEnvironment hostingEnvironment = null, IUrlHelperFactory urlHelperFactory = null, ViewContext viewContext = null) { @@ -998,7 +998,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers }; } - private static IHostingEnvironment MakeHostingEnvironment() + private static IWebHostEnvironment MakeHostingEnvironment() { var emptyDirectoryContents = new Mock(); emptyDirectoryContents.Setup(dc => dc.GetEnumerator()) @@ -1015,7 +1015,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers .Returns(mockFile.Object); mockFileProvider.Setup(fp => fp.Watch(It.IsAny())) .Returns(new TestFileChangeToken()); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object); return hostingEnvironment.Object; diff --git a/src/Mvc/Mvc.TagHelpers/test/ScriptTagHelperTest.cs b/src/Mvc/Mvc.TagHelpers/test/ScriptTagHelperTest.cs index bad0762fcd..ef93cd8ac2 100644 --- a/src/Mvc/Mvc.TagHelpers/test/ScriptTagHelperTest.cs +++ b/src/Mvc/Mvc.TagHelpers/test/ScriptTagHelperTest.cs @@ -791,7 +791,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } private static ScriptTagHelper GetHelper( - IHostingEnvironment hostingEnvironment = null, + IWebHostEnvironment hostingEnvironment = null, IUrlHelperFactory urlHelperFactory = null, ViewContext viewContext = null) { @@ -859,7 +859,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers new DefaultTagHelperContent())); } - private static IHostingEnvironment MakeHostingEnvironment() + private static IWebHostEnvironment MakeHostingEnvironment() { var emptyDirectoryContents = new Mock(); emptyDirectoryContents.Setup(dc => dc.GetEnumerator()) @@ -876,7 +876,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers .Returns(mockFile.Object); mockFileProvider.Setup(fp => fp.Watch(It.IsAny())) .Returns(new TestFileChangeToken()); - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object); return hostingEnvironment.Object; diff --git a/src/Mvc/Mvc/test/MvcOptionsSetupTest.cs b/src/Mvc/Mvc/test/MvcOptionsSetupTest.cs index c4a1876e44..8e7b93cb3e 100644 --- a/src/Mvc/Mvc/test/MvcOptionsSetupTest.cs +++ b/src/Mvc/Mvc/test/MvcOptionsSetupTest.cs @@ -268,7 +268,7 @@ namespace Microsoft.AspNetCore.Mvc private static void AddViewEngineOptionsServices(IServiceCollection serviceCollection) { - var hostingEnvironment = new Mock(); + var hostingEnvironment = new Mock(); hostingEnvironment.SetupGet(e => e.ApplicationName) .Returns(typeof(MvcOptionsSetupTest).GetTypeInfo().Assembly.GetName().Name); diff --git a/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs b/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs index 0c9ed9c640..aad217683c 100644 --- a/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs +++ b/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - services.AddSingleton(GetHostingEnvironment()); + services.AddSingleton(GetHostingEnvironment()); // Register a mock implementation of each service, AddMvcServices should add another implementation. foreach (var serviceType in MultiRegistrationServiceTypes) @@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - services.AddSingleton(GetHostingEnvironment()); + services.AddSingleton(GetHostingEnvironment()); // Register a mock implementation of each service, AddMvcServices should not replace it. foreach (var serviceType in SingleRegistrationServiceTypes) @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Mvc { // Arrange var services = new ServiceCollection(); - services.AddSingleton(GetHostingEnvironment()); + services.AddSingleton(GetHostingEnvironment()); // Act services.AddMvc(); @@ -234,7 +234,7 @@ namespace Microsoft.AspNetCore.Mvc // Arrange var services = new ServiceCollection(); - services.AddSingleton(GetHostingEnvironment()); + services.AddSingleton(GetHostingEnvironment()); var diagnosticListener = new DiagnosticListener("Microsoft.AspNet"); services.AddSingleton(diagnosticListener); @@ -293,7 +293,7 @@ namespace Microsoft.AspNetCore.Mvc get { var services = new ServiceCollection(); - services.AddSingleton(GetHostingEnvironment()); + services.AddSingleton(GetHostingEnvironment()); services.AddMvc(); var multiRegistrationServiceTypes = MultiRegistrationServiceTypes; @@ -477,9 +477,9 @@ namespace Microsoft.AspNetCore.Mvc } } - private IHostingEnvironment GetHostingEnvironment() + private IWebHostEnvironment GetHostingEnvironment() { - var environment = new Mock(); + var environment = new Mock(); environment .Setup(e => e.ApplicationName) .Returns(typeof(MvcServiceCollectionExtensionsTest).GetTypeInfo().Assembly.GetName().Name); diff --git a/src/Mvc/benchmarks/Microsoft.AspNetCore.Mvc.Performance/RuntimePerformanceBenchmarkBase.cs b/src/Mvc/benchmarks/Microsoft.AspNetCore.Mvc.Performance/RuntimePerformanceBenchmarkBase.cs index a763cba861..7d1d2a5169 100644 --- a/src/Mvc/benchmarks/Microsoft.AspNetCore.Mvc.Performance/RuntimePerformanceBenchmarkBase.cs +++ b/src/Mvc/benchmarks/Microsoft.AspNetCore.Mvc.Performance/RuntimePerformanceBenchmarkBase.cs @@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Mvc.Performance } - private class BenchmarkHostingEnvironment : IHostingEnvironment + private class BenchmarkHostingEnvironment : IWebHostEnvironment { public BenchmarkHostingEnvironment() { @@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Mvc.Performance .AddSingleton() .AddSingleton(listener) .AddSingleton(listener) - .AddSingleton() + .AddSingleton() .AddSingleton(partManager) .AddScoped() .AddMvc(); diff --git a/src/Mvc/test/WebSites/FilesWebSite/Controllers/DownloadFilesController.cs b/src/Mvc/test/WebSites/FilesWebSite/Controllers/DownloadFilesController.cs index 7b23292272..27b8dbfe5b 100644 --- a/src/Mvc/test/WebSites/FilesWebSite/Controllers/DownloadFilesController.cs +++ b/src/Mvc/test/WebSites/FilesWebSite/Controllers/DownloadFilesController.cs @@ -12,9 +12,9 @@ namespace FilesWebSite { public class DownloadFilesController : Controller { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public DownloadFilesController(IHostingEnvironment hostingEnvironment) + public DownloadFilesController(IWebHostEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; } diff --git a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs index e6652b4818..9d9bf26a2f 100644 --- a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs +++ b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs @@ -12,9 +12,9 @@ namespace RazorPagesWebSite { public class StartupWithBasePath { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly IWebHostEnvironment _hostingEnvironment; - public StartupWithBasePath(IHostingEnvironment hostingEnvironment) + public StartupWithBasePath(IWebHostEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Startup.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Startup.cs index d9966c3204..b17317b9f6 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Company.WebApplication1 { @@ -18,7 +19,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs index 297d3debb8..b0fc8d5c8a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs @@ -5,6 +5,7 @@ open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Http open Microsoft.Extensions.DependencyInjection +open Microsoft.Extensions.Hosting type Startup() = @@ -14,10 +15,10 @@ type Startup() = () // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = + member this.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) = if env.IsDevelopment() then app.UseDeveloperExceptionPage() |> ignore app.UseRouting(fun routing -> routing.MapGet("/", fun context -> context.Response.WriteAsync("Hello World!")) |> ignore - ) |> ignore \ No newline at end of file + ) |> ignore diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.Server/Startup.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.Server/Startup.cs index 2698185f3a..02ab997058 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.Server/Startup.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.Server/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace RazorComponentsWeb_CSharp.Server { @@ -19,7 +20,7 @@ namespace RazorComponentsWeb_CSharp.Server } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs index bcb0e16987..2a23c083f4 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs @@ -35,6 +35,7 @@ using Company.WebApplication1.Data; #endif using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; #if(MultiOrgAuth) using Microsoft.IdentityModel.Tokens; #endif @@ -134,7 +135,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs index 8c14404309..e16cfd104c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs @@ -35,6 +35,7 @@ using Company.WebApplication1.Data; #endif using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; #if(MultiOrgAuth) using Microsoft.IdentityModel.Tokens; #endif @@ -133,7 +134,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs index b18e598bf2..2dc5aa970e 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs @@ -12,6 +12,7 @@ open Microsoft.AspNetCore.HttpsPolicy; open Microsoft.AspNetCore.Mvc open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection +open Microsoft.Extensions.Hosting type Startup private () = new (configuration: IConfiguration) as this = @@ -24,7 +25,7 @@ type Startup private () = services.AddMvc().AddNewtonsoftJson().AddRazorRuntimeCompilation() |> ignore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = + member this.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) = if (env.IsDevelopment()) then app.UseDeveloperExceptionPage() |> ignore diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs index 92dbf02d54..028797d6c1 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs @@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; #endif using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -48,7 +49,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs index 03dc129e28..a6f84b5513 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs @@ -12,6 +12,7 @@ open Microsoft.AspNetCore.HttpsPolicy; open Microsoft.AspNetCore.Mvc open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection +open Microsoft.Extensions.Hosting type Startup private () = new (configuration: IConfiguration) as this = @@ -24,7 +25,7 @@ type Startup private () = services.AddMvc().AddNewtonsoftJson() |> ignore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = + member this.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) = if (env.IsDevelopment()) then app.UseDeveloperExceptionPage() |> ignore #if (!NoHttps) diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs index 14cfb842b4..9a0eab6147 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SpaServices.AngularCli; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Company.WebApplication1 { @@ -33,7 +34,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs index 9b8508ddab..1ec2eb2027 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Company.WebApplication1 { @@ -33,7 +34,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs index 9b8508ddab..1ec2eb2027 100644 --- a/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs +++ b/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Company.WebApplication1 { @@ -33,7 +34,7 @@ namespace Company.WebApplication1 } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/JwtBearerSample.csproj b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/JwtBearerSample.csproj index a48a6b4ce1..7befb4a05a 100644 --- a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 @@ -6,13 +6,9 @@ + - - - - - diff --git a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Program.cs b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Program.cs index 44d2fe0c4f..348d6c560c 100644 --- a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Program.cs +++ b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Program.cs @@ -1,6 +1,6 @@ -using System.IO; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; namespace JwtBearerSample { @@ -8,10 +8,7 @@ namespace JwtBearerSample { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); diff --git a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Startup.cs b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Startup.cs index f0faeefc68..21d696d968 100644 --- a/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Startup.cs +++ b/src/Security/Authentication/JwtBearer/samples/JwtBearerSample/Startup.cs @@ -19,27 +19,13 @@ namespace JwtBearerSample { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration config) { - Environment = env; - - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath); - - if (env.IsDevelopment()) - { - // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); - } - - builder.AddEnvironmentVariables(); - Configuration = builder.Build(); + Configuration = config; } public IConfiguration Configuration { get; set; } - public IHostingEnvironment Environment { get; set; } - // Shared between users in memory public IList Todos { get; } = new List(); diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 5421dc1116..8116c27802 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 @@ -6,14 +6,9 @@ + - - - - - - diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Program.cs b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Program.cs index 0e1285a9c6..077f415dfb 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -1,6 +1,5 @@ -using System.IO; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Logging; namespace OpenIdConnect.AzureAdSample { @@ -8,16 +7,7 @@ namespace OpenIdConnect.AzureAdSample { public static void Main(string[] args) { - var host = new WebHostBuilder() - .ConfigureLogging(factory => - { - factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Information); - }) - .UseKestrel() - .UseUrls("http://localhost:42023") - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Startup.cs b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Startup.cs index 22a6a6071f..609c78849e 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -19,19 +19,9 @@ namespace OpenIdConnect.AzureAdSample { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration config) { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath); - - if (env.IsDevelopment()) - { - // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); - } - - builder.AddEnvironmentVariables(); - Configuration = builder.Build(); + Configuration = config; } public IConfiguration Configuration { get; set; } diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 859a79dd1f..a8b49363a1 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 @@ -10,16 +10,10 @@ + - - - - - - - diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Program.cs b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Program.cs index 87e7755084..aace6e77ea 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Program.cs +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Program.cs @@ -1,11 +1,6 @@ -using System; -using System.IO; -using System.Net; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; + +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Logging; namespace OpenIdConnectSample { @@ -13,47 +8,11 @@ namespace OpenIdConnectSample { public static void Main(string[] args) { - var host = new WebHostBuilder() - .ConfigureLogging(factory => - { - factory.AddConsole(); - factory.AddDebug(); - factory.AddFilter("Console", level => level >= LogLevel.Information); - factory.AddFilter("Debug", level => level >= LogLevel.Information); - }) - .UseKestrel(options => - { - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - }) - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); host.Run(); } - - private static X509Certificate2 LoadCertificate() - { - var assembly = typeof(Startup).GetTypeInfo().Assembly; - var embeddedFileProvider = new EmbeddedFileProvider(assembly, "OpenIdConnectSample"); - var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); - using (var certificateStream = certificateFileInfo.CreateReadStream()) - { - byte[] certificatePayload; - using (var memoryStream = new MemoryStream()) - { - certificateStream.CopyTo(memoryStream); - certificatePayload = memoryStream.ToArray(); - } - - return new X509Certificate2(certificatePayload, "testPassword"); - } - } } } diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs index 04e819f2f9..95fcc21ec2 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -22,26 +23,14 @@ namespace OpenIdConnectSample { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration config, IWebHostEnvironment env) { + Configuration = config; Environment = env; - - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath); - - if (env.IsDevelopment()) - { - // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); - } - - builder.AddEnvironmentVariables(); - Configuration = builder.Build(); } public IConfiguration Configuration { get; set; } - - public IHostingEnvironment Environment { get; set; } + public IWebHostEnvironment Environment { get; } public void ConfigureServices(IServiceCollection services) { diff --git a/src/Security/Authentication/samples/SocialSample/Program.cs b/src/Security/Authentication/samples/SocialSample/Program.cs index a712b6c03f..15787ce856 100644 --- a/src/Security/Authentication/samples/SocialSample/Program.cs +++ b/src/Security/Authentication/samples/SocialSample/Program.cs @@ -1,11 +1,5 @@ -using System; -using System.IO; -using System.Net; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Logging; namespace SocialSample { @@ -13,45 +7,11 @@ namespace SocialSample { public static void Main(string[] args) { - var host = new WebHostBuilder() - .ConfigureLogging(factory => - { - factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Information); - }) - .UseKestrel(options => - { - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - }) - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); host.Run(); } - - private static X509Certificate2 LoadCertificate() - { - var socialSampleAssembly = typeof(Startup).GetTypeInfo().Assembly; - var embeddedFileProvider = new EmbeddedFileProvider(socialSampleAssembly, "SocialSample"); - var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); - using (var certificateStream = certificateFileInfo.CreateReadStream()) - { - byte[] certificatePayload; - using (var memoryStream = new MemoryStream()) - { - certificateStream.CopyTo(memoryStream); - certificatePayload = memoryStream.ToArray(); - } - - return new X509Certificate2(certificatePayload, "testPassword"); - } - } } } diff --git a/src/Security/Authentication/samples/SocialSample/SocialSample.csproj b/src/Security/Authentication/samples/SocialSample/SocialSample.csproj index 41a6d4c9d5..a2d697363d 100644 --- a/src/Security/Authentication/samples/SocialSample/SocialSample.csproj +++ b/src/Security/Authentication/samples/SocialSample/SocialSample.csproj @@ -14,19 +14,13 @@ + - - - - - - - diff --git a/src/Security/Authentication/samples/SocialSample/Startup.cs b/src/Security/Authentication/samples/SocialSample/Startup.cs index 3921ab5f36..77b592a8f0 100644 --- a/src/Security/Authentication/samples/SocialSample/Startup.cs +++ b/src/Security/Authentication/samples/SocialSample/Startup.cs @@ -28,20 +28,9 @@ namespace SocialSample /* Note all servers must use the same address and port because these are pre-registered with the various providers. */ public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration config) { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true); - - if (env.IsDevelopment()) - { - // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 - builder.AddUserSecrets(); - } - - builder.AddEnvironmentVariables(); - Configuration = builder.Build(); + Configuration = config; } public IConfiguration Configuration { get; set; } diff --git a/src/Security/samples/ClaimsTransformation/Startup.cs b/src/Security/samples/ClaimsTransformation/Startup.cs index 79fcefeb80..99145e2baf 100644 --- a/src/Security/samples/ClaimsTransformation/Startup.cs +++ b/src/Security/samples/ClaimsTransformation/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; namespace AuthSamples.ClaimsTransformer @@ -34,7 +35,7 @@ namespace AuthSamples.ClaimsTransformer } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/samples/Cookies/Startup.cs b/src/Security/samples/Cookies/Startup.cs index 6389e92bcc..536ddfb716 100644 --- a/src/Security/samples/Cookies/Startup.cs +++ b/src/Security/samples/Cookies/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; namespace AuthSamples.Cookies @@ -41,7 +42,7 @@ namespace AuthSamples.Cookies } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/samples/CustomPolicyProvider/Startup.cs b/src/Security/samples/CustomPolicyProvider/Startup.cs index 0aeade97aa..9aaebd2770 100644 --- a/src/Security/samples/CustomPolicyProvider/Startup.cs +++ b/src/Security/samples/CustomPolicyProvider/Startup.cs @@ -1,8 +1,9 @@ -using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace CustomPolicyProvider { @@ -30,7 +31,7 @@ namespace CustomPolicyProvider }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseAuthentication(); diff --git a/src/Security/samples/DynamicSchemes/Startup.cs b/src/Security/samples/DynamicSchemes/Startup.cs index 85567bd9f2..f0cb216969 100644 --- a/src/Security/samples/DynamicSchemes/Startup.cs +++ b/src/Security/samples/DynamicSchemes/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace AuthSamples.DynamicSchemes { @@ -28,7 +29,7 @@ namespace AuthSamples.DynamicSchemes } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/samples/Identity.ExternalClaims/Startup.cs b/src/Security/samples/Identity.ExternalClaims/Startup.cs index 01b966b7ae..3608e0f35e 100644 --- a/src/Security/samples/Identity.ExternalClaims/Startup.cs +++ b/src/Security/samples/Identity.ExternalClaims/Startup.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Identity.ExternalClaims.Data; using Identity.ExternalClaims.Services; using System.Security.Claims; @@ -66,7 +67,7 @@ namespace Identity.ExternalClaims } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/samples/PathSchemeSelection/Startup.cs b/src/Security/samples/PathSchemeSelection/Startup.cs index 42e137ebcf..0687586327 100644 --- a/src/Security/samples/PathSchemeSelection/Startup.cs +++ b/src/Security/samples/PathSchemeSelection/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -60,7 +61,7 @@ namespace AuthSamples.PathSchemeSelection // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Security/samples/StaticFilesAuth/Startup.cs b/src/Security/samples/StaticFilesAuth/Startup.cs index 188f818438..027629f64f 100644 --- a/src/Security/samples/StaticFilesAuth/Startup.cs +++ b/src/Security/samples/StaticFilesAuth/Startup.cs @@ -12,12 +12,13 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; namespace StaticFilesAuth { public class Startup { - public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironment) + public Startup(IConfiguration configuration, IWebHostEnvironment hostingEnvironment) { Configuration = configuration; HostingEnvironment = hostingEnvironment; @@ -25,7 +26,7 @@ namespace StaticFilesAuth public IConfiguration Configuration { get; } - public IHostingEnvironment HostingEnvironment { get; } + public IWebHostEnvironment HostingEnvironment { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) @@ -75,7 +76,7 @@ namespace StaticFilesAuth } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAuthorizationService authorizationService) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAuthorizationService authorizationService) { if (env.IsDevelopment()) { diff --git a/src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs b/src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs index f6a6faf647..216dcea3b8 100644 --- a/src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs +++ b/src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs @@ -25,7 +25,7 @@ namespace NativeIISSample } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.Run(async (context) => { diff --git a/src/Servers/IIS/IIS/src/Core/IISHttpServer.cs b/src/Servers/IIS/IIS/src/Core/IISHttpServer.cs index d0815ebd08..8d47492891 100644 --- a/src/Servers/IIS/IIS/src/Core/IISHttpServer.cs +++ b/src/Servers/IIS/IIS/src/Core/IISHttpServer.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -30,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.IIS.Core private IISContextFactory _iisContextFactory; private readonly MemoryPool _memoryPool = new SlabMemoryPool(); private GCHandle _httpServerHandle; - private readonly IApplicationLifetime _applicationLifetime; + private readonly IHostApplicationLifetime _applicationLifetime; private readonly ILogger _logger; private readonly IISServerOptions _options; private readonly IISNativeApplication _nativeApplication; @@ -62,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.IIS.Core public IISHttpServer( IISNativeApplication nativeApplication, - IApplicationLifetime applicationLifetime, + IHostApplicationLifetime applicationLifetime, IAuthenticationSchemeProvider authentication, IOptions options, ILogger logger diff --git a/src/Servers/IIS/IIS/test/IIS.Tests/Utilities/TestServer.cs b/src/Servers/IIS/IIS/test/IIS.Tests/Utilities/TestServer.cs index 0b94ea4dc3..cd283c200b 100644 --- a/src/Servers/IIS/IIS/test/IIS.Tests/Utilities/TestServer.cs +++ b/src/Servers/IIS/IIS/test/IIS.Tests/Utilities/TestServer.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting.Common; using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests @@ -134,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests .Build(); var doneEvent = new ManualResetEventSlim(); - var lifetime = _host.Services.GetService(); + var lifetime = _host.Services.GetService(); lifetime.ApplicationStopping.Register(() => doneEvent.Set()); _host.Start(); diff --git a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.WebSockets.cs b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.WebSockets.cs index c0ac158d1a..807301c7b2 100644 --- a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.WebSockets.cs +++ b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.WebSockets.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Xunit; namespace TestSite @@ -47,7 +48,7 @@ namespace TestSite { var ws = await Upgrade(context); - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); await Echo(ws, appLifetime.ApplicationStopping); }); diff --git a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs index 619ac58855..f3b8d1e100 100644 --- a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs +++ b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.IISIntegration.FunctionalTests; using Microsoft.AspNetCore.Server.IIS; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Primitives; using Xunit; @@ -655,7 +656,7 @@ namespace TestSite private async Task Shutdown(HttpContext ctx) { await ctx.Response.WriteAsync("Shutting down"); - ctx.RequestServices.GetService().StopApplication(); + ctx.RequestServices.GetService().StopApplication(); } private async Task ShutdownStopAsync(HttpContext ctx) diff --git a/src/Servers/IIS/IIS/test/testassets/StressTestWebSite/Startup.cs b/src/Servers/IIS/IIS/test/testassets/StressTestWebSite/Startup.cs index 6d1adb24f6..3045906c5f 100644 --- a/src/Servers/IIS/IIS/test/testassets/StressTestWebSite/Startup.cs +++ b/src/Servers/IIS/IIS/test/testassets/StressTestWebSite/Startup.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.Net.Http.Headers; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Primitives; +using Microsoft.Extensions.Hosting; namespace ANCMStressTestApp { @@ -172,7 +173,7 @@ namespace ANCMStressTestApp // Get the WebSocket object var ws = WebSocket.CreateFromStream(opaqueTransport, isServer: true, subProtocol: null, keepAliveInterval: TimeSpan.FromMinutes(2)); - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); await Echo(ws, appLifetime.ApplicationStopping); }); diff --git a/src/Servers/IIS/IIS/test/testassets/shared/SharedStartup/Startup.shared.cs b/src/Servers/IIS/IIS/test/testassets/shared/SharedStartup/Startup.shared.cs index 513eb89cef..ba16ed976a 100644 --- a/src/Servers/IIS/IIS/test/testassets/shared/SharedStartup/Startup.shared.cs +++ b/src/Servers/IIS/IIS/test/testassets/shared/SharedStartup/Startup.shared.cs @@ -25,9 +25,9 @@ namespace TestSite serviceCollection.AddResponseCompression(); } - private async Task ContentRootPath(HttpContext ctx) => await ctx.Response.WriteAsync(ctx.RequestServices.GetService().ContentRootPath); + private async Task ContentRootPath(HttpContext ctx) => await ctx.Response.WriteAsync(ctx.RequestServices.GetService().ContentRootPath); - private async Task WebRootPath(HttpContext ctx) => await ctx.Response.WriteAsync(ctx.RequestServices.GetService().WebRootPath); + private async Task WebRootPath(HttpContext ctx) => await ctx.Response.WriteAsync(ctx.RequestServices.GetService().WebRootPath); private async Task CurrentDirectory(HttpContext ctx) => await ctx.Response.WriteAsync(Environment.CurrentDirectory); @@ -102,7 +102,7 @@ namespace TestSite public Task CreateFile(HttpContext context) { - var hostingEnv = context.RequestServices.GetService(); + var hostingEnv = context.RequestServices.GetService(); File.WriteAllText(System.IO.Path.Combine(hostingEnv.ContentRootPath, "Started.txt"), ""); return Task.CompletedTask; } diff --git a/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs b/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs index 013b15adfc..77a4211b74 100644 --- a/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs +++ b/src/Servers/IIS/IISIntegration/src/IISMiddleware.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; @@ -27,7 +28,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration private readonly IISOptions _options; private readonly ILogger _logger; private readonly string _pairingToken; - private readonly IApplicationLifetime _applicationLifetime; + private readonly IHostApplicationLifetime _applicationLifetime; private readonly bool _isWebsocketsSupported; // Can't break public API, so creating a second constructor to propagate the isWebsocketsSupported flag. @@ -36,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration IOptions options, string pairingToken, IAuthenticationSchemeProvider authentication, - IApplicationLifetime applicationLifetime) + IHostApplicationLifetime applicationLifetime) : this(next, loggerFactory, options, pairingToken, isWebsocketsSupported: true, authentication, applicationLifetime) { } @@ -47,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration string pairingToken, bool isWebsocketsSupported, IAuthenticationSchemeProvider authentication, - IApplicationLifetime applicationLifetime) + IHostApplicationLifetime applicationLifetime) { if (next == null) { diff --git a/src/Servers/IIS/IISIntegration/test/Tests/IISMiddlewareTests.cs b/src/Servers/IIS/IISIntegration/test/Tests/IISMiddlewareTests.cs index a0ee6a124c..890ce500e9 100644 --- a/src/Servers/IIS/IISIntegration/test/Tests/IISMiddlewareTests.cs +++ b/src/Servers/IIS/IISIntegration/test/Tests/IISMiddlewareTests.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Xunit; namespace Microsoft.AspNetCore.Server.IISIntegration @@ -91,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration .UseIISIntegration() .Configure(app => { - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); appLifetime.ApplicationStopping.Register(() => applicationStoppingFired.SetResult(0)); app.Run(context => @@ -141,7 +142,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration .UseIISIntegration() .Configure(app => { - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); appLifetime.ApplicationStopping.Register(() => applicationStoppingFired.SetResult(0)); app.Run(context => @@ -177,7 +178,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration .UseIISIntegration() .Configure(app => { - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); appLifetime.ApplicationStopping.Register(() => applicationStoppingFired.SetResult(0)); app.Run(context => @@ -213,7 +214,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration .UseIISIntegration() .Configure(app => { - var appLifetime = app.ApplicationServices.GetRequiredService(); + var appLifetime = app.ApplicationServices.GetRequiredService(); appLifetime.ApplicationStopping.Register(() => applicationStoppingFired.SetResult(0)); app.Run(context => diff --git a/src/Servers/Kestrel/Core/src/KestrelConfigurationLoader.cs b/src/Servers/Kestrel/Core/src/KestrelConfigurationLoader.cs index e568aec6c7..49949911b9 100644 --- a/src/Servers/Kestrel/Core/src/KestrelConfigurationLoader.cs +++ b/src/Servers/Kestrel/Core/src/KestrelConfigurationLoader.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Https.Internal; using Microsoft.AspNetCore.Server.Kestrel.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Server.Kestrel @@ -344,7 +345,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel private bool TryGetCertificatePath(out string path) { - var hostingEnvironment = Options.ApplicationServices.GetRequiredService(); + var hostingEnvironment = Options.ApplicationServices.GetRequiredService(); var appName = hostingEnvironment.ApplicationName; // This will go away when we implement @@ -365,7 +366,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel } else if (certInfo.IsFileCert) { - var env = Options.ApplicationServices.GetRequiredService(); + var env = Options.ApplicationServices.GetRequiredService(); return new X509Certificate2(Path.Combine(env.ContentRootPath, certInfo.Path), certInfo.Password); } else if (certInfo.IsStoreCert) diff --git a/src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs b/src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs index 80c6eda3d2..e1950bd527 100644 --- a/src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs +++ b/src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.AspNetCore.Server.Kestrel.Https.Internal; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Hosting @@ -34,7 +35,7 @@ namespace Microsoft.AspNetCore.Hosting /// The . public static ListenOptions UseHttps(this ListenOptions listenOptions, string fileName) { - var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); + var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); return listenOptions.UseHttps(new X509Certificate2(Path.Combine(env.ContentRootPath, fileName))); } @@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Hosting /// The . public static ListenOptions UseHttps(this ListenOptions listenOptions, string fileName, string password) { - var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); + var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); return listenOptions.UseHttps(new X509Certificate2(Path.Combine(env.ContentRootPath, fileName), password)); } @@ -63,7 +64,7 @@ namespace Microsoft.AspNetCore.Hosting public static ListenOptions UseHttps(this ListenOptions listenOptions, string fileName, string password, Action configureOptions) { - var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); + var env = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); return listenOptions.UseHttps(new X509Certificate2(Path.Combine(env.ContentRootPath, fileName), password), configureOptions); } diff --git a/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationBuilderTests.cs b/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationBuilderTests.cs index 2299d38f63..c2bb493845 100644 --- a/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationBuilderTests.cs +++ b/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationBuilderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Xunit; namespace Microsoft.AspNetCore.Server.Kestrel.Tests @@ -22,9 +23,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests private KestrelServerOptions CreateServerOptions() { var serverOptions = new KestrelServerOptions(); + var env = new HostingEnvironment { ApplicationName = "TestApplication" }; serverOptions.ApplicationServices = new ServiceCollection() .AddLogging() - .AddSingleton(new HostingEnvironment { ApplicationName = "TestApplication" }) + .AddSingleton(env) + .AddSingleton(env) .BuildServiceProvider(); return serverOptions; } diff --git a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvThread.cs b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvThread.cs index a4854e2035..2cb5f4de95 100644 --- a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvThread.cs +++ b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvThread.cs @@ -9,8 +9,8 @@ using System.IO.Pipelines; using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal private readonly int _maxLoops = 8; private readonly LibuvTransport _transport; - private readonly IApplicationLifetime _appLifetime; + private readonly IHostApplicationLifetime _appLifetime; private readonly Thread _thread; private readonly TaskCompletionSource _threadTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); private readonly UvLoopHandle _loop; diff --git a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransport.cs b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransport.cs index 293745f38b..d07d51d116 100644 --- a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransport.cs +++ b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransport.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal { @@ -36,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public LibuvTransportContext TransportContext { get; } public List Threads { get; } = new List(); - public IApplicationLifetime AppLifetime => TransportContext.AppLifetime; + public IHostApplicationLifetime AppLifetime => TransportContext.AppLifetime; public ILibuvTrace Log => TransportContext.Log; public LibuvTransportOptions TransportOptions => TransportContext.Options; diff --git a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportContext.cs b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportContext.cs index 37074dc968..5baff8faab 100644 --- a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportContext.cs +++ b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportContext.cs @@ -1,8 +1,8 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal { @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal { public LibuvTransportOptions Options { get; set; } - public IApplicationLifetime AppLifetime { get; set; } + public IHostApplicationLifetime AppLifetime { get; set; } public ILibuvTrace Log { get; set; } diff --git a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportFactory.cs b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportFactory.cs index c2ff9e8a56..9254693979 100644 --- a/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportFactory.cs +++ b/src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportFactory.cs @@ -1,9 +1,9 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal public LibuvTransportFactory( IOptions options, - IApplicationLifetime applicationLifetime, + IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory) { if (options == null) diff --git a/src/Servers/Kestrel/Transport.Sockets/src/SocketTransport.cs b/src/Servers/Kestrel/Transport.Sockets/src/SocketTransport.cs index 3e40d1ce8b..a1b01d45bb 100644 --- a/src/Servers/Kestrel/Transport.Sockets/src/SocketTransport.cs +++ b/src/Servers/Kestrel/Transport.Sockets/src/SocketTransport.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets { @@ -22,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets private readonly MemoryPool _memoryPool; private readonly IEndPointInformation _endPointInformation; private readonly IConnectionDispatcher _dispatcher; - private readonly IApplicationLifetime _appLifetime; + private readonly IHostApplicationLifetime _appLifetime; private readonly int _numSchedulers; private readonly PipeScheduler[] _schedulers; private readonly ISocketsTrace _trace; @@ -34,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets internal SocketTransport( IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher, - IApplicationLifetime applicationLifetime, + IHostApplicationLifetime applicationLifetime, int ioQueueCount, ISocketsTrace trace, MemoryPool memoryPool) diff --git a/src/Servers/Kestrel/Transport.Sockets/src/SocketTransportFactory.cs b/src/Servers/Kestrel/Transport.Sockets/src/SocketTransportFactory.cs index 11046878da..f6ef805fbb 100644 --- a/src/Servers/Kestrel/Transport.Sockets/src/SocketTransportFactory.cs +++ b/src/Servers/Kestrel/Transport.Sockets/src/SocketTransportFactory.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal; using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; -using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets { @@ -15,12 +15,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets #pragma warning restore PUB0001 // Pubternal type in public API { private readonly SocketTransportOptions _options; - private readonly IApplicationLifetime _appLifetime; + private readonly IHostApplicationLifetime _appLifetime; private readonly SocketsTrace _trace; public SocketTransportFactory( IOptions options, - IApplicationLifetime applicationLifetime, + IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory) { if (options == null) diff --git a/src/Servers/Kestrel/samples/Http2SampleApp/Startup.cs b/src/Servers/Kestrel/samples/Http2SampleApp/Startup.cs index 4f45eb97cc..c2d84b42fe 100644 --- a/src/Servers/Kestrel/samples/Http2SampleApp/Startup.cs +++ b/src/Servers/Kestrel/samples/Http2SampleApp/Startup.cs @@ -12,7 +12,7 @@ namespace Http2SampleApp { } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseTimingMiddleware(); app.Run(context => diff --git a/src/Servers/Kestrel/samples/SampleApp/Startup.cs b/src/Servers/Kestrel/samples/SampleApp/Startup.cs index 32890238ef..71f218d816 100644 --- a/src/Servers/Kestrel/samples/SampleApp/Startup.cs +++ b/src/Servers/Kestrel/samples/SampleApp/Startup.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Https.Internal; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace SampleApp @@ -184,4 +185,4 @@ namespace SampleApp } } } -} \ No newline at end of file +} diff --git a/src/Servers/Kestrel/shared/test/LifetimeNotImplemented.cs b/src/Servers/Kestrel/shared/test/LifetimeNotImplemented.cs index df5253cc62..83fa710cc4 100644 --- a/src/Servers/Kestrel/shared/test/LifetimeNotImplemented.cs +++ b/src/Servers/Kestrel/shared/test/LifetimeNotImplemented.cs @@ -3,11 +3,11 @@ using System; using System.Threading; -using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Testing { - public class LifetimeNotImplemented : IApplicationLifetime + public class LifetimeNotImplemented : IHostApplicationLifetime { public CancellationToken ApplicationStarted { diff --git a/src/Servers/Kestrel/shared/test/TransportTestHelpers/TestServer.cs b/src/Servers/Kestrel/shared/test/TransportTestHelpers/TestServer.cs index 276eeaf768..6445cbe32c 100644 --- a/src/Servers/Kestrel/shared/test/TransportTestHelpers/TestServer.cs +++ b/src/Servers/Kestrel/shared/test/TransportTestHelpers/TestServer.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Xunit; @@ -110,7 +111,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests IServiceProvider IStartup.ConfigureServices(IServiceCollection services) { // Unfortunately, this needs to be replaced in IStartup.ConfigureServices - services.AddSingleton(); + services.AddSingleton(); return services.BuildServiceProvider(); } diff --git a/src/SignalR/clients/ts/FunctionalTests/Startup.cs b/src/SignalR/clients/ts/FunctionalTests/Startup.cs index 7f5cccf9e0..f95a19471a 100644 --- a/src/SignalR/clients/ts/FunctionalTests/Startup.cs +++ b/src/SignalR/clients/ts/FunctionalTests/Startup.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Connections; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -82,7 +83,7 @@ namespace FunctionalTests }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionManager.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionManager.cs index 231eb8fd87..4d1dc43a2c 100644 --- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionManager.cs +++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionManager.cs @@ -12,6 +12,7 @@ using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Internal; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -32,12 +33,12 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal private readonly ILogger _connectionLogger; private readonly TimeSpan _disconnectTimeout; - public HttpConnectionManager(ILoggerFactory loggerFactory, IApplicationLifetime appLifetime) + public HttpConnectionManager(ILoggerFactory loggerFactory, IHostApplicationLifetime appLifetime) : this(loggerFactory, appLifetime, Options.Create(new ConnectionOptions() { DisconnectTimeout = ConnectionOptionsSetup.DefaultDisconectTimeout })) { } - public HttpConnectionManager(ILoggerFactory loggerFactory, IApplicationLifetime appLifetime, IOptions connectionOptions) + public HttpConnectionManager(ILoggerFactory loggerFactory, IHostApplicationLifetime appLifetime, IOptions connectionOptions) { _logger = loggerFactory.CreateLogger(); _connectionLogger = loggerFactory.CreateLogger(); diff --git a/src/SignalR/common/Http.Connections/test/ApplicationLifetime.cs b/src/SignalR/common/Http.Connections/test/ApplicationLifetime.cs index 15c3343790..4ad4f5b393 100644 --- a/src/SignalR/common/Http.Connections/test/ApplicationLifetime.cs +++ b/src/SignalR/common/Http.Connections/test/ApplicationLifetime.cs @@ -3,10 +3,11 @@ using System.Threading; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Http.Connections.Tests { - public class TestApplicationLifetime : IApplicationLifetime + public class TestApplicationLifetime : IHostApplicationLifetime { private readonly CancellationTokenSource _startedSource = new CancellationTokenSource(); private readonly CancellationTokenSource _stoppingSource = new CancellationTokenSource(); @@ -29,8 +30,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests } } - public class EmptyApplicationLifetime : IApplicationLifetime - { + public class EmptyApplicationLifetime : IHostApplicationLifetime + { public CancellationToken ApplicationStarted => CancellationToken.None; public CancellationToken ApplicationStopping => CancellationToken.None; diff --git a/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs b/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs index bd31f0c1b8..8f886ca1ac 100644 --- a/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs +++ b/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http.Connections.Internal; using Microsoft.AspNetCore.SignalR.Tests; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Xunit; @@ -378,7 +379,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests } } - private static HttpConnectionManager CreateConnectionManager(ILoggerFactory loggerFactory, IApplicationLifetime lifetime = null) + private static HttpConnectionManager CreateConnectionManager(ILoggerFactory loggerFactory, IHostApplicationLifetime lifetime = null) { lifetime = lifetime ?? new EmptyApplicationLifetime(); return new HttpConnectionManager(loggerFactory, lifetime); diff --git a/src/SignalR/common/testassets/Tests.Utils/InProcessTestServer.cs b/src/SignalR/common/testassets/Tests.Utils/InProcessTestServer.cs index 6723915cd1..b4d9a8ec8d 100644 --- a/src/SignalR/common/testassets/Tests.Utils/InProcessTestServer.cs +++ b/src/SignalR/common/testassets/Tests.Utils/InProcessTestServer.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; @@ -32,7 +33,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests private readonly ILoggerFactory _loggerFactory; private readonly ILogger _logger; private IWebHost _host; - private IApplicationLifetime _lifetime; + private IHostApplicationLifetime _lifetime; private readonly IDisposable _logToken; private readonly LogSinkProvider _logSinkProvider; @@ -91,7 +92,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests var t = Task.Run(() => _host.Start()); _logger.LogInformation("Starting test server..."); - _lifetime = _host.Services.GetRequiredService(); + _lifetime = _host.Services.GetRequiredService(); // This only happens once per fixture, so we can afford to wait a little bit on it. if (!_lifetime.ApplicationStarted.WaitHandle.WaitOne(TimeSpan.FromSeconds(20))) diff --git a/src/SignalR/samples/JwtSample/Startup.cs b/src/SignalR/samples/JwtSample/Startup.cs index 34d3dff880..a29e43816f 100644 --- a/src/SignalR/samples/JwtSample/Startup.cs +++ b/src/SignalR/samples/JwtSample/Startup.cs @@ -63,7 +63,7 @@ namespace JwtSample }); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseFileServer(); diff --git a/src/SignalR/samples/SignalRSamples/Startup.cs b/src/SignalR/samples/SignalRSamples/Startup.cs index 8d09aedef4..4546e3cc01 100644 --- a/src/SignalR/samples/SignalRSamples/Startup.cs +++ b/src/SignalR/samples/SignalRSamples/Startup.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SignalRSamples.ConnectionHandlers; @@ -45,7 +46,7 @@ namespace SignalRSamples } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseFileServer(); diff --git a/src/SignalR/samples/SocialWeather/Startup.cs b/src/SignalR/samples/SocialWeather/Startup.cs index 1ad19f35b6..0199a6c16f 100644 --- a/src/SignalR/samples/SocialWeather/Startup.cs +++ b/src/SignalR/samples/SocialWeather/Startup.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using SocialWeather.Json; using SocialWeather.Pipe; @@ -24,7 +25,7 @@ namespace SocialWeather services.AddSingleton(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/SignalR/server/SignalR/test/Startup.cs b/src/SignalR/server/SignalR/test/Startup.cs index 2dd4b4b216..471449fea0 100644 --- a/src/SignalR/server/SignalR/test/Startup.cs +++ b/src/SignalR/server/SignalR/test/Startup.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests }).AddCookie(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseRouting(routes => { diff --git a/src/SignalR/server/StackExchangeRedis/test/Startup.cs b/src/SignalR/server/StackExchangeRedis/test/Startup.cs index 5f102b6d7e..fc49a8741e 100644 --- a/src/SignalR/server/StackExchangeRedis/test/Startup.cs +++ b/src/SignalR/server/StackExchangeRedis/test/Startup.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests services.AddSingleton(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseRouting(routes => {