Forráskód Böngészése

Code Clean up: Convert to null-coalescing operator ?? (#5845)

Co-authored-by: Cody Robibero <cody@robibe.ro>
Co-authored-by: Patrick Barron <18354464+barronpm@users.noreply.github.com>
BaronGreenback 4 éve
szülő
commit
2e98de9062
27 módosított fájl, 60 hozzáadás és 200 törlés
  1. 2 8
      Emby.Server.Implementations/ApplicationHost.cs
  2. 3 12
      Emby.Server.Implementations/Dto/DtoService.cs
  3. 1 4
      Emby.Server.Implementations/Library/LibraryManager.cs
  4. 3 11
      Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
  5. 3 7
      Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
  6. 2 5
      Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
  7. 3 12
      Emby.Server.Implementations/LiveTv/LiveTvManager.cs
  8. 1 4
      Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
  9. 2 11
      Emby.Server.Implementations/Plugins/PluginManager.cs
  10. 1 6
      Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
  11. 1 4
      Emby.Server.Implementations/Session/SessionManager.cs
  12. 1 6
      Jellyfin.Api/Controllers/PluginsController.cs
  13. 1 4
      Jellyfin.Api/Controllers/SearchController.cs
  14. 1 4
      Jellyfin.Api/Helpers/StreamingHelpers.cs
  15. 1 4
      MediaBrowser.Common/Net/IPHost.cs
  16. 1 4
      MediaBrowser.Common/Plugins/BasePluginOfT.cs
  17. 8 18
      MediaBrowser.Controller/Entities/BaseItem.cs
  18. 1 4
      MediaBrowser.Controller/Entities/UserView.cs
  19. 1 4
      MediaBrowser.Controller/Library/ItemResolveArgs.cs
  20. 1 4
      MediaBrowser.Controller/Playlists/Playlist.cs
  21. 1 4
      MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
  22. 6 10
      MediaBrowser.Controller/Providers/MetadataResult.cs
  23. 11 34
      MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
  24. 1 4
      MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
  25. 1 4
      MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
  26. 1 4
      MediaBrowser.Providers/Subtitles/SubtitleManager.cs
  27. 1 4
      RSSDP/SsdpCommunicationsServer.cs

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

@@ -335,10 +335,7 @@ namespace Emby.Server.Implementations
         {
             get
             {
-                if (_deviceId == null)
-                {
-                    _deviceId = new DeviceId(ApplicationPaths, LoggerFactory);
-                }
+                _deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
 
                 return _deviceId.Value;
             }
@@ -370,10 +367,7 @@ namespace Emby.Server.Implementations
         /// <returns>System.Object.</returns>
         protected object CreateInstanceSafe(Type type)
         {
-            if (_creatingInstances == null)
-            {
-                _creatingInstances = new List<Type>();
-            }
+            _creatingInstances ??= new List<Type>();
 
             if (_creatingInstances.IndexOf(type) != -1)
             {

+ 3 - 12
Emby.Server.Implementations/Dto/DtoService.cs

@@ -665,10 +665,7 @@ namespace Emby.Server.Implementations.Dto
             var tag = GetImageCacheTag(item, image);
             if (!string.IsNullOrEmpty(image.BlurHash))
             {
-                if (dto.ImageBlurHashes == null)
-                {
-                    dto.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
-                }
+                dto.ImageBlurHashes ??= new Dictionary<ImageType, Dictionary<string, string>>();
 
                 if (!dto.ImageBlurHashes.ContainsKey(image.Type))
                 {
@@ -702,10 +699,7 @@ namespace Emby.Server.Implementations.Dto
 
             if (hashes.Count > 0)
             {
-                if (dto.ImageBlurHashes == null)
-                {
-                    dto.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
-                }
+                dto.ImageBlurHashes ??= new Dictionary<ImageType, Dictionary<string, string>>();
 
                 dto.ImageBlurHashes[imageType] = hashes;
             }
@@ -898,10 +892,7 @@ namespace Emby.Server.Implementations.Dto
                     dto.Taglines = new string[] { item.Tagline };
                 }
 
-                if (dto.Taglines == null)
-                {
-                    dto.Taglines = Array.Empty<string>();
-                }
+                dto.Taglines ??= Array.Empty<string>();
             }
 
             dto.Type = item.GetBaseItemKind();

+ 1 - 4
Emby.Server.Implementations/Library/LibraryManager.cs

@@ -176,10 +176,7 @@ namespace Emby.Server.Implementations.Library
                 {
                     lock (_rootFolderSyncLock)
                     {
-                        if (_rootFolder == null)
-                        {
-                            _rootFolder = CreateRootFolder();
-                        }
+                        _rootFolder ??= CreateRootFolder();
                     }
                 }
 

+ 3 - 11
Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs

@@ -35,14 +35,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
                 return null;
             }
 
-            var season = parent as Season;
-
             // Just in case the user decided to nest episodes.
             // Not officially supported but in some cases we can handle it.
-            if (season == null)
-            {
-                season = parent.GetParents().OfType<Season>().FirstOrDefault();
-            }
+
+            var season = parent as Season ?? parent.GetParents().OfType<Season>().FirstOrDefault();
 
             // If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something
             // Also handle flat tv folders
@@ -55,11 +51,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
 
                 if (episode != null)
                 {
-                    var series = parent as Series;
-                    if (series == null)
-                    {
-                        series = parent.GetParents().OfType<Series>().FirstOrDefault();
-                    }
+                    var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault();
 
                     if (series != null)
                     {

+ 3 - 7
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -2237,14 +2237,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             var enabledTimersForSeries = new List<TimerInfo>();
             foreach (var timer in allTimers)
             {
-                var existingTimer = _timerProvider.GetTimer(timer.Id);
-
-                if (existingTimer == null)
-                {
-                    existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId)
+                var existingTimer = _timerProvider.GetTimer(timer.Id) 
+                    ?? (string.IsNullOrWhiteSpace(timer.ProgramId)
                         ? null
-                        : _timerProvider.GetTimerByProgramId(timer.ProgramId);
-                }
+                        : _timerProvider.GetTimerByProgramId(timer.ProgramId));
 
                 if (existingTimer == null)
                 {

+ 2 - 5
Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -787,14 +787,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             {
                 var channelNumber = GetChannelNumber(channel);
 
-                var station = allStations.Find(item => string.Equals(item.stationID, channel.stationID, StringComparison.OrdinalIgnoreCase));
-                if (station == null)
-                {
-                    station = new ScheduleDirect.Station
+                var station = allStations.Find(item => string.Equals(item.stationID, channel.stationID, StringComparison.OrdinalIgnoreCase)) 
+                    ?? new ScheduleDirect.Station
                     {
                         stationID = channel.stationID
                     };
-                }
 
                 var channelInfo = new ChannelInfo
                 {

+ 3 - 12
Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -987,10 +987,7 @@ namespace Emby.Server.Implementations.LiveTv
                 var externalProgramId = programTuple.Item2;
                 string externalSeriesId = programTuple.Item3;
 
-                if (timerList == null)
-                {
-                    timerList = (await GetTimersInternal(new TimerQuery(), cancellationToken).ConfigureAwait(false)).Items;
-                }
+                timerList ??= (await GetTimersInternal(new TimerQuery(), cancellationToken).ConfigureAwait(false)).Items;
 
                 var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, externalProgramId, StringComparison.OrdinalIgnoreCase));
                 var foundSeriesTimer = false;
@@ -1018,10 +1015,7 @@ namespace Emby.Server.Implementations.LiveTv
                     continue;
                 }
 
-                if (seriesTimerList == null)
-                {
-                    seriesTimerList = (await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false)).Items;
-                }
+                seriesTimerList ??= (await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false)).Items;
 
                 var seriesTimer = seriesTimerList.FirstOrDefault(i => string.Equals(i.SeriesId, externalSeriesId, StringComparison.OrdinalIgnoreCase));
 
@@ -1974,10 +1968,7 @@ namespace Emby.Server.Implementations.LiveTv
                 };
             }
 
-            if (service == null)
-            {
-                service = _services[0];
-            }
+            service ??= _services[0];
 
             var info = await service.GetNewTimerDefaultsAsync(cancellationToken, programInfo).ConfigureAwait(false);
 

+ 1 - 4
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs

@@ -421,10 +421,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
 
             string audioCodec = channelInfo.AudioCodec;
 
-            if (!videoBitrate.HasValue)
-            {
-                videoBitrate = isHd ? 15000000 : 2000000;
-            }
+            videoBitrate ??= isHd ? 15000000 : 2000000;
 
             int? audioBitrate = isHd ? 448000 : 192000;
 

+ 2 - 11
Emby.Server.Implementations/Plugins/PluginManager.cs

@@ -44,12 +44,7 @@ namespace Emby.Server.Implementations.Plugins
         {
             get
             {
-                if (_httpClientFactory == null)
-                {
-                    _httpClientFactory = _appHost.Resolve<IHttpClientFactory>();
-                }
-
-                return _httpClientFactory;
+                return _httpClientFactory ?? (_httpClientFactory = _appHost.Resolve<IHttpClientFactory>());
             }
         }
 
@@ -276,11 +271,7 @@ namespace Emby.Server.Implementations.Plugins
                 // If no version is given, return the current instance.
                 var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
 
-                plugin = plugins.FirstOrDefault(p => p.Instance != null);
-                if (plugin == null)
-                {
-                    plugin = plugins.OrderByDescending(p => p.Version).FirstOrDefault();
-                }
+                plugin = plugins.FirstOrDefault(p => p.Instance != null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
             }
             else
             {

+ 1 - 6
Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs

@@ -301,12 +301,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
         {
             get
             {
-                if (_id == null)
-                {
-                    _id = ScheduledTask.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture);
-                }
-
-                return _id;
+                return _id ??= ScheduledTask.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture);
             }
         }
 

