diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.csproj b/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.csproj index 8217ee10af78e..b6229478e382f 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.1 + enable true diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj index 1e2a601e8065f..042bf76144d8c 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.1 + enable true .NET hosting infrastructure for Systemd Services. diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs index 22fe30dfe5527..5767ba2a769c0 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/ServiceState.cs @@ -26,9 +26,9 @@ public struct ServiceState /// /// Create custom ServiceState. /// - public ServiceState(string state) + public ServiceState(string state!!) { - _data = Encoding.UTF8.GetBytes(state ?? throw new ArgumentNullException(nameof(state))); + _data = Encoding.UTF8.GetBytes(state); } /// diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs index af166430ad4be..e49b00fd49c0e 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs @@ -41,12 +41,12 @@ public Task WaitForStartAsync(CancellationToken cancellationToken) { _applicationStartedRegistration = ApplicationLifetime.ApplicationStarted.Register(state => { - ((SystemdLifetime)state).OnApplicationStarted(); + ((SystemdLifetime)state!).OnApplicationStarted(); }, this); _applicationStoppingRegistration = ApplicationLifetime.ApplicationStopping.Register(state => { - ((SystemdLifetime)state).OnApplicationStopping(); + ((SystemdLifetime)state!).OnApplicationStopping(); }, this); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.netcoreapp.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.netcoreapp.cs index c277fc926fff5..4c8f0ff2feaee 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.netcoreapp.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.netcoreapp.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Hosting.Systemd { public partial class SystemdLifetime { - private PosixSignalRegistration _sigTermRegistration; + private PosixSignalRegistration? _sigTermRegistration; private partial void RegisterShutdownHandlers() { diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index 0b8738823dc4f..715db9b04cab6 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -12,14 +12,14 @@ public class SystemdNotifier : ISystemdNotifier { private const string NOTIFY_SOCKET = "NOTIFY_SOCKET"; - private readonly string _socketPath; + private readonly string? _socketPath; public SystemdNotifier() : this(GetNotifySocketPath()) { } // For testing - internal SystemdNotifier(string socketPath) + internal SystemdNotifier(string? socketPath) { _socketPath = socketPath; } @@ -37,7 +37,7 @@ public void Notify(ServiceState state) using (var socket = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified)) { - var endPoint = new UnixDomainSocketEndPoint(_socketPath); + var endPoint = new UnixDomainSocketEndPoint(_socketPath!); socket.Connect(endPoint); // It's safe to do a non-blocking call here: messages sent here are much @@ -46,9 +46,9 @@ public void Notify(ServiceState state) } } - private static string GetNotifySocketPath() + private static string? GetNotifySocketPath() { - string socketPath = Environment.GetEnvironmentVariable(NOTIFY_SOCKET); + string? socketPath = Environment.GetEnvironmentVariable(NOTIFY_SOCKET); if (string.IsNullOrEmpty(socketPath)) {