From 76ac1e614395a711099ef8d000a9605794053ac3 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sat, 5 Oct 2024 14:54:26 -0600 Subject: [PATCH] NetworkManager: Use MemberNotNull attribute Added in .NET 5, this attribute allows for the compiler to recognize that InitializeLan (and by extension, UpdateSettings) will initialize the specified fields. --- src/Jellyfin.Networking/Manager/NetworkManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Jellyfin.Networking/Manager/NetworkManager.cs b/src/Jellyfin.Networking/Manager/NetworkManager.cs index b285b836bc..5a13cc4173 100644 --- a/src/Jellyfin.Networking/Manager/NetworkManager.cs +++ b/src/Jellyfin.Networking/Manager/NetworkManager.cs @@ -81,7 +81,6 @@ public class NetworkManager : INetworkManager, IDisposable /// The instance. /// The instance holding startup parameters. /// Logger to use for messages. -#pragma warning disable CS8618 // Non-nullable field is uninitialized. : Values are set in UpdateSettings function. Compiler doesn't yet recognise this. public NetworkManager(IConfigurationManager configurationManager, IConfiguration startupConfig, ILogger logger) { ArgumentNullException.ThrowIfNull(logger); @@ -109,7 +108,6 @@ public class NetworkManager : INetworkManager, IDisposable _configurationManager.NamedConfigurationUpdated += ConfigurationUpdated; } -#pragma warning restore CS8618 // Non-nullable field is uninitialized. /// /// Event triggered on network changes. @@ -312,6 +310,7 @@ public class NetworkManager : INetworkManager, IDisposable /// /// Initializes internal LAN cache. /// + [MemberNotNull(nameof(_lanSubnets), nameof(_excludedSubnets))] private void InitializeLan(NetworkConfiguration config) { lock (_initLock) @@ -591,6 +590,7 @@ public class NetworkManager : INetworkManager, IDisposable /// Reloads all settings and re-Initializes the instance. /// /// The to use. + [MemberNotNull(nameof(_lanSubnets), nameof(_excludedSubnets))] public void UpdateSettings(object configuration) { ArgumentNullException.ThrowIfNull(configuration);