+ 1 - 4
Emby.Server.Implementations/Session/SessionManager.cs

@@ -1475,10 +1475,7 @@ namespace Emby.Server.Implementations.Session
                 user = _userManager.GetUserById(request.UserId);
             }
 
-            if (user == null)
-            {
-                user = _userManager.GetUserByName(request.Username);
-            }
+            user ??= _userManager.GetUserByName(request.Username);
 
             if (enforcePassword)
             {

+ 1 - 6
Jellyfin.Api/Controllers/PluginsController.cs

@@ -207,12 +207,7 @@ namespace Jellyfin.Api.Controllers
             var plugins = _pluginManager.Plugins.Where(p => p.Id.Equals(pluginId));
 
             // Select the un-instanced one first.
-            var plugin = plugins.FirstOrDefault(p => p.Instance == null);
-            if (plugin == null)
-            {
-                // Then by the status.
-                plugin = plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
-            }
+            var plugin = plugins.FirstOrDefault(p => p.Instance == null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
 
             if (plugin != null)
             {

+ 1 - 4
Jellyfin.Api/Controllers/SearchController.cs

@@ -228,10 +228,7 @@ namespace Jellyfin.Api.Controllers
                 itemWithImage = GetParentWithImage<Series>(item, ImageType.Thumb);
             }
 
-            if (itemWithImage == null)
-            {
-                itemWithImage = GetParentWithImage<BaseItem>(item, ImageType.Thumb);
-            }
+            itemWithImage ??= GetParentWithImage<BaseItem>(item, ImageType.Thumb);
 
             if (itemWithImage != null)
             {

+ 1 - 4
Jellyfin.Api/Helpers/StreamingHelpers.cs

@@ -292,10 +292,7 @@ namespace Jellyfin.Api.Helpers
                 }
             }
 
-            if (profile == null)
-            {
-                profile = dlnaManager.GetDefaultProfile();
-            }
+            profile ??= dlnaManager.GetDefaultProfile();
 
             var audioCodec = state.ActualOutputAudioCodec;
 

+ 1 - 4
MediaBrowser.Common/Net/IPHost.cs

@@ -400,10 +400,7 @@ namespace MediaBrowser.Common.Net
         private bool ResolveHost()
         {
             // When was the last time we resolved?
-            if (_lastResolved == null)
-            {
-                _lastResolved = DateTime.UtcNow;
-            }
+            _lastResolved ??= DateTime.UtcNow;
 
             // If we haven't resolved before, or our timer has run out...
             if ((_addresses.Length == 0 && !Resolved) || (DateTime.UtcNow > _lastResolved.Value.AddMinutes(Timeout)))

+ 1 - 4
MediaBrowser.Common/Plugins/BasePluginOfT.cs

@@ -105,10 +105,7 @@ namespace MediaBrowser.Common.Plugins
                 {
                     lock (_configurationSyncLock)
                     {
-                        if (_configuration == null)
-                        {
-                            _configuration = LoadConfiguration();
-                        }
+                        _configuration ??= LoadConfiguration();
                     }
                 }
 

+ 8 - 18
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -106,15 +106,10 @@ namespace MediaBrowser.Controller.Entities
         {
             get
             {
-                if (_themeSongIds == null)
-                {
-                    _themeSongIds = GetExtras()
-                        .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeSong)
-                        .Select(song => song.Id)
-                        .ToArray();
-                }
-
-                return _themeSongIds;
+                return _themeSongIds ??= GetExtras()
+                    .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeSong)
+                    .Select(song => song.Id)
+                    .ToArray();
             }
 
             private set
@@ -128,15 +123,10 @@ namespace MediaBrowser.Controller.Entities
         {
             get
             {
-                if (_themeVideoIds == null)
-                {
-                    _themeVideoIds = GetExtras()
-                        .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeVideo)
-                        .Select(song => song.Id)
-                        .ToArray();
-                }
-
-                return _themeVideoIds;
+                return _themeVideoIds ??= GetExtras()
+                    .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeVideo)
+                    .Select(song => song.Id)
+                    .ToArray();
             }
 
             private set

