Преглед изворни кода

Enable nullability for ServerDiscoveryInfo (#5804)

Cody Robibero пре 4 година
родитељ
комит
b63f615fd4

+ 1 - 6
Emby.Server.Implementations/Udp/UdpServer.cs

@@ -53,12 +53,7 @@ namespace Emby.Server.Implementations.Udp
 
             if (!string.IsNullOrEmpty(localUrl))
             {
-                var response = new ServerDiscoveryInfo
-                {
-                    Address = localUrl,
-                    Id = _appHost.SystemId,
-                    Name = _appHost.FriendlyName
-                };
+                var response = new ServerDiscoveryInfo(localUrl, _appHost.SystemId, _appHost.FriendlyName);
 
                 try
                 {

+ 26 - 15
MediaBrowser.Model/ApiClient/ServerDiscoveryInfo.cs

@@ -1,32 +1,43 @@
-#nullable disable
-#pragma warning disable CS1591
-
 namespace MediaBrowser.Model.ApiClient
 {
+    /// <summary>
+    /// The server discovery info model.
+    /// </summary>
     public class ServerDiscoveryInfo
     {
         /// <summary>
-        /// Gets or sets the address.
+        /// Initializes a new instance of the <see cref="ServerDiscoveryInfo"/> class.
+        /// </summary>
+        /// <param name="address">The server address.</param>
+        /// <param name="id">The server id.</param>
+        /// <param name="name">The server name.</param>
+        /// <param name="endpointAddress">The endpoint address.</param>
+        public ServerDiscoveryInfo(string address, string id, string name, string? endpointAddress = null)
+        {
+            Address = address;
+            Id = id;
+            Name = name;
+            EndpointAddress = endpointAddress;
+        }
+
+        /// <summary>
+        /// Gets the address.
         /// </summary>
-        /// <value>The address.</value>
-        public string Address { get; set; }
+        public string Address { get; }
 
         /// <summary>
-        /// Gets or sets the server identifier.
+        /// Gets the server identifier.
         /// </summary>
-        /// <value>The server identifier.</value>
-        public string Id { get; set; }
+        public string Id { get; }
 
         /// <summary>
-        /// Gets or sets the name.
+        /// Gets the name.
         /// </summary>
-        /// <value>The name.</value>
-        public string Name { get; set; }
+        public string Name { get; }
 
         /// <summary>
-        /// Gets or sets the endpoint address.
+        /// Gets the endpoint address.
         /// </summary>
-        /// <value>The endpoint address.</value>
-        public string EndpointAddress { get; set; }
+        public string? EndpointAddress { get; }
     }
 }