diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdHelpers.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdHelpers.cs index f14fb7a69588b..c7887bc29b230 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdHelpers.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdHelpers.cs @@ -14,9 +14,9 @@ namespace Microsoft.Extensions.Hosting.Systemd /// /// Helper methods for systemd Services. /// - public static partial class SystemdHelpers + public static class SystemdHelpers { - private static bool? _isSystemdService; + private static readonly bool _isSystemdService = GetIsSystemdService(); /// /// Check if the current process is hosted as a systemd Service. @@ -24,8 +24,7 @@ public static partial class SystemdHelpers /// /// if the current process is hosted as a systemd Service; otherwise, . /// - public static bool IsSystemdService() - => _isSystemdService ??= GetIsSystemdService(); + public static bool IsSystemdService() => _isSystemdService; private static bool GetIsSystemdService() {