diff --git a/samples/GenericHostSample/ServiceBaseLifetime.cs b/samples/GenericHostSample/ServiceBaseLifetime.cs index 08bf4348d0..d5625a4671 100644 --- a/samples/GenericHostSample/ServiceBaseLifetime.cs +++ b/samples/GenericHostSample/ServiceBaseLifetime.cs @@ -31,7 +31,7 @@ namespace GenericHostSample public void RegisterDelayStartCallback(Action callback, object state) { _startCallback = callback ?? throw new ArgumentNullException(nameof(callback)); - _startState = state ?? throw new ArgumentNullException(nameof(state)); + _startState = state; Run(this); } @@ -39,7 +39,7 @@ namespace GenericHostSample public void RegisterStopCallback(Action callback, object state) { _stopCallback = callback ?? throw new ArgumentNullException(nameof(callback)); - _stopState = state ?? throw new ArgumentNullException(nameof(state)); + _stopState = state; } public Task StopAsync(CancellationToken cancellationToken) diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs index 79b7829728..97331e4768 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs @@ -31,13 +31,13 @@ namespace Microsoft.AspNetCore.Hosting /// /// Starts listening on the configured addresses. /// - Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)); + Task StartAsync(CancellationToken cancellationToken = default); /// /// Attempt to gracefully stop the host. /// /// /// - Task StopAsync(CancellationToken cancellationToken = default(CancellationToken)); + Task StopAsync(CancellationToken cancellationToken = default); } } diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs index 67491e4aad..a2789a1153 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal StartAsync().GetAwaiter().GetResult(); } - public virtual async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)) + public virtual async Task StartAsync(CancellationToken cancellationToken = default) { HostingEventSource.Log.HostStart(); _logger = _applicationServices.GetRequiredService>(); @@ -282,7 +282,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal } } - public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken)) + public async Task StopAsync(CancellationToken cancellationToken = default) { if (_stopped) { diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs b/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs index 38807e11e3..d87de05af4 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Hosting /// /// The running . /// The token to trigger shutdown. - public static async Task WaitForShutdownAsync(this IWebHost host, CancellationToken token = default(CancellationToken)) + public static async Task WaitForShutdownAsync(this IWebHost host, CancellationToken token = default) { var done = new ManualResetEventSlim(false); using (var cts = CancellationTokenSource.CreateLinkedTokenSource(token)) @@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Hosting /// /// The to run. /// The token to trigger shutdown. - public static async Task RunAsync(this IWebHost host, CancellationToken token = default(CancellationToken)) + public static async Task RunAsync(this IWebHost host, CancellationToken token = default) { // Wait for token shutdown if it can be canceled if (token.CanBeCanceled) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/RetryHelper.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/RetryHelper.cs index 66a0c250a6..75ac9f6f41 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/RetryHelper.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Common/RetryHelper.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting public static async Task RetryRequest( Func> retryBlock, ILogger logger, - CancellationToken cancellationToken = default(CancellationToken), + CancellationToken cancellationToken = default, int retryCount = 60) { for (var retry = 0; retry < retryCount; retry++) diff --git a/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostBuilderExtensions.cs b/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostBuilderExtensions.cs index 451f4cf32c..8b1c4d3494 100644 --- a/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostBuilderExtensions.cs +++ b/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostBuilderExtensions.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Hosting public static class HostingAbstractionsHostBuilderExtensions { /// - /// Start the web host and listen on the specified urls. + /// Start the host and listen on the specified urls. /// /// The to start. /// The . diff --git a/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostExtensions.cs b/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostExtensions.cs index 8bc47d7b02..1681e504bc 100644 --- a/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostExtensions.cs +++ b/src/Microsoft.Extensions.Hosting.Abstractions/HostingAbstractionsHostExtensions.cs @@ -41,7 +41,7 @@ namespace Microsoft.Extensions.Hosting } /// - /// Runs a web application and block the calling thread until host shutdown. + /// Runs an application and block the calling thread until host shutdown. /// /// The to run. public static void Run(this IHost host) @@ -50,11 +50,11 @@ namespace Microsoft.Extensions.Hosting } /// - /// Runs a web application and returns a Task that only completes when the token is triggered or shutdown is triggered. + /// Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered. /// /// The to run. /// The token to trigger shutdown. - public static async Task RunAsync(this IHost host, CancellationToken token = default(CancellationToken)) + public static async Task RunAsync(this IHost host, CancellationToken token = default) { using (host) { @@ -69,7 +69,7 @@ namespace Microsoft.Extensions.Hosting /// /// The running . /// The token to trigger shutdown. - public static async Task WaitForShutdownAsync(this IHost host, CancellationToken token = default(CancellationToken)) + public static async Task WaitForShutdownAsync(this IHost host, CancellationToken token = default) { var applicationLifetime = host.Services.GetService(); @@ -88,7 +88,7 @@ namespace Microsoft.Extensions.Hosting await waitForStop.Task; - // WebHost will use its default ShutdownTimeout if none is specified. + // Host will use its default ShutdownTimeout if none is specified. await host.StopAsync(); } } diff --git a/src/Microsoft.Extensions.Hosting.Abstractions/IHost.cs b/src/Microsoft.Extensions.Hosting.Abstractions/IHost.cs index bd1e9f14bf..cd5a6b1c1d 100644 --- a/src/Microsoft.Extensions.Hosting.Abstractions/IHost.cs +++ b/src/Microsoft.Extensions.Hosting.Abstractions/IHost.cs @@ -22,13 +22,13 @@ namespace Microsoft.Extensions.Hosting /// /// Used to abort program start. /// - Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)); + Task StartAsync(CancellationToken cancellationToken = default); /// /// Attempts to gracefully stop the program. /// /// Used to indicate when stop should no longer be graceful. /// - Task StopAsync(CancellationToken cancellationToken = default(CancellationToken)); + Task StopAsync(CancellationToken cancellationToken = default); } } diff --git a/src/Microsoft.Extensions.Hosting.Abstractions/IHostingEnvironment.cs b/src/Microsoft.Extensions.Hosting.Abstractions/IHostingEnvironment.cs index a2614b12f4..e667a53285 100644 --- a/src/Microsoft.Extensions.Hosting.Abstractions/IHostingEnvironment.cs +++ b/src/Microsoft.Extensions.Hosting.Abstractions/IHostingEnvironment.cs @@ -1,13 +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 System.Collections.Generic; using Microsoft.Extensions.FileProviders; namespace Microsoft.Extensions.Hosting { /// - /// Provides information about the web hosting environment an application is running in. + /// Provides information about the hosting environment an application is running in. /// public interface IHostingEnvironment { diff --git a/src/Microsoft.Extensions.Hosting/HostBuilder.cs b/src/Microsoft.Extensions.Hosting/HostBuilder.cs index b12914a1a0..bcaac8c9a8 100644 --- a/src/Microsoft.Extensions.Hosting/HostBuilder.cs +++ b/src/Microsoft.Extensions.Hosting/HostBuilder.cs @@ -178,7 +178,7 @@ namespace Microsoft.Extensions.Hosting services.AddSingleton(_hostBuilderContext); services.AddSingleton(_appConfiguration); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddOptions(); services.AddLogging(); diff --git a/src/Microsoft.Extensions.Hosting/HostingHostBuilderExtensions.cs b/src/Microsoft.Extensions.Hosting/HostingHostBuilderExtensions.cs index fdf9f70988..dcbfdb3c33 100644 --- a/src/Microsoft.Extensions.Hosting/HostingHostBuilderExtensions.cs +++ b/src/Microsoft.Extensions.Hosting/HostingHostBuilderExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.Hosting public static class HostingHostBuilderExtensions { /// - /// Specify the environment to be used by the web host. + /// Specify the environment to be used by the host. /// /// The to configure. /// The environment to host the application in. @@ -33,7 +33,7 @@ namespace Microsoft.Extensions.Hosting } /// - /// Specify the content root directory to be used by the web host. + /// Specify the content root directory to be used by the host. /// /// The to configure. /// Path to root directory of the application. @@ -125,7 +125,7 @@ namespace Microsoft.Extensions.Hosting /// The to configure. /// /// - public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default(CancellationToken)) + public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default) { return hostBuilder.UseConsoleLifetime().Build().RunAsync(cancellationToken); } diff --git a/src/Microsoft.Extensions.Hosting/Internal/Host.cs b/src/Microsoft.Extensions.Hosting/Internal/Host.cs index b009767159..e10834ade1 100644 --- a/src/Microsoft.Extensions.Hosting/Internal/Host.cs +++ b/src/Microsoft.Extensions.Hosting/Internal/Host.cs @@ -28,7 +28,7 @@ namespace Microsoft.Extensions.Hosting.Internal public IServiceProvider Services { get; } - public async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)) + public async Task StartAsync(CancellationToken cancellationToken = default) { _logger.Starting(); @@ -53,7 +53,7 @@ namespace Microsoft.Extensions.Hosting.Internal _logger.Started(); } - public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken)) + public async Task StopAsync(CancellationToken cancellationToken = default) { _logger.Stopping(); diff --git a/src/Microsoft.Extensions.Hosting/Internal/HostProcessLifetime.cs b/src/Microsoft.Extensions.Hosting/Internal/ProcessLifetime.cs similarity index 93% rename from src/Microsoft.Extensions.Hosting/Internal/HostProcessLifetime.cs rename to src/Microsoft.Extensions.Hosting/Internal/ProcessLifetime.cs index 09e2870d7f..e8ba9b3942 100644 --- a/src/Microsoft.Extensions.Hosting/Internal/HostProcessLifetime.cs +++ b/src/Microsoft.Extensions.Hosting/Internal/ProcessLifetime.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Microsoft.Extensions.Hosting.Internal { - public class HostProcessLifetime : IHostLifetime + public class ProcessLifetime : IHostLifetime { public void RegisterDelayStartCallback(Action callback, object state) {