+ 1 - 4
MediaBrowser.Controller/Entities/UserView.cs

@@ -75,10 +75,7 @@ namespace MediaBrowser.Controller.Entities
 
         public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
         {
-            if (query == null)
-            {
-                query = new InternalItemsQuery(user);
-            }
+            query ??= new InternalItemsQuery(user);
 
             query.EnableTotalRecordCount = false;
             var result = GetItemList(query);

+ 1 - 4
MediaBrowser.Controller/Library/ItemResolveArgs.cs

@@ -147,10 +147,7 @@ namespace MediaBrowser.Controller.Library
                 throw new ArgumentException("The path was empty or null.", nameof(path));
             }
 
-            if (AdditionalLocations == null)
-            {
-                AdditionalLocations = new List<string>();
-            }
+            AdditionalLocations ??= new List<string>();
 
             AdditionalLocations.Add(path);
         }

+ 1 - 4
MediaBrowser.Controller/Playlists/Playlist.cs

@@ -126,10 +126,7 @@ namespace MediaBrowser.Controller.Playlists
 
         private List<BaseItem> GetPlayableItems(User user, InternalItemsQuery query)
         {
-            if (query == null)
-            {
-                query = new InternalItemsQuery(user);
-            }
+            query ??= new InternalItemsQuery(user);
 
             query.IsFolder = false;
 

+ 1 - 4
MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs

@@ -45,10 +45,7 @@ namespace MediaBrowser.Controller.Providers
 
             if (copy.RefreshPaths != null && copy.RefreshPaths.Length > 0)
             {
-                if (RefreshPaths == null)
-                {
-                    RefreshPaths = Array.Empty<string>();
-                }
+                RefreshPaths ??= Array.Empty<string>();
 
                 RefreshPaths = copy.RefreshPaths.ToArray();
             }

+ 6 - 10
MediaBrowser.Controller/Providers/MetadataResult.cs

@@ -37,10 +37,7 @@ namespace MediaBrowser.Controller.Providers
 
         public void AddPerson(PersonInfo p)
         {
-            if (People == null)
-            {
-                People = new List<PersonInfo>();
-            }
+            People ??= new List<PersonInfo>();
 
             PeopleHelper.AddPerson(People, p);
         }
@@ -54,16 +51,15 @@ namespace MediaBrowser.Controller.Providers
             {
                 People = new List<PersonInfo>();
             }
-
-            People.Clear();
+            else
+            {
+                People.Clear();
+            }
         }
 
         public UserItemData GetOrAddUserData(string userId)
         {
-            if (UserDataList == null)
-            {
-                UserDataList = new List<UserItemData>();
-            }
+            UserDataList ??= new List<UserItemData>();
 
             UserItemData userData = null;
 

+ 11 - 34
MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs

@@ -1187,43 +1187,28 @@ namespace MediaBrowser.MediaEncoding.Probing
             FetchStudios(audio, tags, "label");
 
             // These support mulitple values, but for now we only store the first.
-            var mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id"));
-            if (mb == null)
-            {
-                mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID"));
-            }
+            var mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id"))
+                ?? GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID"));
 
             audio.SetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 
-            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id"));
-            if (mb == null)
-            {
-                mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID"));
-            }
+            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id"))
+                ?? GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID"));
 
             audio.SetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 
-            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id"));
-            if (mb == null)
-            {
-                mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID"));
-            }
+            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id"))
+                ?? GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID"));
 
             audio.SetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 
-            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"));
-            if (mb == null)
-            {
-                mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID"));
-            }
+            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"))
+                ?? GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID"));
 
             audio.SetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 
-            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id"));
-            if (mb == null)
-            {
-                mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID"));
-            }
+            mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id"))
+                ?? GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID"));
 
             audio.SetProviderId(MetadataProvider.MusicBrainzTrack, mb);
         }
