فهرست منبع

Fix always null expressions

Bond_009 6 سال پیش
والد
کامیت
8af256f9c2

+ 1 - 2
Emby.Dlna/ContentDirectory/ContentDirectory.cs

@@ -76,7 +76,6 @@ namespace Emby.Dlna.ContentDirectory
                           _dlna.GetDefaultProfile();
 
             var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));
-            string accessToken = null;
 
             var user = GetUser(profile);
 
@@ -85,7 +84,7 @@ namespace Emby.Dlna.ContentDirectory
                 _libraryManager,
                 profile,
                 serverAddress,
-                accessToken,
+                null,
                 _imageProcessor,
                 _userDataManager,
                 user,

+ 3 - 7
Emby.Dlna/PlayTo/PlayToManager.cs

@@ -162,9 +162,7 @@ namespace Emby.Dlna.PlayTo
                 uuid = location.GetMD5().ToString("N");
             }
 
-            string deviceName = null;
-
-            var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, deviceName, uri.OriginalString, null);
+            var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, null, uri.OriginalString, null);
 
             var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
 
@@ -172,7 +170,7 @@ namespace Emby.Dlna.PlayTo
             {
                 var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false);
 
-                deviceName = device.Properties.Name;
+                string deviceName = device.Properties.Name;
 
                 _sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);
 
@@ -186,8 +184,6 @@ namespace Emby.Dlna.PlayTo
                     serverAddress = _appHost.GetLocalApiUrl(info.LocalIpAddress);
                 }
 
-                string accessToken = null;
-
                 controller = new PlayToController(sessionInfo,
                    _sessionManager,
                    _libraryManager,
@@ -196,7 +192,7 @@ namespace Emby.Dlna.PlayTo
                    _userManager,
                    _imageProcessor,
                    serverAddress,
-                   accessToken,
+                   null,
                    _deviceDiscovery,
                    _userDataManager,
                    _localization,

+ 1 - 1
Emby.Naming/AudioBook/AudioBookResolver.cs

@@ -36,7 +36,7 @@ namespace Emby.Naming.AudioBook
                 return null;
             }
 
-            var extension = Path.GetExtension(path) ?? string.Empty;
+            var extension = Path.GetExtension(path);
             // Check supported extensions
             if (!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
             {

+ 1 - 2
Emby.Server.Implementations/ApplicationHost.cs

@@ -466,9 +466,8 @@ namespace Emby.Server.Implementations
         private static Tuple<Assembly, string> GetAssembly(Type type)
         {
             var assembly = type.GetTypeInfo().Assembly;
-            string path = null;
 
-            return new Tuple<Assembly, string>(assembly, path);
+            return new Tuple<Assembly, string>(assembly, null);
         }
 
         public virtual IStreamHelper CreateStreamHelper()

+ 33 - 36
Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs

@@ -1005,7 +1005,7 @@ namespace Emby.XmlTv.Classes
             }
         }
 
-        public static Regex _regDateWithOffset = new Regex(@"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$");
+        public const string _regDateWithOffset = @"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$";
 
         public DateTimeOffset? ParseDate(string dateValue)
         {
@@ -1018,50 +1018,47 @@ namespace Emby.XmlTv.Classes
             '200007281733 BST', '200209', '19880523083000 +0300'.  (BST == +0100.)
             */
 
-            DateTimeOffset? result = null;
-
-            if (!string.IsNullOrEmpty(dateValue))
+            if (string.IsNullOrEmpty(dateValue))
             {
-                var completeDate = "20000101000000";
-                var dateComponent = string.Empty;
-                var dateOffset = "+00:00";
+                return null;
+            }
 
-                var match = _regDateWithOffset.Match(dateValue);
-                if (match.Success)
+            var completeDate = "20000101000000";
+            var dateComponent = string.Empty;
+            var dateOffset = "+00:00";
+            var match = Regex.Match(dateValue, _regDateWithOffset);
+            if (match.Success)
+            {
+                dateComponent = match.Groups["dateDigits"].Value;
+                if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value))
                 {
-                    dateComponent = match.Groups["dateDigits"].Value;
-                    if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value))
+                    dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later
+                    if (dateOffset.Length == 5)
                     {
-                        dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later
-                        if (dateOffset.Length == 5)
-                        {
-                            dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later
-                        }
-                        else
-                        {
-                            dateOffset = "+00:00";
-                        }
+                        dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later
+                    }
+                    else
+                    {
+                        dateOffset = "+00:00";
                     }
                 }
+            }
 
-                // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000
-                if (dateComponent.Length < 14)
-                {
-                    dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length);
-                }
+            // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000
+            if (dateComponent.Length < 14)
+            {
+                dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length);
+            }
 
-                var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);
-                if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parsedDateTime))
-                {
-                    return parsedDateTime.ToUniversalTime();
-                }
-                else
-                {
-                    //Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);
-                }
+            var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);
+            if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTimeOffset parsedDateTime))
+            {
+                return parsedDateTime.ToUniversalTime();
             }
 
-            return result;
+            // Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);
+
+            return null;
         }
 
         public string StandardiseDate(string value)
@@ -1070,7 +1067,7 @@ namespace Emby.XmlTv.Classes
             var dateComponent = string.Empty;
             var dateOffset = "+0000";
 
-            var match = _regDateWithOffset.Match(value);
+            var match = Regex.Match(value, _regDateWithOffset);
             if (match.Success)
             {
                 dateComponent = match.Groups["dateDigits"].Value;

+ 1 - 1
MediaBrowser.Controller/Entities/UserViewBuilder.cs

@@ -508,7 +508,7 @@ namespace MediaBrowser.Controller.Entities
 
             if (query.IsLiked.HasValue)
             {
-                userData = userData ?? userDataManager.GetUserData(user, item);
+                userData = userDataManager.GetUserData(user, item);
 
                 if (!userData.Likes.HasValue || userData.Likes != query.IsLiked.Value)
                 {

+ 2 - 4
MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs

@@ -510,13 +510,11 @@ namespace MediaBrowser.Providers.Music
             return new ValueTuple<string, string>();
         }
 
-        private static ValueTuple<string, string> ParseArtistNameCredit(XmlReader reader)
+        private static (string, string) ParseArtistNameCredit(XmlReader reader)
         {
             reader.MoveToContent();
             reader.Read();
 
-            string name = null;
-
             // http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
 
             // Loop through each element
@@ -547,7 +545,7 @@ namespace MediaBrowser.Providers.Music
                 }
             }
 
-            return new ValueTuple<string, string>(name, null);
+            return (null, null);
         }
 
         private static ValueTuple<string, string> ParseArtistArtistCredit(XmlReader reader, string artistId)