From 7dfefe6834a6784b6cd288346383eac63cbba79e Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Mon, 3 Oct 2022 13:56:43 -0600 Subject: [PATCH 1/8] Triple slash for Extensions.Hosting --- .../src/BackgroundService.cs | 2 ++ .../src/Environments.cs | 9 +++++++++ .../src/HostBuilderContext.cs | 4 ++++ .../src/HostingAbstractionsHostBuilderExtensions.cs | 3 +++ .../src/IHostBuilder.cs | 1 + .../src/IHostLifetime.cs | 3 +++ .../src/IHostedService.cs | 2 ++ .../Microsoft.Extensions.Hosting/src/HostBuilder.cs | 3 +++ .../src/HostingHostBuilderExtensions.cs | 7 +++++-- 9 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs index 4e9a62d53b9a8..315b158e7ddb8 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs @@ -36,6 +36,7 @@ public abstract class BackgroundService : IHostedService, IDisposable /// Triggered when the application host is ready to start the service. /// /// Indicates that the start process has been aborted. + /// A . public virtual Task StartAsync(CancellationToken cancellationToken) { // Create linked token to allow cancelling executing task from provided token @@ -58,6 +59,7 @@ public virtual Task StartAsync(CancellationToken cancellationToken) /// Triggered when the application host is performing a graceful shutdown. /// /// Indicates that the shutdown process should no longer be graceful. + /// A . public virtual async Task StopAsync(CancellationToken cancellationToken) { // Stop called without start diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs index 93b762e12c9a9..cf7983e89fefa 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs @@ -8,8 +8,17 @@ namespace Microsoft.Extensions.Hosting /// public static class Environments { + /// + /// The development environment can enable features that shouldn't be exposed in production. Because of the performance cost, scope validation and dependency validation only happens in development. + /// public static readonly string Development = "Development"; + /// + /// The staging environment can be used to validate app changes before changing the environment to production. + /// public static readonly string Staging = "Staging"; + /// + /// The production environment should be configured to maximize security, performance, and application robustness. + /// public static readonly string Production = "Production"; } } diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostBuilderContext.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostBuilderContext.cs index 10d05076102bf..85e6f95a79c94 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostBuilderContext.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostBuilderContext.cs @@ -12,6 +12,10 @@ namespace Microsoft.Extensions.Hosting /// public class HostBuilderContext { + /// + /// Initializes a new instance of . + /// + /// A non-null for sharing state between components during the host building process. public HostBuilderContext(IDictionary properties) { ThrowHelper.ThrowIfNull(properties); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostBuilderExtensions.cs index 5e7f334993e76..f1cefed444d67 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostBuilderExtensions.cs @@ -6,6 +6,9 @@ namespace Microsoft.Extensions.Hosting { + /// + /// Provides extension methods for the from the hosting abstractions package. + /// public static class HostingAbstractionsHostBuilderExtensions { /// diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostBuilder.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostBuilder.cs index 7c08dd33014c1..faf77e945ce39 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostBuilder.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostBuilder.cs @@ -57,6 +57,7 @@ public interface IHostBuilder /// Overrides the factory used to create the service provider. /// /// The type of builder. + /// The factory to register. /// The same instance of the for chaining. IHostBuilder UseServiceProviderFactory(Func> factory) where TContainerBuilder : notnull; diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs index 5820904fc095f..cd16244633589 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs @@ -6,6 +6,9 @@ namespace Microsoft.Extensions.Hosting { + /// + /// An interface for tracking host lifetime. + /// public interface IHostLifetime { /// diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs index 97a947b72513f..333a83df9149a 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs @@ -15,12 +15,14 @@ public interface IHostedService /// Triggered when the application host is ready to start the service. /// /// Indicates that the start process has been aborted. + /// A . Task StartAsync(CancellationToken cancellationToken); /// /// Triggered when the application host is performing a graceful shutdown. /// /// Indicates that the shutdown process should no longer be graceful. + /// A . Task StopAsync(CancellationToken cancellationToken); } } diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs index a285d3e487ef7..aca18778f3f7e 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs @@ -38,6 +38,9 @@ public partial class HostBuilder : IHostBuilder private IServiceProvider? _appServices; private PhysicalFileProvider? _defaultProvider; + /// + /// Initializes a new instance of . + /// [RequiresDynamicCode(Host.RequiresDynamicCodeMessage)] public HostBuilder() { diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs index 33ab570a2f1ff..ad09104a153ce 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs @@ -18,6 +18,9 @@ namespace Microsoft.Extensions.Hosting { + /// + /// Provides extension methods for the from the hosting package. + /// public static class HostingHostBuilderExtensions { /// @@ -64,7 +67,7 @@ public static IHostBuilder UseContentRoot(this IHostBuilder hostBuilder, string /// Specify the to be the default one. /// /// The to configure. - /// + /// The delegate that configures the . /// The . [RequiresDynamicCode(Host.RequiresDynamicCodeMessage)] public static IHostBuilder UseDefaultServiceProvider(this IHostBuilder hostBuilder, Action configure) @@ -161,7 +164,7 @@ public static IHostBuilder ConfigureServices(this IHostBuilder hostBuilder, Acti /// Enables configuring the instantiated dependency container. This can be called multiple times and /// the results will be additive. /// - /// + /// The type of builder. /// The to configure. /// The delegate for configuring the . /// The same instance of the for chaining. From 825f455ea44304545dba2b6ac79dec95ac1f2186 Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Wed, 5 Oct 2022 15:13:15 -0600 Subject: [PATCH 2/8] Add Extensions.Hosting.Systemd triple-slash --- .../src/ISystemdNotifier.cs | 1 + .../src/ServiceState.cs | 2 ++ .../src/SystemdLifetime.cs | 10 ++++++++++ .../src/SystemdNotifier.cs | 3 +++ 4 files changed, 16 insertions(+) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ISystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ISystemdNotifier.cs index 9f35b4f2112b7..bcfbb59db5f96 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ISystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ISystemdNotifier.cs @@ -11,6 +11,7 @@ public interface ISystemdNotifier /// /// Sends a notification to systemd. /// + /// The to notify. void Notify(ServiceState state); /// /// Returns whether systemd is configured to receive service notifications. diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs index 17270278e6f11..3fff525a64651 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs @@ -26,6 +26,7 @@ public struct ServiceState /// /// Create custom ServiceState. /// + /// A representation of service state. public ServiceState(string state) { ThrowHelper.ThrowIfNull(state); @@ -36,6 +37,7 @@ public ServiceState(string state) /// /// String representation of service state. /// + /// The representation of the service state. public override string ToString() => _data == null ? string.Empty : Encoding.UTF8.GetString(_data); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs index ae1ce1e903f0a..0ed142ebb29f1 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs @@ -9,6 +9,9 @@ namespace Microsoft.Extensions.Hosting.Systemd { + /// + /// Provides notification messages for application started and stopping, and configures console logging to the systemd format. + /// [UnsupportedOSPlatform("android")] [UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("ios")] @@ -19,6 +22,13 @@ public partial class SystemdLifetime : IHostLifetime, IDisposable private CancellationTokenRegistration _applicationStartedRegistration; private CancellationTokenRegistration _applicationStoppingRegistration; + /// + /// Instantiates a object. + /// + /// Contains information about the host. + /// The that tracks the service lifetime. + /// The to notify Systemd about service status. + /// The used to instantiate the lifetime logger. public SystemdLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ISystemdNotifier systemdNotifier, ILoggerFactory loggerFactory) { ThrowHelper.ThrowIfNull(environment); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index 715db9b04cab6..bfde5fe73df6a 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -14,6 +14,9 @@ public class SystemdNotifier : ISystemdNotifier private readonly string? _socketPath; + /// + /// Instantiates a new and sets the notify socket path. + /// public SystemdNotifier() : this(GetNotifySocketPath()) { } From fe0d793bf417ecd38a6946455590aae3ea83acdc Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Wed, 5 Oct 2022 17:28:55 -0600 Subject: [PATCH 3/8] Add Extensions.Hosting.WindowsService triple-slash --- .../src/SystemdLifetime.cs | 2 +- .../src/WindowsServiceLifetime.cs | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs index 0ed142ebb29f1..637867e2b4ea3 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs @@ -26,7 +26,7 @@ public partial class SystemdLifetime : IHostLifetime, IDisposable /// Instantiates a object. /// /// Contains information about the host. - /// The that tracks the service lifetime. + /// The that tracks the service lifetime. /// The to notify Systemd about service status. /// The used to instantiate the lifetime logger. public SystemdLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ISystemdNotifier systemdNotifier, ILoggerFactory loggerFactory) diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index 164e60670fb67..23df4e2baa2c1 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -11,6 +11,9 @@ namespace Microsoft.Extensions.Hosting.WindowsServices { + /// + /// Listens for shutdown signal and tracks the status of the Windows service. + /// [SupportedOSPlatform("windows")] public class WindowsServiceLifetime : ServiceBase, IHostLifetime { @@ -18,11 +21,26 @@ public class WindowsServiceLifetime : ServiceBase, IHostLifetime private readonly ManualResetEventSlim _delayStop = new ManualResetEventSlim(); private readonly HostOptions _hostOptions; + /// + /// Instantiates a object. + /// + /// Contains information about the host. + /// The that tracks the service lifetime. + /// The used to instantiate the lifetime logger. + /// The containing options for the service. public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IOptions optionsAccessor) : this(environment, applicationLifetime, loggerFactory, optionsAccessor, Options.Options.Create(new WindowsServiceLifetimeOptions())) { } + /// + /// Instantiates a object. + /// + /// Contains information about the host. + /// The that tracks the service lifetime. + /// The used to instantiate the lifetime logger. + /// The containing options for the service. + /// Contains the Windows service options and is used to find the service name. public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IOptions optionsAccessor, IOptions windowsServiceOptionsAccessor) { ThrowHelper.ThrowIfNull(environment); @@ -84,15 +102,20 @@ public Task StopAsync(CancellationToken cancellationToken) return Task.CompletedTask; } - // Called by base.Run when the service is ready to start. + /// + /// Called by base.Run when the service is ready to start. + /// + /// The command line arguments passed to the service. protected override void OnStart(string[] args) { _delayStart.TrySetResult(null); base.OnStart(args); } - // Called by base.Stop. This may be called multiple times by service Stop, ApplicationStopping, and StopAsync. - // That's OK because StopApplication uses a CancellationTokenSource and prevents any recursion. + /// + /// Called by base.Stop to stop the . + /// + /// This may be called multiple times by service Stop, ApplicationStopping, and StopAsync. That's OK because StopApplication uses a CancellationTokenSource and prevents any recursion. protected override void OnStop() { ApplicationLifetime.StopApplication(); @@ -101,6 +124,9 @@ protected override void OnStop() base.OnStop(); } + /// + /// Called when the service starts shutdown. + /// protected override void OnShutdown() { ApplicationLifetime.StopApplication(); @@ -109,6 +135,10 @@ protected override void OnShutdown() base.OnShutdown(); } + /// + /// Disposes the . + /// + /// true is invoked from . protected override void Dispose(bool disposing) { if (disposing) From 46a37638a60e0643dfc2818fa42b9d7f67d05d86 Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Thu, 6 Oct 2022 10:09:44 -0600 Subject: [PATCH 4/8] Resolve feedback. Asynchronous is hard to spell. --- .../src/BackgroundService.cs | 4 ++-- .../src/IHostedService.cs | 4 ++-- .../src/WindowsServiceLifetime.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs index 315b158e7ddb8..d8172e9b61659 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs @@ -36,7 +36,7 @@ public abstract class BackgroundService : IHostedService, IDisposable /// Triggered when the application host is ready to start the service. /// /// Indicates that the start process has been aborted. - /// A . + /// A that represents the asynchronous Start operation. public virtual Task StartAsync(CancellationToken cancellationToken) { // Create linked token to allow cancelling executing task from provided token @@ -59,7 +59,7 @@ public virtual Task StartAsync(CancellationToken cancellationToken) /// Triggered when the application host is performing a graceful shutdown. /// /// Indicates that the shutdown process should no longer be graceful. - /// A . + /// A that represents the asynchronous Stop operation. public virtual async Task StopAsync(CancellationToken cancellationToken) { // Stop called without start diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs index 333a83df9149a..0bb8c07c22d77 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostedService.cs @@ -15,14 +15,14 @@ public interface IHostedService /// Triggered when the application host is ready to start the service. /// /// Indicates that the start process has been aborted. - /// A . + /// A that represents the asynchronous Start operation. Task StartAsync(CancellationToken cancellationToken); /// /// Triggered when the application host is performing a graceful shutdown. /// /// Indicates that the shutdown process should no longer be graceful. - /// A . + /// A that represents the asynchronous Stop operation. Task StopAsync(CancellationToken cancellationToken); } } diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index 23df4e2baa2c1..be1da97683d36 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -125,7 +125,7 @@ protected override void OnStop() } /// - /// Called when the service starts shutdown. + /// Executes when the service starts shutdown. /// protected override void OnShutdown() { @@ -136,7 +136,7 @@ protected override void OnShutdown() } /// - /// Disposes the . + /// Releases the resources used by the . /// /// true is invoked from . protected override void Dispose(bool disposing) From a8832d35111f3deb738963cf5d29ad3fed3a5c6f Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Fri, 7 Oct 2022 11:39:14 -0600 Subject: [PATCH 5/8] Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../src/IHostLifetime.cs | 2 +- .../src/SystemdLifetime.cs | 4 ++-- .../src/WindowsServiceLifetime.cs | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs index cd16244633589..2f8aa1202bf63 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/IHostLifetime.cs @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Hosting { /// - /// An interface for tracking host lifetime. + /// Tracks host lifetime. /// public interface IHostLifetime { diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs index 637867e2b4ea3..e1b196fb2a6f5 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs @@ -23,9 +23,9 @@ public partial class SystemdLifetime : IHostLifetime, IDisposable private CancellationTokenRegistration _applicationStoppingRegistration; /// - /// Instantiates a object. + /// Initializes a new instance. /// - /// Contains information about the host. + /// Information about the host. /// The that tracks the service lifetime. /// The to notify Systemd about service status. /// The used to instantiate the lifetime logger. diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index be1da97683d36..c8a9646d7f7b2 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -22,9 +22,9 @@ public class WindowsServiceLifetime : ServiceBase, IHostLifetime private readonly HostOptions _hostOptions; /// - /// Instantiates a object. + /// Initializes a new instance. /// - /// Contains information about the host. + /// Information about the host. /// The that tracks the service lifetime. /// The used to instantiate the lifetime logger. /// The containing options for the service. @@ -34,13 +34,13 @@ public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLife } /// - /// Instantiates a object. + /// Initializes a new instance of the class. /// - /// Contains information about the host. + /// Information about the host. /// The that tracks the service lifetime. /// The used to instantiate the lifetime logger. /// The containing options for the service. - /// Contains the Windows service options and is used to find the service name. + /// The Windows service options used to find the service name. public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IOptions optionsAccessor, IOptions windowsServiceOptionsAccessor) { ThrowHelper.ThrowIfNull(environment); @@ -115,7 +115,7 @@ protected override void OnStart(string[] args) /// /// Called by base.Stop to stop the . /// - /// This may be called multiple times by service Stop, ApplicationStopping, and StopAsync. That's OK because StopApplication uses a CancellationTokenSource and prevents any recursion. + /// This might be called multiple times by service Stop, ApplicationStopping, and StopAsync. That's okay because StopApplication uses a CancellationTokenSource and prevents any recursion. protected override void OnStop() { ApplicationLifetime.StopApplication(); @@ -138,7 +138,8 @@ protected override void OnShutdown() /// /// Releases the resources used by the . /// - /// true is invoked from . + /// + ; otherwise, . protected override void Dispose(bool disposing) { if (disposing) From ab8812556740a833313a446fb0ba40f5615b7a19 Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Mon, 10 Oct 2022 16:12:42 -0600 Subject: [PATCH 6/8] Resolve feedback to match conventions --- .../src/Environments.cs | 9 ++++++--- .../src/WindowsServiceLifetime.cs | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs index cf7983e89fefa..30ea295c3c721 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/Environments.cs @@ -9,16 +9,19 @@ namespace Microsoft.Extensions.Hosting public static class Environments { /// - /// The development environment can enable features that shouldn't be exposed in production. Because of the performance cost, scope validation and dependency validation only happens in development. + /// Specifies the Development environment. /// + /// The development environment can enable features that shouldn't be exposed in production. Because of the performance cost, scope validation and dependency validation only happens in development. public static readonly string Development = "Development"; /// - /// The staging environment can be used to validate app changes before changing the environment to production. + /// Specifies the Staging environment. /// + /// The staging environment can be used to validate app changes before changing the environment to production. public static readonly string Staging = "Staging"; /// - /// The production environment should be configured to maximize security, performance, and application robustness. + /// Specifies the Production environment. /// + /// The production environment should be configured to maximize security, performance, and application robustness. public static readonly string Production = "Production"; } } diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index c8a9646d7f7b2..99c09df825231 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -102,8 +102,9 @@ public Task StopAsync(CancellationToken cancellationToken) return Task.CompletedTask; } + // Called by base.Run when the service is ready to start. /// - /// Called by base.Run when the service is ready to start. + /// Raises the Start event when the servuce is ready to start. /// /// The command line arguments passed to the service. protected override void OnStart(string[] args) @@ -113,7 +114,7 @@ protected override void OnStart(string[] args) } /// - /// Called by base.Stop to stop the . + /// Raises the Stop event to stop the . /// /// This might be called multiple times by service Stop, ApplicationStopping, and StopAsync. That's okay because StopApplication uses a CancellationTokenSource and prevents any recursion. protected override void OnStop() @@ -125,7 +126,7 @@ protected override void OnStop() } /// - /// Executes when the service starts shutdown. + /// Raise the Shutdown event. /// protected override void OnShutdown() { @@ -138,8 +139,7 @@ protected override void OnShutdown() /// /// Releases the resources used by the . /// - /// - ; otherwise, . + /// only when called from ; otherwise, . protected override void Dispose(bool disposing) { if (disposing) From 5a7753b1e92df96e12f0c0749daff1f900bc9fa2 Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Tue, 11 Oct 2022 09:21:34 -0600 Subject: [PATCH 7/8] Update src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../src/WindowsServiceLifetime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index 99c09df825231..1fa21c44c836a 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -104,7 +104,7 @@ public Task StopAsync(CancellationToken cancellationToken) // Called by base.Run when the service is ready to start. /// - /// Raises the Start event when the servuce is ready to start. + /// Raises the Start event when the service is ready to start. /// /// The command line arguments passed to the service. protected override void OnStart(string[] args) From c639984e0e9b4bfb1c7740302cfe9015a9bc2031 Mon Sep 17 00:00:00 2001 From: Nick Stanton Date: Thu, 13 Oct 2022 12:52:05 -0600 Subject: [PATCH 8/8] Address feedback and resolve missing classes --- .../src/HostingAbstractionsHostExtensions.cs | 3 +++ .../src/WindowsServiceLifetime.cs | 11 ++++------- .../src/ConsoleLifetimeOptions.cs | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs index 81484d28223ad..b0dd81dbe1935 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs @@ -8,6 +8,9 @@ namespace Microsoft.Extensions.Hosting { + /// + /// Provides extension methods for the from the hosting abstractions package. + /// public static class HostingAbstractionsHostExtensions { /// diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs index 1fa21c44c836a..d39ddd818099b 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs @@ -25,7 +25,7 @@ public class WindowsServiceLifetime : ServiceBase, IHostLifetime /// Initializes a new instance. /// /// Information about the host. - /// The that tracks the service lifetime. + /// The that tracks the service lifetime. /// The used to instantiate the lifetime logger. /// The containing options for the service. public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IOptions optionsAccessor) @@ -37,7 +37,7 @@ public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLife /// Initializes a new instance of the class. /// /// Information about the host. - /// The that tracks the service lifetime. + /// The that tracks the service lifetime. /// The used to instantiate the lifetime logger. /// The containing options for the service. /// The Windows service options used to find the service name. @@ -103,10 +103,7 @@ public Task StopAsync(CancellationToken cancellationToken) } // Called by base.Run when the service is ready to start. - /// - /// Raises the Start event when the service is ready to start. - /// - /// The command line arguments passed to the service. + /// protected override void OnStart(string[] args) { _delayStart.TrySetResult(null); @@ -126,7 +123,7 @@ protected override void OnStop() } /// - /// Raise the Shutdown event. + /// Raises the Shutdown event. /// protected override void OnShutdown() { diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/ConsoleLifetimeOptions.cs b/src/libraries/Microsoft.Extensions.Hosting/src/ConsoleLifetimeOptions.cs index eebb5d7fae165..90366bd82f199 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/ConsoleLifetimeOptions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/ConsoleLifetimeOptions.cs @@ -3,6 +3,9 @@ namespace Microsoft.Extensions.Hosting { + /// + /// Provides option flags for . + /// public class ConsoleLifetimeOptions { ///