@@ -1290,15 +1275,7 @@ namespace MediaBrowser.MediaEncoding.Probing
 
         private IEnumerable<string> GetSplitWhitelist()
         {
-            if (_splitWhiteList == null)
-            {
-                _splitWhiteList = new List<string>
-                        {
-                            "AC/DC"
-                        };
-            }
-
-            return _splitWhiteList;
+            return _splitWhiteList ??= new List<string> { "AC/DC" };
         }
 
         /// <summary>

+ 1 - 4
MediaBrowser.Model/Entities/ProviderIdsExtensions.cs

@@ -123,10 +123,7 @@ namespace MediaBrowser.Model.Entities
             else
             {
                 // Ensure it exists
-                if (instance.ProviderIds == null)
-                {
-                    instance.ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
-                }
+                instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 
                 instance.ProviderIds[name] = value;
             }

+ 1 - 4
MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs

@@ -111,10 +111,7 @@ namespace MediaBrowser.Providers.MediaInfo
                     }
                 }
 
-                if (streamFileNames == null)
-                {
-                    streamFileNames = Array.Empty<string>();
-                }
+                streamFileNames ??= Array.Empty<string>();
 
                 mediaInfoResult = await GetMediaInfo(item, cancellationToken).ConfigureAwait(false);
 

+ 1 - 4
MediaBrowser.Providers/Subtitles/SubtitleManager.cs

@@ -256,10 +256,7 @@ namespace MediaBrowser.Providers.Subtitles
                 }
                 catch (Exception ex)
                 {
-                    if (exceptionToThrow == null)
-                    {
-                        exceptionToThrow = ex;
-                    }
+                    exceptionToThrow ??= ex;
                 }
                 finally
                 {

+ 1 - 4
RSSDP/SsdpCommunicationsServer.cs

@@ -415,10 +415,7 @@ namespace Rssdp.Infrastructure
             {
                 lock (_SendSocketSynchroniser)
                 {
-                    if (_sendSockets == null)
-                    {
-                        _sendSockets = CreateSocketAndListenForResponsesAsync();
-                    }
+                    _sendSockets ??= CreateSocketAndListenForResponsesAsync();
                 }
             }
         }