diff options
206 files changed, 627 insertions, 627 deletions
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 8e3a335c6..e2e3b2d8b 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -191,7 +191,7 @@ namespace Emby.Dlna.Didl private void AddVideoResource(XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo streamInfo = null) { - if (streamInfo == null) + if (streamInfo is null) { var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user); @@ -263,7 +263,7 @@ namespace Emby.Dlna.Didl .FirstOrDefault(i => string.Equals(info.Format, i.Format, StringComparison.OrdinalIgnoreCase) && i.Method == SubtitleDeliveryMethod.External); - if (subtitleProfile == null) + if (subtitleProfile is null) { return false; } @@ -392,7 +392,7 @@ namespace Emby.Dlna.Didl var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal)); - var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType) + var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType) ? MimeTypes.GetMimeType(filename) : mediaProfile.MimeType; @@ -533,7 +533,7 @@ namespace Emby.Dlna.Didl { writer.WriteStartElement(string.Empty, "res", NsDidl); - if (streamInfo == null) + if (streamInfo is null) { var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user); @@ -598,7 +598,7 @@ namespace Emby.Dlna.Didl var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal)); - var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType) + var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType) ? MimeTypes.GetMimeType(filename) : mediaProfile.MimeType; @@ -695,7 +695,7 @@ namespace Emby.Dlna.Didl } // Not a samsung device - if (secAttribute == null) + if (secAttribute is null) { return; } @@ -909,7 +909,7 @@ namespace Emby.Dlna.Didl AddValue(writer, "dc", "creator", artist, NsDc); // If it doesn't support album artists (musicvideo), then tag as both - if (hasAlbumArtists == null) + if (hasAlbumArtists is null) { AddAlbumArtist(writer, artist); } @@ -973,7 +973,7 @@ namespace Emby.Dlna.Didl { ImageDownloadInfo imageInfo = GetImageInfo(item); - if (imageInfo == null) + if (imageInfo is null) { return; } @@ -1036,7 +1036,7 @@ namespace Emby.Dlna.Didl { var imageInfo = GetImageInfo(item); - if (imageInfo == null) + if (imageInfo is null) { return; } @@ -1116,7 +1116,7 @@ namespace Emby.Dlna.Didl private BaseItem GetFirstParentWithImageBelowUserRoot(BaseItem item) { - if (item == null) + if (item is null) { return null; } diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index 2ea2c130f..31b999f64 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -107,7 +107,7 @@ namespace Emby.Dlna var profile = GetProfiles() .FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification)); - if (profile == null) + if (profile is null) { _logger.LogInformation("No matching device profile found. The default will need to be used. \n{@Profile}", deviceInfo); } @@ -172,7 +172,7 @@ namespace Emby.Dlna ArgumentNullException.ThrowIfNull(headers); var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification)); - if (profile == null) + if (profile is null) { _logger.LogDebug("No matching device profile found. {@Headers}", headers); } @@ -272,7 +272,7 @@ namespace Emby.Dlna var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase)); - if (info == null) + if (info is null) { return null; } @@ -470,7 +470,7 @@ namespace Emby.Dlna var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant(); var stream = _assembly.GetManifestResourceStream(resource); - if (stream == null) + if (stream is null) { return null; } diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index 15021c19d..bcd7ece08 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -199,7 +199,7 @@ namespace Emby.Dlna.Main { try { - if (_communicationsServer == null) + if (_communicationsServer is null) { var enableMultiSocketBinding = OperatingSystem.IsWindows() || OperatingSystem.IsLinux(); diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index 34981bd3f..1c7730187 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -220,14 +220,14 @@ namespace Emby.Dlna.PlayTo var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetMute"); - if (command == null) + if (command is null) { return false; } var service = GetServiceRenderingControl(); - if (service == null) + if (service is null) { return false; } @@ -260,14 +260,14 @@ namespace Emby.Dlna.PlayTo var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume"); - if (command == null) + if (command is null) { return; } var service = GetServiceRenderingControl(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } @@ -291,14 +291,14 @@ namespace Emby.Dlna.PlayTo var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Seek"); - if (command == null) + if (command is null) { return; } var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } @@ -324,7 +324,7 @@ namespace Emby.Dlna.PlayTo _logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header); var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI"); - if (command == null) + if (command is null) { return; } @@ -337,7 +337,7 @@ namespace Emby.Dlna.PlayTo var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } @@ -381,7 +381,7 @@ namespace Emby.Dlna.PlayTo _logger.LogDebug("{PropertyName} - SetNextAvTransport Uri: {Url} DlnaHeaders: {Header}", Properties.Name, url, header); var command = avCommands.ServiceActions.FirstOrDefault(c => string.Equals(c.Name, "SetNextAVTransportURI", StringComparison.OrdinalIgnoreCase)); - if (command == null) + if (command is null) { return; } @@ -394,7 +394,7 @@ namespace Emby.Dlna.PlayTo var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } @@ -418,13 +418,13 @@ namespace Emby.Dlna.PlayTo private Task SetPlay(TransportCommands avCommands, CancellationToken cancellationToken) { var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Play"); - if (command == null) + if (command is null) { return Task.CompletedTask; } var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } @@ -440,7 +440,7 @@ namespace Emby.Dlna.PlayTo public async Task SetPlay(CancellationToken cancellationToken) { var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); - if (avCommands == null) + if (avCommands is null) { return; } @@ -455,7 +455,7 @@ namespace Emby.Dlna.PlayTo var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Stop"); - if (command == null) + if (command is null) { return; } @@ -479,7 +479,7 @@ namespace Emby.Dlna.PlayTo var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Pause"); - if (command == null) + if (command is null) { return; } @@ -513,7 +513,7 @@ namespace Emby.Dlna.PlayTo var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); - if (avCommands == null) + if (avCommands is null) { return; } @@ -538,7 +538,7 @@ namespace Emby.Dlna.PlayTo var currentObject = tuple.Track; - if (tuple.Success && currentObject == null) + if (tuple.Success && currentObject is null) { currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false); } @@ -607,14 +607,14 @@ namespace Emby.Dlna.PlayTo var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetVolume"); - if (command == null) + if (command is null) { return; } var service = GetServiceRenderingControl(); - if (service == null) + if (service is null) { return; } @@ -626,7 +626,7 @@ namespace Emby.Dlna.PlayTo rendererCommands.BuildPost(command, service.ServiceType), cancellationToken: cancellationToken).ConfigureAwait(false); - if (result == null || result.Document == null) + if (result is null || result.Document is null) { return; } @@ -657,14 +657,14 @@ namespace Emby.Dlna.PlayTo var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetMute"); - if (command == null) + if (command is null) { return; } var service = GetServiceRenderingControl(); - if (service == null) + if (service is null) { return; } @@ -676,7 +676,7 @@ namespace Emby.Dlna.PlayTo rendererCommands.BuildPost(command, service.ServiceType), cancellationToken: cancellationToken).ConfigureAwait(false); - if (result == null || result.Document == null) + if (result is null || result.Document is null) { return; } @@ -691,13 +691,13 @@ namespace Emby.Dlna.PlayTo private async Task<TransportState?> GetTransportInfo(TransportCommands avCommands, CancellationToken cancellationToken) { var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetTransportInfo"); - if (command == null) + if (command is null) { return null; } var service = GetAvTransportService(); - if (service == null) + if (service is null) { return null; } @@ -709,7 +709,7 @@ namespace Emby.Dlna.PlayTo avCommands.BuildPost(command, service.ServiceType), cancellationToken: cancellationToken).ConfigureAwait(false); - if (result == null || result.Document == null) + if (result is null || result.Document is null) { return null; } @@ -731,19 +731,19 @@ namespace Emby.Dlna.PlayTo private async Task<UBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken) { var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo"); - if (command == null) + if (command is null) { return null; } var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); - if (rendererCommands == null) + if (rendererCommands is null) { return null; } @@ -755,14 +755,14 @@ namespace Emby.Dlna.PlayTo rendererCommands.BuildPost(command, service.ServiceType), cancellationToken: cancellationToken).ConfigureAwait(false); - if (result == null || result.Document == null) + if (result is null || result.Document is null) { return null; } var track = result.Document.Descendants("CurrentURIMetaData").FirstOrDefault(); - if (track == null) + if (track is null) { return null; } @@ -778,7 +778,7 @@ namespace Emby.Dlna.PlayTo track = result.Document.Descendants("CurrentURI").FirstOrDefault(); - if (track == null) + if (track is null) { return null; } @@ -801,21 +801,21 @@ namespace Emby.Dlna.PlayTo private async Task<(bool Success, UBaseObject Track)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken) { var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo"); - if (command == null) + if (command is null) { return (false, null); } var service = GetAvTransportService(); - if (service == null) + if (service is null) { throw new InvalidOperationException("Unable to find service"); } var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); - if (rendererCommands == null) + if (rendererCommands is null) { return (false, null); } @@ -827,7 +827,7 @@ namespace Emby.Dlna.PlayTo rendererCommands.BuildPost(command, service.ServiceType), cancellationToken: cancellationToken).ConfigureAwait(false); - if (result == null || result.Document == null) + if (result is null || result.Document is null) { return (false, null); } @@ -858,7 +858,7 @@ namespace Emby.Dlna.PlayTo var track = result.Document.Descendants("TrackMetaData").FirstOrDefault(); - if (track == null) + if (track is null) { // If track is null, some vendors do this, use GetMediaInfo instead. return (true, null); @@ -882,7 +882,7 @@ namespace Emby.Dlna.PlayTo _logger.LogError(ex, "Uncaught exception while parsing xml"); } - if (uPnpResponse == null) + if (uPnpResponse is null) { _logger.LogError("Failed to parse xml: \n {Xml}", trackString); return (true, null); @@ -985,7 +985,7 @@ namespace Emby.Dlna.PlayTo } var avService = GetAvTransportService(); - if (avService == null) + if (avService is null) { return null; } @@ -995,7 +995,7 @@ namespace Emby.Dlna.PlayTo var httpClient = new DlnaHttpClient(_logger, _httpClientFactory); var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false); - if (document == null) + if (document is null) { return null; } @@ -1017,7 +1017,7 @@ namespace Emby.Dlna.PlayTo } var avService = GetServiceRenderingControl(); - if (avService == null) + if (avService is null) { throw new ArgumentException("Device AvService is null"); } @@ -1027,7 +1027,7 @@ namespace Emby.Dlna.PlayTo var httpClient = new DlnaHttpClient(_logger, _httpClientFactory); _logger.LogDebug("Dlna Device.GetRenderingProtocolAsync"); var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false); - if (document == null) + if (document is null) { return null; } @@ -1062,7 +1062,7 @@ namespace Emby.Dlna.PlayTo var ssdpHttpClient = new DlnaHttpClient(logger, httpClientFactory); var document = await ssdpHttpClient.GetDataAsync(url.ToString(), cancellationToken).ConfigureAwait(false); - if (document == null) + if (document is null) { return null; } @@ -1149,13 +1149,13 @@ namespace Emby.Dlna.PlayTo foreach (var services in document.Descendants(UPnpNamespaces.Ud.GetName("serviceList"))) { - if (services == null) + if (services is null) { continue; } var servicesList = services.Descendants(UPnpNamespaces.Ud.GetName("service")); - if (servicesList == null) + if (servicesList is null) { continue; } @@ -1212,14 +1212,14 @@ namespace Emby.Dlna.PlayTo var previousMediaInfo = CurrentMediaInfo; CurrentMediaInfo = mediaInfo; - if (mediaInfo == null) + if (mediaInfo is null) { if (previousMediaInfo != null) { OnPlaybackStop(previousMediaInfo); } } - else if (previousMediaInfo == null) + else if (previousMediaInfo is null) { if (state != TransportState.STOPPED) { diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 65367e24f..fca5fc2a0 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo } streamInfo = StreamParams.ParseFromUrl(e.NewMediaInfo.Url, _libraryManager, _mediaSourceManager); - if (streamInfo.Item == null) + if (streamInfo.Item is null) { return; } @@ -199,7 +199,7 @@ namespace Emby.Dlna.PlayTo { var streamInfo = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager); - if (streamInfo.Item == null) + if (streamInfo.Item is null) { return; } @@ -210,7 +210,7 @@ namespace Emby.Dlna.PlayTo var mediaSource = await streamInfo.GetMediaSource(CancellationToken.None).ConfigureAwait(false); - var duration = mediaSource == null + var duration = mediaSource is null ? _device.Duration?.Ticks : mediaSource.RunTimeTicks; @@ -865,7 +865,7 @@ namespace Emby.Dlna.PlayTo throw new ObjectDisposedException(GetType().Name); } - if (_device == null) + if (_device is null) { return Task.CompletedTask; } diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index 294bda5b6..f4a9a90af 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -176,10 +176,10 @@ namespace Emby.Dlna.PlayTo var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault(); - if (controller == null) + if (controller is null) { var device = await Device.CreateuPnpDeviceAsync(uri, _httpClientFactory, _logger, cancellationToken).ConfigureAwait(false); - if (device == null) + if (device is null) { _logger.LogError("Ignoring device as xml response is invalid."); return; diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs index 391dda147..bb58a5d1b 100644 --- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs +++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs @@ -71,7 +71,7 @@ namespace Emby.Dlna.Ssdp { lock (_syncLock) { - if (_listenerCount > 0 && _deviceLocator == null && _commsServer != null) + if (_listenerCount > 0 && _deviceLocator is null && _commsServer != null) { _deviceLocator = new SsdpDeviceLocator(_commsServer); @@ -97,7 +97,7 @@ namespace Emby.Dlna.Ssdp { var originalHeaders = e.DiscoveredDevice.ResponseHeaders; - var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase); + var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase); var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase); @@ -116,7 +116,7 @@ namespace Emby.Dlna.Ssdp { var originalHeaders = e.DiscoveredDevice.ResponseHeaders; - var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase); + var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase); var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase); diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 11256dafd..d2c430415 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -436,7 +436,7 @@ namespace Emby.Drawing /// <inheritdoc /> public string? GetImageCacheTag(User user) { - if (user.ProfileImage == null) + if (user.ProfileImage is null) { return null; } diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index 6e491185d..7a241aab2 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -75,7 +75,7 @@ namespace Emby.Naming.AudioBook foreach (var group in groupedBy) { - if (group.Key.ChapterNumber == null && group.Key.PartNumber == null) + if (group.Key.ChapterNumber is null && group.Key.PartNumber is null) { if (group.Count() > 1 || haveChaptersOrPages) { diff --git a/Emby.Naming/AudioBook/AudioBookNameParser.cs b/Emby.Naming/AudioBook/AudioBookNameParser.cs index 120482bc2..97b34199e 100644 --- a/Emby.Naming/AudioBook/AudioBookNameParser.cs +++ b/Emby.Naming/AudioBook/AudioBookNameParser.cs @@ -33,7 +33,7 @@ namespace Emby.Naming.AudioBook var match = new Regex(expression, RegexOptions.IgnoreCase).Match(name); if (match.Success) { - if (result.Name == null) + if (result.Name is null) { var value = match.Groups["name"]; if (value.Success) diff --git a/Emby.Naming/ExternalFiles/ExternalPathParser.cs b/Emby.Naming/ExternalFiles/ExternalPathParser.cs index 1fa4fa537..cfe3256e3 100644 --- a/Emby.Naming/ExternalFiles/ExternalPathParser.cs +++ b/Emby.Naming/ExternalFiles/ExternalPathParser.cs @@ -94,7 +94,7 @@ namespace Emby.Naming.ExternalFiles // Try to translate to three character code var culture = _localizationManager.FindLanguageInfo(currentSliceWithoutSeparator); - if (culture != null && pathInfo.Language == null) + if (culture != null && pathInfo.Language is null) { pathInfo.Language = culture.ThreeLetterISOLanguageName; extraString = extraString.Replace(currentSlice, string.Empty, StringComparison.OrdinalIgnoreCase); diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 11f82525f..1366bdb2c 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -26,7 +26,7 @@ namespace Emby.Naming.Video // Filter out all extras, otherwise they could cause stacks to not be resolved // See the unit test TestStackedWithTrailer var nonExtras = videoInfos - .Where(i => i.ExtraType == null) + .Where(i => i.ExtraType is null) .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory }); var stackResult = StackResolver.Resolve(nonExtras, namingOptions).ToList(); @@ -42,7 +42,7 @@ namespace Emby.Naming.Video continue; } - if (current.ExtraType == null) + if (current.ExtraType is null) { standaloneMedia.Add(current); } diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs index de8e177d8..858e9dd2f 100644 --- a/Emby.Naming/Video/VideoResolver.cs +++ b/Emby.Naming/Video/VideoResolver.cs @@ -87,7 +87,7 @@ namespace Emby.Naming.Video name = cleanDateTimeResult.Name; year = cleanDateTimeResult.Year; - if (extraResult.ExtraType == null + if (extraResult.ExtraType is null && TryCleanString(name, namingOptions, out var newName)) { name = newName; diff --git a/Emby.Notifications/NotificationEntryPoint.cs b/Emby.Notifications/NotificationEntryPoint.cs index 668c059b4..3763b1e92 100644 --- a/Emby.Notifications/NotificationEntryPoint.cs +++ b/Emby.Notifications/NotificationEntryPoint.cs @@ -141,7 +141,7 @@ namespace Emby.Notifications lock (_libraryChangedSyncLock) { - if (_libraryUpdateTimer == null) + if (_libraryUpdateTimer is null) { _libraryUpdateTimer = new Timer( LibraryUpdateTimerCallback, diff --git a/Emby.Notifications/NotificationManager.cs b/Emby.Notifications/NotificationManager.cs index ac90cc8ec..2b9d2c577 100644 --- a/Emby.Notifications/NotificationManager.cs +++ b/Emby.Notifications/NotificationManager.cs @@ -68,7 +68,7 @@ namespace Emby.Notifications var users = GetUserIds(request, options) .Select(i => _userManager.GetUserById(i)) - .Where(i => relatedItem == null || relatedItem.IsVisibleStandalone(i)) + .Where(i => relatedItem is null || relatedItem.IsVisibleStandalone(i)) .ToArray(); var title = request.Name; diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 26b4649dd..5876c9b4c 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.AppBase { IConfigurationFactory factory = Activator.CreateInstance<T>(); - if (_configurationFactories == null) + if (_configurationFactories is null) { _configurationFactories = new[] { factory }; } @@ -306,7 +306,7 @@ namespace Emby.Server.Implementations.AppBase configurationManager._configurationStores, i => string.Equals(i.Key, k, StringComparison.OrdinalIgnoreCase)); - if (configurationInfo == null) + if (configurationInfo is null) { throw new ResourceNotFoundException("Configuration with key " + k + " not found."); } diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index f923e59ef..1c8477605 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -43,7 +43,7 @@ namespace Emby.Server.Implementations.AppBase Span<byte> newBytes = stream.GetBuffer().AsSpan(0, (int)stream.Length); // If the file didn't exist before, or if something has changed, re-save - if (buffer == null || !newBytes.SequenceEqual(buffer)) + if (buffer is null || !newBytes.SequenceEqual(buffer)) { var directory = Path.GetDirectoryName(path) ?? throw new ArgumentException($"Provided path ({path}) is not valid.", nameof(path)); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 6837cce5c..d7eb7e3ac 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.Channels public Task DeleteItem(BaseItem item) { var internalChannel = _libraryManager.GetItemById(item.ChannelId); - if (internalChannel == null) + if (internalChannel is null) { throw new ArgumentException(nameof(item.ChannelId)); } @@ -253,7 +253,7 @@ namespace Emby.Server.Implementations.Channels if (query.StartIndex.HasValue || query.Limit.HasValue) { int startIndex = query.StartIndex ?? 0; - int count = query.Limit == null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex); + int count = query.Limit is null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex); all = all.GetRange(startIndex, count); } @@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels { var path = Path.Combine(item.GetInternalMetadataPath(), "channelmediasourceinfos.json"); - if (mediaSources == null || mediaSources.Count == 0) + if (mediaSources is null || mediaSources.Count == 0) { try { @@ -447,7 +447,7 @@ namespace Emby.Server.Implementations.Channels var item = _libraryManager.GetItemById(id) as Channel; - if (item == null) + if (item is null) { item = new Channel { @@ -861,7 +861,7 @@ namespace Emby.Server.Implementations.Channels var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false); - if (result == null) + if (result is null) { throw new InvalidOperationException("Channel returned a null result from GetChannelItems"); } @@ -955,7 +955,7 @@ namespace Emby.Server.Implementations.Channels _logger.LogError(ex, "Error retrieving channel item from database"); } - if (item == null) + if (item is null) { item = new T(); isNew = true; @@ -1193,7 +1193,7 @@ namespace Emby.Server.Implementations.Channels var result = GetAllChannels() .FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase)); - if (result == null) + if (result is null) { throw new ResourceNotFoundException("No channel provider found for channel " + channel.Name); } @@ -1206,7 +1206,7 @@ namespace Emby.Server.Implementations.Channels var result = GetAllChannels() .FirstOrDefault(i => internalChannelId.Equals(GetInternalChannelId(i.Name))); - if (result == null) + if (result is null) { throw new ResourceNotFoundException("No channel provider found for channel id " + internalChannelId); } diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 187e0c9b3..701c7b61d 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.Collections { var folder = GetCollectionsFolder(false).GetAwaiter().GetResult(); - return folder == null + return folder is null ? Enumerable.Empty<BoxSet>() : folder.GetChildren(user, true).OfType<BoxSet>(); } @@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Collections var parentFolder = await GetCollectionsFolder(true).ConfigureAwait(false); - if (parentFolder == null) + if (parentFolder is null) { throw new ArgumentException(nameof(parentFolder)); } @@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.Collections { var item = _libraryManager.GetItemById(id); - if (item == null) + if (item is null) { throw new ArgumentException("No item exists with the supplied Id"); } @@ -267,7 +267,7 @@ namespace Emby.Server.Implementations.Collections var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); - if (child == null) + if (child is null) { _logger.LogWarning("No collection title exists with the supplied Id"); continue; diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index 736b8125d..4055b0ba1 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -253,7 +253,7 @@ namespace Emby.Server.Implementations.Data { if (statement.BindParameters.TryGetValue(name, out IBindParameter bindParam)) { - if (value == null) + if (value is null) { bindParam.BindNull(); } diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 9d44fd9d1..36fdfc8f2 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -691,7 +691,7 @@ namespace Emby.Server.Implementations.Data private string GetPathToSave(string path) { - if (path == null) + if (path is null) { return null; } @@ -890,7 +890,7 @@ namespace Emby.Server.Implementations.Data saveItemStatement.TryBind("@UnratedType", item.GetBlockUnratedType().ToString()); - if (topParent == null) + if (topParent is null) { saveItemStatement.TryBindNull("@TopParentId"); } @@ -1414,7 +1414,7 @@ namespace Emby.Server.Implementations.Data var type = _typeMapper.GetType(typeString); - if (type == null) + if (type is null) { return null; } @@ -1433,7 +1433,7 @@ namespace Emby.Server.Implementations.Data } } - if (item == null) + if (item is null) { try { @@ -1444,7 +1444,7 @@ namespace Emby.Server.Implementations.Data } } - if (item == null) + if (item is null) { return null; } @@ -2151,7 +2151,7 @@ namespace Emby.Server.Implementations.Data private static bool EnableJoinUserData(InternalItemsQuery query) { - if (query.User == null) + if (query.User is null) { return false; } @@ -2497,7 +2497,7 @@ namespace Emby.Server.Implementations.Data { var item = query.SimilarTo; - if (item == null) + if (item is null) { return; } @@ -4522,7 +4522,7 @@ namespace Emby.Server.Implementations.Data if (query.ExcludeInheritedTags.Length > 0) { var paramName = "@ExcludeInheritedTags"; - if (statement == null) + if (statement is null) { int index = 0; string excludedTags = string.Join(',', query.ExcludeInheritedTags.Select(_ => paramName + index++)); @@ -4732,7 +4732,7 @@ namespace Emby.Server.Implementations.Data return false; } - if (query.User == null) + if (query.User is null) { return false; } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index f6d37421a..e0e3366b4 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -235,14 +235,14 @@ namespace Emby.Server.Implementations.Dto if (options.ContainsField(ItemFields.CanDelete)) { - dto.CanDelete = user == null + dto.CanDelete = user is null ? item.CanDelete() : item.CanDelete(user); } if (options.ContainsField(ItemFields.CanDownload)) { - dto.CanDownload = user == null + dto.CanDownload = user is null ? item.CanDownload() : item.CanDownload(user); } @@ -571,7 +571,7 @@ namespace Emby.Server.Implementations.Dto return null; } }).Where(i => i != null) - .Where(i => user == null ? + .Where(i => user is null ? true : i.IsVisible(user)) .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase) @@ -1143,7 +1143,7 @@ namespace Emby.Server.Implementations.Dto if (episodeSeries != null) { dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, episodeSeries, ImageType.Primary); - if (dto.ImageTags == null || !dto.ImageTags.ContainsKey(ImageType.Primary)) + if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary)) { AttachPrimaryImageAspectRatio(dto, episodeSeries); } @@ -1193,7 +1193,7 @@ namespace Emby.Server.Implementations.Dto if (series != null) { dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, series, ImageType.Primary); - if (dto.ImageTags == null || !dto.ImageTags.ContainsKey(ImageType.Primary)) + if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary)) { AttachPrimaryImageAspectRatio(dto, series); } @@ -1276,7 +1276,7 @@ namespace Emby.Server.Implementations.Dto var parent = currentItem.DisplayParent ?? currentItem.GetOwner() ?? currentItem.GetParent(); - if (parent == null && originalItem is not UserRootFolder && originalItem is not UserView && originalItem is not AggregateFolder && originalItem is not ICollectionFolder && originalItem is not Channel) + if (parent is null && originalItem is not UserRootFolder && originalItem is not UserView && originalItem is not AggregateFolder && originalItem is not ICollectionFolder && originalItem is not Channel) { parent = _libraryManager.GetCollectionFolders(originalItem).FirstOrDefault(); } @@ -1315,7 +1315,7 @@ namespace Emby.Server.Implementations.Dto || parent is Series) { parent ??= isFirst ? GetImageDisplayParent(item, item) ?? owner : parent; - if (parent == null) + if (parent is null) { break; } @@ -1403,7 +1403,7 @@ namespace Emby.Server.Implementations.Dto { var imageInfo = item.GetImageInfo(ImageType.Primary, 0); - if (imageInfo == null) + if (imageInfo is null) { return null; } diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index d5e4a636e..fb6f52332 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -191,7 +191,7 @@ namespace Emby.Server.Implementations.EntryPoints lock (_libraryChangedSyncLock) { - if (LibraryUpdateTimer == null) + if (LibraryUpdateTimer is null) { LibraryUpdateTimer = new Timer( LibraryUpdateTimerCallback, @@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.EntryPoints lock (_libraryChangedSyncLock) { - if (LibraryUpdateTimer == null) + if (LibraryUpdateTimer is null) { LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite); } @@ -254,7 +254,7 @@ namespace Emby.Server.Implementations.EntryPoints lock (_libraryChangedSyncLock) { - if (LibraryUpdateTimer == null) + if (LibraryUpdateTimer is null) { LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite); } diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index 82c8d3ab6..ce81f9e42 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.EntryPoints lock (_syncLock) { - if (_updateTimer == null) + if (_updateTimer is null) { _updateTimer = new Timer( UpdateTimerCallback, diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index d095248fa..b1a99853a 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.HttpServer ReadResult result = await reader.ReadAsync().ConfigureAwait(false); ReadOnlySequence<byte> buffer = result.Buffer; - if (OnReceive == null) + if (OnReceive is null) { // Tell the PipeReader how much of the buffer we have consumed reader.AdvanceTo(buffer.End); @@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.HttpServer return; } - if (stub == null) + if (stub is null) { _logger.LogError("Error processing web socket message"); return; diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 6326208f7..6337952c1 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.IO return; } - if (_timer == null) + if (_timer is null) { _timer = new Timer(OnTimerCallback, null, TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1)); } @@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.IO { BaseItem? item = null; - while (item == null && !string.IsNullOrEmpty(path)) + while (item is null && !string.IsNullOrEmpty(path)) { item = _libraryManager.FindByPath(path, null); @@ -192,7 +192,7 @@ namespace Emby.Server.Implementations.IO { item = item.GetOwner() ?? item.GetParent(); - if (item == null) + if (item is null) { break; } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index b688af528..e8f6d2d23 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.Library { get { - if (_rootFolder == null) + if (_rootFolder is null) { lock (_rootFolderSyncLock) { @@ -656,7 +656,7 @@ namespace Emby.Server.Implementations.Library if (parent != null) { - var multiItemResolvers = resolvers == null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray(); + var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray(); foreach (var resolver in multiItemResolvers) { @@ -770,11 +770,11 @@ namespace Emby.Server.Implementations.Library public Folder GetUserRootFolder() { - if (_userRootFolder == null) + if (_userRootFolder is null) { lock (_userRootFolderSyncLock) { - if (_userRootFolder == null) + if (_userRootFolder is null) { var userRootPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath; @@ -792,7 +792,7 @@ namespace Emby.Server.Implementations.Library _logger.LogError(ex, "Error creating UserRootFolder {Path}", newItemId); } - if (tmpItem == null) + if (tmpItem is null) { _logger.LogDebug("Creating new userRootFolder with DeepCopy"); tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy<Folder, UserRootFolder>(); @@ -961,7 +961,7 @@ namespace Emby.Server.Implementations.Library var path = getPathFn(name); var id = GetItemByNameId<T>(path); var item = GetItemById(id) as T; - if (item == null) + if (item is null) { item = new T { @@ -1627,7 +1627,7 @@ namespace Emby.Server.Implementations.Library // Get an existing item by Id video = GetItemById(info.ItemId.Value) as Video; - if (video == null) + if (video is null) { _logger.LogError("Unable to locate item with Id {ID}.", info.ItemId.Value); } @@ -1639,7 +1639,7 @@ namespace Emby.Server.Implementations.Library // Try to resolve the path into a video video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video; - if (video == null) + if (video is null) { _logger.LogError("Intro resolver returned null for {Path}.", info.Path); } @@ -1711,7 +1711,7 @@ namespace Emby.Server.Implementations.Library foreach (var (name, sortOrder) in orderBy) { var comparer = GetComparer(name, user); - if (comparer == null) + if (comparer is null) { continue; } @@ -2010,7 +2010,7 @@ namespace Emby.Server.Implementations.Library { var parent = item.GetParent(); - if (parent == null || parent is AggregateFolder) + if (parent is null || parent is AggregateFolder) { break; } @@ -2018,7 +2018,7 @@ namespace Emby.Server.Implementations.Library item = parent; } - if (item == null) + if (item is null) { return new List<Folder>(); } @@ -2032,7 +2032,7 @@ namespace Emby.Server.Implementations.Library { var parent = item.GetParent(); - if (parent == null || parent is AggregateFolder) + if (parent is null || parent is AggregateFolder) { break; } @@ -2040,7 +2040,7 @@ namespace Emby.Server.Implementations.Library item = parent; } - if (item == null) + if (item is null) { return new List<Folder>(); } @@ -2064,7 +2064,7 @@ namespace Emby.Server.Implementations.Library .Find(folder => folder is CollectionFolder) as CollectionFolder; } - return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions(); + return collectionFolder is null ? new LibraryOptions() : collectionFolder.GetLibraryOptions(); } public string GetContentType(BaseItem item) @@ -2129,7 +2129,7 @@ namespace Emby.Server.Implementations.Library private string GetTopFolderContentType(BaseItem item) { - if (item == null) + if (item is null) { return null; } @@ -2137,7 +2137,7 @@ namespace Emby.Server.Implementations.Library while (!item.ParentId.Equals(default)) { var parent = item.GetParent(); - if (parent == null || parent is AggregateFolder) + if (parent is null || parent is AggregateFolder) { break; } @@ -2177,7 +2177,7 @@ namespace Emby.Server.Implementations.Library var refresh = false; - if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) + if (item is null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) { Directory.CreateDirectory(path); @@ -2225,7 +2225,7 @@ namespace Emby.Server.Implementations.Library var isNew = false; - if (item == null) + if (item is null) { Directory.CreateDirectory(path); @@ -2289,7 +2289,7 @@ namespace Emby.Server.Implementations.Library var isNew = false; - if (item == null) + if (item is null) { Directory.CreateDirectory(path); @@ -2362,7 +2362,7 @@ namespace Emby.Server.Implementations.Library var isNew = false; - if (item == null) + if (item is null) { Directory.CreateDirectory(path); @@ -2459,7 +2459,7 @@ namespace Emby.Server.Implementations.Library episodeInfo = resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming); // Resolve from parent folder if it's not the Season folder var parent = episode.GetParent(); - if (episodeInfo == null && parent.GetType() == typeof(Folder)) + if (episodeInfo is null && parent.GetType() == typeof(Folder)) { episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming); if (episodeInfo != null) @@ -2620,7 +2620,7 @@ namespace Emby.Server.Implementations.Library public IEnumerable<BaseItem> FindExtras(BaseItem owner, IReadOnlyList<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) { var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions); - if (ownerVideoInfo == null) + if (ownerVideoInfo is null) { yield break; } @@ -2754,7 +2754,7 @@ namespace Emby.Server.Implementations.Library } }) .Where(i => i != null) - .Where(i => query.User == null ? + .Where(i => query.User is null ? true : i.IsVisible(query.User)) .ToList(); diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs index 20624cc7a..101033551 100644 --- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs @@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Library } } - if (mediaInfo == null) + if (mediaInfo is null) { if (addProbeDelay) { @@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.Library var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - if (audioStream == null || audioStream.Index == -1) + if (audioStream is null || audioStream.Index == -1) { mediaSource.DefaultAudioStreamIndex = null; } diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index bfccc7db7..e2474f508 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -383,7 +383,7 @@ namespace Emby.Server.Implementations.Library var preferredSubs = NormalizeLanguage(user.SubtitleLanguagePreference); var defaultAudioIndex = source.DefaultAudioStreamIndex; - var audioLangage = defaultAudioIndex == null + var audioLangage = defaultAudioIndex is null ? null : source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault(); @@ -417,13 +417,13 @@ namespace Emby.Server.Implementations.Library public void SetDefaultAudioAndSubtitleStreamIndexes(BaseItem item, MediaSourceInfo source, User user) { // Item would only be null if the app didn't supply ItemId as part of the live stream open request - var mediaType = item == null ? MediaType.Video : item.MediaType; + var mediaType = item is null ? MediaType.Video : item.MediaType; if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) { - var userData = item == null ? new UserItemData() : _userDataManager.GetUserData(user, item); + var userData = item is null ? new UserItemData() : _userDataManager.GetUserData(user, item); - var allowRememberingSelection = item == null || item.EnableRememberingTrackSelections; + var allowRememberingSelection = item is null || item.EnableRememberingTrackSelections; SetDefaultAudioStreamIndex(source, userData, user, allowRememberingSelection); SetDefaultSubtitleStreamIndex(source, userData, user, allowRememberingSelection); @@ -543,7 +543,7 @@ namespace Emby.Server.Implementations.Library var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - if (audioStream == null || audioStream.Index == -1) + if (audioStream is null || audioStream.Index == -1) { mediaSource.DefaultAudioStreamIndex = null; } @@ -638,7 +638,7 @@ namespace Emby.Server.Implementations.Library } } - if (mediaInfo == null) + if (mediaInfo is null) { if (addProbeDelay) { @@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.Library var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - if (audioStream == null || audioStream.Index == -1) + if (audioStream is null || audioStream.Index == -1) { mediaSource.DefaultAudioStreamIndex = null; } diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs index 4100a74a5..590d37b92 100644 --- a/Emby.Server.Implementations/Library/ResolverHelper.cs +++ b/Emby.Server.Implementations/Library/ResolverHelper.cs @@ -43,7 +43,7 @@ namespace Emby.Server.Implementations.Library // Make sure DateCreated and DateModified have values var fileInfo = directoryService.GetFile(item.Path); - if (fileInfo == null) + if (fileInfo is null) { return false; } diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index 7a6aea9c1..bc1f5d08a 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio // Use regular audio type for mixed libraries, owned items and music if (isMixedCollectionType || - args.Parent == null || + args.Parent is null || isMusicCollectionType) { item = new MediaBrowser.Controller.Entities.Audio.Audio(); @@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio // TODO: Allow GetMultiDiscMovie in here var result = ResolveMultipleAudio(args.Parent, args.GetActualFileSystemChildren(), parseName); - if (result == null || result.Items.Count != 1 || result.Items[0] is not AudioBook item) + if (result is null || result.Items.Count != 1 || result.Items[0] is not AudioBook item) { return null; } diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index b2a7abb1b..cb377136a 100644 --- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Library.Resolvers videoType = VideoType.Dvd; } - if (videoType == null) + if (videoType is null) { continue; } @@ -93,7 +93,7 @@ namespace Emby.Server.Implementations.Library.Resolvers videoInfo = VideoResolver.Resolve(args.Path, false, NamingOptions, parseName); } - if (videoInfo == null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions))) + if (videoInfo is null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions))) { return null; } diff --git a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs index 408e640f9..30c52e19d 100644 --- a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType) { var extraResult = GetExtraInfo(path, _namingOptions); - if (extraResult.ExtraType == null) + if (extraResult.ExtraType is null) { extraType = null; return false; diff --git a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs index 079962282..1c2de912a 100644 --- a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs @@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Library.Resolvers { base.SetInitialItemValues(item, args); - item.IsRoot = args.Parent == null; + item.IsRoot = args.Parent is null; } } } diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 84d4688af..6b18ad237 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies if (string.IsNullOrEmpty(collectionType)) { // Owned items will be caught by the video extra resolver - if (args.Parent == null) + if (args.Parent is null) { return null; } @@ -127,10 +127,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies } // ignore extras - return movie?.ExtraType == null ? movie : null; + return movie?.ExtraType is null ? movie : null; } - if (args.Parent == null) + if (args.Parent is null) { return base.Resolve(args); } @@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies if (string.IsNullOrEmpty(collectionType)) { // Owned items should just use the plain video type - if (parent == null) + if (parent is null) { return ResolveVideos<Video>(parent, files, false, collectionType, false); } diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs index 9ba079edf..2e2b79341 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV { var parent = args.Parent; - if (parent == null) + if (parent is null) { return null; } @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV var episode = ResolveVideo<Episode>(args, false); // Ignore extras - if (episode == null || episode.ExtraType != null) + if (episode is null || episode.ExtraType != null) { return null; } @@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV } // Assume season 1 if there's no season folder and a season number could not be determined - if (season == null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue)) + if (season is null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue)) { episode.ParentIndexNumber = 1; } diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index ec411aa3b..c294a63db 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library { var user = _userManager.GetUserById(query.UserId); - if (user == null) + if (user is null) { throw new ArgumentException("User Id specified in the query does not exist.", nameof(query)); } @@ -208,7 +208,7 @@ namespace Emby.Server.Implementations.Library // Only grab the index container for media var container = item.IsFolder || !request.GroupItems ? null : item.LatestItemsIndexContainer; - if (container == null) + if (container is null) { list.Add(new Tuple<BaseItem, List<BaseItem>>(null, new List<BaseItem> { item })); } diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs index 88b93a211..df45793c3 100644 --- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs +++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs @@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.Library.Validators try { var boxSet = boxSets.FirstOrDefault(b => b?.Name == collectionName) as BoxSet; - if (boxSet == null) + if (boxSet is null) { // won't automatically create collection if only one movie in it if (movieIds.Count >= 2) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index cf9be5a54..2f4854a6d 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } var program = GetProgramInfoFromCache(timer); - if (program == null) + if (program is null) { OnTimerOutOfDate(timer); continue; @@ -642,7 +642,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV programInfo = GetProgramInfoFromCache(info); } - if (programInfo == null) + if (programInfo is null) { _logger.LogInformation("Unable to find program with Id {0}. Will search using start date", info.ProgramId); programInfo = GetProgramInfoFromCache(info.ChannelId, info.StartDate); @@ -744,7 +744,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var existingTimer = _timerProvider.GetTimer(updatedTimer.Id); - if (existingTimer == null) + if (existingTimer is null) { throw new ResourceNotFoundException(); } @@ -912,7 +912,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var epgChannel = await GetEpgChannelFromTunerChannel(provider.Item1, provider.Item2, channel, cancellationToken).ConfigureAwait(false); - if (epgChannel == null) + if (epgChannel is null) { _logger.LogDebug("EPG channel not found for tuner channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty); continue; @@ -945,7 +945,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var provider = _liveTvManager.ListingProviders.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase)); - return provider == null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i); + return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i); }) .Where(i => i != null) .ToList(); @@ -1232,7 +1232,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV programInfo = GetProgramInfoFromCache(timer); } - if (programInfo == null) + if (programInfo is null) { _logger.LogInformation("Unable to find program with Id {0}. Will search using start date", timer.ProgramId); programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate); @@ -1437,7 +1437,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var parentPath = Path.GetDirectoryName(path); - while (item == null && !string.IsNullOrEmpty(path)) + while (item is null && !string.IsNullOrEmpty(path)) { item = _libraryManager.FindByPath(path, null); @@ -1474,7 +1474,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var seriesTimerId = timer.SeriesTimerId; var seriesTimer = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, seriesTimerId, StringComparison.OrdinalIgnoreCase)); - if (seriesTimer == null || seriesTimer.KeepUpTo <= 0) + if (seriesTimer is null || seriesTimer.KeepUpTo <= 0) { return; } @@ -1695,7 +1695,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _ => null }; - if (imageSaveFilenameWithoutExtension == null) + if (imageSaveFilenameWithoutExtension is null) { return; } @@ -1782,7 +1782,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV }).FirstOrDefault() as LiveTvProgram; // dummy this up - if (program == null) + if (program is null) { program = new LiveTvProgram { @@ -2240,7 +2240,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV ? null : _timerProvider.GetTimerByProgramId(timer.ProgramId)); - if (existingTimer == null) + if (existingTimer is null) { if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 58b798ce6..80e3e5233 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var bytes = File.ReadAllBytes(_dataPath); _items = JsonSerializer.Deserialize<T[]>(bytes, _jsonOptions); - if (_items == null) + if (_items is null) { Logger.LogError("Error deserializing {Path}, data was null", _dataPath); _items = Array.Empty<T>(); diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index b981ad81a..69670e811 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -111,7 +111,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false); await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); var dailySchedules = await JsonSerializer.DeserializeAsync<IReadOnlyList<DayDto>>(responseStream, _jsonOptions, cancellationToken).ConfigureAwait(false); - if (dailySchedules == null) + if (dailySchedules is null) { return Array.Empty<ProgramInfo>(); } @@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false); await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); var programDetails = await JsonSerializer.DeserializeAsync<IReadOnlyList<ProgramDetailsDto>>(innerResponseStream, _jsonOptions, cancellationToken).ConfigureAwait(false); - if (programDetails == null) + if (programDetails is null) { return Array.Empty<ProgramInfo>(); } @@ -228,7 +228,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings private ProgramInfo GetProgram(string channelId, ProgramDto programInfo, ProgramDetailsDto details) { - if (programInfo.AirDateTime == null) + if (programInfo.AirDateTime is null) { return null; } @@ -283,7 +283,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings EpisodeTitle = episodeTitle, Audio = audioType, // IsNew = programInfo.@new ?? false, - IsRepeat = programInfo.New == null, + IsRepeat = programInfo.New is null, IsSeries = string.Equals(details.EntityType, "episode", StringComparison.OrdinalIgnoreCase), ImageUrl = details.PrimaryImage, ThumbImageUrl = details.ThumbImage, @@ -407,7 +407,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings .ThenByDescending(i => GetSizeOrder(i)) .FirstOrDefault(); - if (match == null) + if (match is null) { return null; } @@ -785,7 +785,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false); await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); var root = await JsonSerializer.DeserializeAsync<ChannelDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false); - if (root == null) + if (root is null) { return new List<ChannelInfo>(); } diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 264eec947..1b72a44b4 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings HasImage = !string.IsNullOrEmpty(program.Icon?.Source), OfficialRating = string.IsNullOrEmpty(program.Rating?.Value) ? null : program.Rating.Value, CommunityRating = program.StarRating, - SeriesId = program.Episode == null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture) + SeriesId = program.Episode is null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture) }; if (string.IsNullOrWhiteSpace(program.ProgramId)) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index c09f9cf8d..a92b473b5 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture); } - dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days.ToArray()); + dto.DayPattern = info.Days is null ? null : GetDayPattern(info.Days.ToArray()); FillImages(dto, info.Name, info.SeriesId); @@ -228,7 +228,7 @@ namespace Emby.Server.Implementations.LiveTv } } - if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0) + if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0) { image = program.GetImageInfo(ImageType.Backdrop, 0); if (image != null) @@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.LiveTv DtoOptions = new DtoOptions(false) }).FirstOrDefault(); - if (program == null) + if (program is null) { program = _libraryManager.GetItemList(new InternalItemsQuery { @@ -334,7 +334,7 @@ namespace Emby.Server.Implementations.LiveTv } } - if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0) + if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0) { image = program.GetImageInfo(ImageType.Backdrop, 0); if (image != null) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 97c2e6e30..ea26a2227 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -434,7 +434,7 @@ namespace Emby.Server.Implementations.LiveTv var item = _libraryManager.GetItemById(id) as LiveTvChannel; - if (item == null) + if (item is null) { item = new LiveTvChannel { @@ -948,7 +948,7 @@ namespace Emby.Server.Implementations.LiveTv var channel = _libraryManager.GetItemById(program.ChannelId); - if (channel == null) + if (channel is null) { return score; } @@ -1314,7 +1314,7 @@ namespace Emby.Server.Implementations.LiveTv private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user) { - if (user == null) + if (user is null) { return new QueryResult<BaseItem>(); } @@ -1702,7 +1702,7 @@ namespace Emby.Server.Implementations.LiveTv { var timer = await GetTimer(id, CancellationToken.None).ConfigureAwait(false); - if (timer == null) + if (timer is null) { throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "Timer with Id {0} not found", id)); } @@ -1721,7 +1721,7 @@ namespace Emby.Server.Implementations.LiveTv { var timer = await GetSeriesTimer(id, CancellationToken.None).ConfigureAwait(false); - if (timer == null) + if (timer is null) { throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "SeriesTimer with Id {0} not found", id)); } @@ -1834,7 +1834,7 @@ namespace Emby.Server.Implementations.LiveTv { var internalChannelId = _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId); var channel = _libraryManager.GetItemById(internalChannelId); - channelName = channel == null ? null : channel.Name; + channelName = channel is null ? null : channel.Name; } return _tvDtoService.GetSeriesTimerInfoDto(i.Item1, i.Item2, channelName); @@ -2147,7 +2147,7 @@ namespace Emby.Server.Implementations.LiveTv var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), parts[0], StringComparison.OrdinalIgnoreCase)); - if (service == null) + if (service is null) { throw new ArgumentException("Service not found."); } @@ -2178,7 +2178,7 @@ namespace Emby.Server.Implementations.LiveTv var provider = _tunerHosts.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); - if (provider == null) + if (provider is null) { throw new ResourceNotFoundException(); } @@ -2222,7 +2222,7 @@ namespace Emby.Server.Implementations.LiveTv var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); - if (provider == null) + if (provider is null) { throw new ResourceNotFoundException( string.Format( @@ -2334,7 +2334,7 @@ namespace Emby.Server.Implementations.LiveTv { var provider = _listingProviders.FirstOrDefault(i => string.Equals(providerType, i.Type, StringComparison.OrdinalIgnoreCase)); - if (provider == null) + if (provider is null) { throw new ResourceNotFoundException(); } @@ -2347,7 +2347,7 @@ namespace Emby.Server.Implementations.LiveTv var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); - if (provider == null) + if (provider is null) { throw new ResourceNotFoundException(); } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index e0eaa8e58..04d64e500 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -302,7 +302,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo; - if (hdHomerunChannelInfo == null || hdHomerunChannelInfo.IsLegacyTuner) + if (hdHomerunChannelInfo is null || hdHomerunChannelInfo.IsLegacyTuner) { return await GetTunerInfosUdp(info, cancellationToken).ConfigureAwait(false); } diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index b77168126..8f15a155e 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -329,14 +329,14 @@ namespace Emby.Server.Implementations.Localization { await using var stream = _assembly.GetManifestResourceStream(resourcePath); // If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain - if (stream == null) + if (stream is null) { _logger.LogError("Missing translation/culture resource: {ResourcePath}", resourcePath); return; } var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(stream, _jsonOptions).ConfigureAwait(false); - if (dict == null) + if (dict is null) { throw new InvalidOperationException($"Resource contains invalid data: '{stream}'"); } diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 9e7035cb3..d8d4629c1 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Playlists var folderName = _fileSystem.GetValidFilename(name); var parentFolder = GetPlaylistsFolder(Guid.Empty); - if (parentFolder == null) + if (parentFolder is null) { throw new ArgumentException(nameof(parentFolder)); } @@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Playlists { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { throw new ArgumentException("No item exists with the supplied Id"); } diff --git a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs index 8ec9f6161..e2f2e436f 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs @@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Playlists protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) { - if (query.User == null) + if (query.User is null) { query.Recursive = false; return base.GetItemsInternal(query); diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs index 3f7d46822..c1a38d23c 100644 --- a/Emby.Server.Implementations/Plugins/PluginManager.cs +++ b/Emby.Server.Implementations/Plugins/PluginManager.cs @@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Plugins foreach (var pluginServiceRegistrator in _appHost.GetExportTypes<IPluginServiceRegistrator>()) { var plugin = GetPluginByAssembly(pluginServiceRegistrator.Assembly); - if (plugin == null) + if (plugin is null) { _logger.LogError("Unable to find plugin in assembly {Assembly}", pluginServiceRegistrator.Assembly.FullName); continue; @@ -263,7 +263,7 @@ namespace Emby.Server.Implementations.Plugins { LocalPlugin? plugin; - if (version == null) + if (version is null) { // If no version is given, return the current instance. var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList(); @@ -320,7 +320,7 @@ namespace Emby.Server.Implementations.Plugins ArgumentNullException.ThrowIfNull(assembly); var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location)); - if (plugin == null) + if (plugin is null) { // A plugin's assembly didn't cause this issue, so ignore it. return; @@ -442,7 +442,7 @@ namespace Emby.Server.Implementations.Plugins _logger.LogDebug("Creating instance of {Type}", type); // _appHost.ServiceProvider is already assigned when we create the plugins var instance = (IPlugin)ActivatorUtilities.CreateInstance(_appHost.ServiceProvider!, type); - if (plugin == null) + if (plugin is null) { // Create a dummy record for the providers. // TODO: remove this code once all provided have been released as separate plugins. @@ -711,7 +711,7 @@ namespace Emby.Server.Implementations.Plugins && p.IsEnabledAndSupported && p.Version != plugin.Version); - if (previousVersion == null) + if (previousVersion is null) { // This value is memory only - so that the web will show restart required. plugin.Manifest.Status = PluginStatus.Restart; diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index b370e06ef..25515f778 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.ScheduledTasks lock (_lastExecutionResultSyncLock) { - if (_lastExecutionResult == null && !_readFromFile) + if (_lastExecutionResult is null && !_readFromFile) { if (File.Exists(path)) { diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index 0431858fc..63f0beb10 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T)); - if (scheduledTask == null) + if (scheduledTask is null) { _logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", typeof(T).Name); } @@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T)); - if (scheduledTask == null) + if (scheduledTask is null) { _logger.LogError("Unable to find scheduled task of type {0} in Execute.", typeof(T).Name); } @@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType()); - if (scheduledTask == null) + if (scheduledTask is null) { _logger.LogError("Unable to find scheduled task of type {0} in QueueScheduledTask.", task.GetType().Name); } diff --git a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs index 3eb800199..e9b8a8257 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs @@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers DateTime triggerDate; - if (lastResult == null) + if (lastResult is null) { // Task has never been completed before triggerDate = DateTime.UtcNow.AddHours(1); diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 0d1029882..a1e3b9dbd 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -377,11 +377,11 @@ namespace Emby.Server.Implementations.Session info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture); } - if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null) + if (!info.ItemId.Equals(default) && info.Item is null && libraryItem != null) { var current = session.NowPlayingItem; - if (current == null || !info.ItemId.Equals(current.Id)) + if (current is null || !info.ItemId.Equals(current.Id)) { var runtimeTicks = libraryItem.RunTimeTicks; @@ -495,7 +495,7 @@ namespace Emby.Server.Implementations.Session sessionInfo.UserId = user?.Id ?? Guid.Empty; sessionInfo.UserName = user?.Username; - sessionInfo.UserPrimaryImageTag = user?.ProfileImage == null ? null : GetImageCacheTag(user); + sessionInfo.UserPrimaryImageTag = user?.ProfileImage is null ? null : GetImageCacheTag(user); sessionInfo.RemoteEndPoint = remoteEndPoint; sessionInfo.Client = appName; @@ -506,7 +506,7 @@ namespace Emby.Server.Implementations.Session sessionInfo.ApplicationVersion = appVersion; - if (user == null) + if (user is null) { sessionInfo.AdditionalUsers = Array.Empty<SessionUserInfo>(); } @@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.Session sessionInfo.UserId = user?.Id ?? Guid.Empty; sessionInfo.UserName = username; - sessionInfo.UserPrimaryImageTag = user?.ProfileImage == null ? null : GetImageCacheTag(user); + sessionInfo.UserPrimaryImageTag = user?.ProfileImage is null ? null : GetImageCacheTag(user); sessionInfo.RemoteEndPoint = remoteEndPoint; if (string.IsNullOrEmpty(deviceName)) @@ -570,7 +570,7 @@ namespace Emby.Server.Implementations.Session var user = _userManager.GetUserById(session.UserId); - if (user == null) + if (user is null) { throw new InvalidOperationException("User not found"); } @@ -618,7 +618,7 @@ namespace Emby.Server.Implementations.Session await OnPlaybackStopped(new PlaybackStopInfo { Item = session.NowPlayingItem, - ItemId = session.NowPlayingItem == null ? Guid.Empty : session.NowPlayingItem.Id, + ItemId = session.NowPlayingItem is null ? Guid.Empty : session.NowPlayingItem.Id, SessionId = session.Id, MediaSourceId = session.PlayState?.MediaSourceId, PositionTicks = session.PlayState?.PositionTicks @@ -912,11 +912,11 @@ namespace Emby.Server.Implementations.Session info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture); } - if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null) + if (!info.ItemId.Equals(default) && info.Item is null && libraryItem != null) { var current = session.NowPlayingItem; - if (current == null || !info.ItemId.Equals(current.Id)) + if (current is null || !info.ItemId.Equals(current.Id)) { MediaSourceInfo mediaSource = null; @@ -1037,7 +1037,7 @@ namespace Emby.Server.Implementations.Session private SessionInfo GetSession(string sessionId, bool throwOnMissing = true) { var session = Sessions.FirstOrDefault(i => string.Equals(i.Id, sessionId, StringComparison.Ordinal)); - if (session == null && throwOnMissing) + if (session is null && throwOnMissing) { throw new ResourceNotFoundException( string.Format(CultureInfo.InvariantCulture, "Session {0} not found.", sessionId)); @@ -1051,7 +1051,7 @@ namespace Emby.Server.Implementations.Session // Accept either device id or session id var session = Sessions.FirstOrDefault(i => string.Equals(i.Id, sessionId, StringComparison.Ordinal)); - if (session == null) + if (session is null) { throw new ResourceNotFoundException( string.Format(CultureInfo.InvariantCulture, "Session {0} not found.", sessionId)); @@ -1231,7 +1231,7 @@ namespace Emby.Server.Implementations.Session { var item = _libraryManager.GetItemById(id); - if (item == null) + if (item is null) { _logger.LogError("A non-existent item Id {0} was passed into TranslateItemForPlayback", id); return Array.Empty<BaseItem>(); @@ -1284,7 +1284,7 @@ namespace Emby.Server.Implementations.Session { var item = _libraryManager.GetItemById(id); - if (item == null) + if (item is null) { _logger.LogError("A non-existent item Id {0} was passed into TranslateItemForInstantMix", id); return new List<BaseItem>(); @@ -1480,7 +1480,7 @@ namespace Emby.Server.Implementations.Session true).ConfigureAwait(false); } - if (user == null) + if (user is null) { AuthenticationFailed?.Invoke(this, new GenericEventArgs<AuthenticationRequest>(request)); throw new AuthenticationException("Invalid username or password entered."); @@ -1541,7 +1541,7 @@ namespace Emby.Server.Implementations.Session foreach (var auth in allExistingForDevice) { - if (existing == null || !string.Equals(auth.AccessToken, existing.AccessToken, StringComparison.Ordinal)) + if (existing is null || !string.Equals(auth.AccessToken, existing.AccessToken, StringComparison.Ordinal)) { try { @@ -1677,7 +1677,7 @@ namespace Emby.Server.Implementations.Session var dtoOptions = _itemInfoDtoOptions; - if (_itemInfoDtoOptions == null) + if (_itemInfoDtoOptions is null) { dtoOptions = new DtoOptions { diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs index c654828b1..bab934578 100644 --- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs @@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Session { lock (_keepAliveLock) { - if (_keepAliveCancellationToken == null) + if (_keepAliveCancellationToken is null) { _keepAliveCancellationToken = new CancellationTokenSource(); // Start KeepAlive watcher diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs index 1f3248f07..051fa5b3c 100644 --- a/Emby.Server.Implementations/Session/WebSocketController.cs +++ b/Emby.Server.Implementations/Session/WebSocketController.cs @@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Session .OrderByDescending(i => i.LastActivityDate) .FirstOrDefault(); - if (socket == null) + if (socket is null) { return Task.CompletedTask; } diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 2d21bd9c2..964004ecc 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -31,9 +31,9 @@ namespace Emby.Server.Implementations.Sorting var episode1 = x as Episode; var episode2 = y as Episode; - if (episode1 == null) + if (episode1 is null) { - if (episode2 == null) + if (episode2 is null) { return 0; } @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Sorting return 1; } - if (episode2 == null) + if (episode2 is null) { return -1; } diff --git a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs index 45c9044c5..16f1b79b3 100644 --- a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs +++ b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs @@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Sorting { var userdata = UserDataRepository.GetUserData(User, x); - return userdata == null ? 0 : userdata.PlayCount; + return userdata is null ? 0 : userdata.PlayCount; } } } diff --git a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs index b217556ef..db86b8002 100644 --- a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs +++ b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Sorting /// <returns>DateTime.</returns> private static DateTime GetDate(BaseItem? x) { - if (x == null) + if (x is null) { return DateTime.MinValue; } diff --git a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs index d2022df7a..7fd1e024d 100644 --- a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs +++ b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs @@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.Sorting /// <returns>DateTime.</returns> private static int GetValue(BaseItem? x) { - if (x == null) + if (x is null) { return 0; } diff --git a/Emby.Server.Implementations/SyncPlay/Group.cs b/Emby.Server.Implementations/SyncPlay/Group.cs index 52becfec6..ef2a4ef77 100644 --- a/Emby.Server.Implementations/SyncPlay/Group.cs +++ b/Emby.Server.Implementations/SyncPlay/Group.cs @@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.SyncPlay private bool HasAccessToQueue(User user, IReadOnlyList<Guid> queue) { // Check if queue is empty. - if (queue == null || queue.Count == 0) + if (queue is null || queue.Count == 0) { return true; } @@ -217,7 +217,7 @@ namespace Emby.Server.Implementations.SyncPlay private bool AllUsersHaveAccessToQueue(IReadOnlyList<Guid> queue) { // Check if queue is empty. - if (queue == null || queue.Count == 0) + if (queue is null || queue.Count == 0) { return true; } diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs index 53e3b3577..63c4a1556 100644 --- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs +++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs @@ -102,12 +102,12 @@ namespace Emby.Server.Implementations.SyncPlay /// <inheritdoc /> public void NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken) { - if (session == null) + if (session is null) { throw new InvalidOperationException("Session is null!"); } - if (request == null) + if (request is null) { throw new InvalidOperationException("Request is null!"); } @@ -138,12 +138,12 @@ namespace Emby.Server.Implementations.SyncPlay /// <inheritdoc /> public void JoinGroup(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken) { - if (session == null) + if (session is null) { throw new InvalidOperationException("Session is null!"); } - if (request == null) + if (request is null) { throw new InvalidOperationException("Request is null!"); } @@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.SyncPlay { _groups.TryGetValue(request.GroupId, out Group group); - if (group == null) + if (group is null) { _logger.LogWarning("Session {SessionId} tried to join group {GroupId} that does not exist.", session.Id, request.GroupId); @@ -204,12 +204,12 @@ namespace Emby.Server.Implementations.SyncPlay /// <inheritdoc /> public void LeaveGroup(SessionInfo session, LeaveGroupRequest request, CancellationToken cancellationToken) { - if (session == null) + if (session is null) { throw new InvalidOperationException("Session is null!"); } - if (request == null) + if (request is null) { throw new InvalidOperationException("Request is null!"); } @@ -257,12 +257,12 @@ namespace Emby.Server.Implementations.SyncPlay /// <inheritdoc /> public List<GroupInfoDto> ListGroups(SessionInfo session, ListGroupsRequest request) { - if (session == null) + if (session is null) { throw new InvalidOperationException("Session is null!"); } - if (request == null) + if (request is null) { throw new InvalidOperationException("Request is null!"); } @@ -291,12 +291,12 @@ namespace Emby.Server.Implementations.SyncPlay /// <inheritdoc /> public void HandleRequest(SessionInfo session, IGroupPlaybackRequest request, CancellationToken cancellationToken) { - if (session == null) + if (session is null) { throw new InvalidOperationException("Session is null!"); } - if (request == null) + if (request is null) { throw new InvalidOperationException("Request is null!"); } diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 5c9b9df15..57fa57c59 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.TV { var user = _userManager.GetUserById(query.UserId); - if (user == null) + if (user is null) { throw new ArgumentException("User not found"); } @@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.TV { var user = _userManager.GetUserById(request.UserId); - if (user == null) + if (user is null) { throw new ArgumentException("User not found"); } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 550f0e075..84489b646 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Updates PackageInfo[]? packages = await _httpClientFactory.CreateClient(NamedClient.Default) .GetFromJsonAsync<PackageInfo[]>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false); - if (packages == null) + if (packages is null) { return Array.Empty<PackageInfo>(); } @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Updates var package = FilterPackages(availablePackages, name, id, specificVersion).FirstOrDefault(); // Package not found in repository - if (package == null) + if (package is null) { yield break; } @@ -370,7 +370,7 @@ namespace Emby.Server.Implementations.Updates /// <param name="plugin">The <see cref="LocalPlugin"/> to uninstall.</param> public void UninstallPlugin(LocalPlugin plugin) { - if (plugin == null) + if (plugin is null) { return; } @@ -565,7 +565,7 @@ namespace Emby.Server.Implementations.Updates ?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version)); await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false); - _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin == null ? "installed" : "updated", package.Name, package.Version); + _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin is null ? "installed" : "updated", package.Name, package.Version); return plugin != null; } diff --git a/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs b/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs index 88af08dd3..d4b1ffb06 100644 --- a/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs +++ b/Jellyfin.Api/Auth/AnonymousLanAccessPolicy/AnonymousLanAccessHandler.cs @@ -32,7 +32,7 @@ namespace Jellyfin.Api.Auth.AnonymousLanAccessPolicy var ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress; // Loopback will be on LAN, so we can accept null. - if (ip == null || _networkManager.IsInLocalNetwork(ip)) + if (ip is null || _networkManager.IsInLocalNetwork(ip)) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs index 92ee1dd59..630bb7037 100644 --- a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs +++ b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs @@ -67,7 +67,7 @@ namespace Jellyfin.Api.Auth // Ensure userId links to a valid user. var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return false; } diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index bbe163312..a00ac1b0a 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers var configurationType = _configurationManager.GetConfigurationType(key); var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions); - if (deserializedConfiguration == null) + if (deserializedConfiguration is null) { throw new ArgumentException("Body doesn't contain a valid configuration"); } diff --git a/Jellyfin.Api/Controllers/DashboardController.cs b/Jellyfin.Api/Controllers/DashboardController.cs index c8411f44b..3894e6c5f 100644 --- a/Jellyfin.Api/Controllers/DashboardController.cs +++ b/Jellyfin.Api/Controllers/DashboardController.cs @@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers public ActionResult GetDashboardConfigurationPage([FromQuery] string? name) { var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, name, StringComparison.OrdinalIgnoreCase)); - if (altPage == null) + if (altPage is null) { return NotFound(); } @@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers IPlugin plugin = altPage.Item2; string resourcePath = altPage.Item1.EmbeddedResourcePath; Stream? stream = plugin.GetType().Assembly.GetManifestResourceStream(resourcePath); - if (stream == null) + if (stream is null) { _logger.LogError("Failed to get resource {Resource} from plugin {Plugin}", resourcePath, plugin.Name); return NotFound(); diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs index 8292cf83b..aad60cf5c 100644 --- a/Jellyfin.Api/Controllers/DevicesController.cs +++ b/Jellyfin.Api/Controllers/DevicesController.cs @@ -64,7 +64,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult<DeviceInfo>> GetDeviceInfo([FromQuery, Required] string id) { var deviceInfo = await _deviceManager.GetDevice(id).ConfigureAwait(false); - if (deviceInfo == null) + if (deviceInfo is null) { return NotFound(); } @@ -85,7 +85,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult<DeviceOptions>> GetDeviceOptions([FromQuery, Required] string id) { var deviceInfo = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false); - if (deviceInfo == null) + if (deviceInfo is null) { return NotFound(); } @@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult> DeleteDevice([FromQuery, Required] string id) { var existingDevice = await _deviceManager.GetDevice(id).ConfigureAwait(false); - if (existingDevice == null) + if (existingDevice is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/DlnaController.cs b/Jellyfin.Api/Controllers/DlnaController.cs index 35c3a3d92..07e0590a1 100644 --- a/Jellyfin.Api/Controllers/DlnaController.cs +++ b/Jellyfin.Api/Controllers/DlnaController.cs @@ -63,7 +63,7 @@ namespace Jellyfin.Api.Controllers public ActionResult<DeviceProfile> GetProfile([FromRoute, Required] string profileId) { var profile = _dlnaManager.GetProfile(profileId); - if (profile == null) + if (profile is null) { return NotFound(); } @@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers public ActionResult DeleteProfile([FromRoute, Required] string profileId) { var existingDeviceProfile = _dlnaManager.GetProfile(profileId); - if (existingDeviceProfile == null) + if (existingDeviceProfile is null) { return NotFound(); } @@ -121,7 +121,7 @@ namespace Jellyfin.Api.Controllers public ActionResult UpdateProfile([FromRoute, Required] string profileId, [FromBody] DeviceProfile deviceProfile) { var existingDeviceProfile = _dlnaManager.GetProfile(profileId); - if (existingDeviceProfile == null) + if (existingDeviceProfile is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index 8859d6020..96c492b3e 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -274,7 +274,7 @@ namespace Jellyfin.Api.Controllers private ActionResult GetIconInternal(string fileName) { var icon = _dlnaManager.GetIcon(fileName); - if (icon == null) + if (icon is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index 0f4d3c1eb..afe0de630 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -1482,7 +1482,7 @@ namespace Jellyfin.Api.Controllers startTranscoding = true; segmentId = 0; } - else if (currentTranscodingIndex == null) + else if (currentTranscodingIndex is null) { _logger.LogDebug("Starting transcoding because currentTranscodingIndex=null"); startTranscoding = true; @@ -1665,7 +1665,7 @@ namespace Jellyfin.Api.Controllers /// <returns>The command line arguments for audio transcoding.</returns> private string GetAudioArguments(StreamState state) { - if (state.AudioStream == null) + if (state.AudioStream is null) { return string.Empty; } @@ -1762,7 +1762,7 @@ namespace Jellyfin.Api.Controllers /// <returns>The command line arguments for video transcoding.</returns> private string GetVideoArguments(StreamState state, int startNumber, bool isEventPlaylist) { - if (state.VideoStream == null) + if (state.VideoStream is null) { return string.Empty; } @@ -1969,14 +1969,14 @@ namespace Jellyfin.Api.Controllers { var job = _transcodingJobHelper.GetTranscodingJob(playlist, TranscodingJobType); - if (job == null || job.HasExited) + if (job is null || job.HasExited) { return null; } var file = GetLastTranscodingFile(playlist, segmentExtension, _fileSystem); - if (file == null) + if (file is null) { return null; } diff --git a/Jellyfin.Api/Controllers/EnvironmentController.cs b/Jellyfin.Api/Controllers/EnvironmentController.cs index b0b4b5af5..6c78a7987 100644 --- a/Jellyfin.Api/Controllers/EnvironmentController.cs +++ b/Jellyfin.Api/Controllers/EnvironmentController.cs @@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers if (validatePathDto.ValidateWritable) { - if (validatePathDto.Path == null) + if (validatePathDto.Path is null) { throw new ResourceNotFoundException(nameof(validatePathDto.Path)); } diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs index 11808b1b8..b6780ee20 100644 --- a/Jellyfin.Api/Controllers/FilterController.cs +++ b/Jellyfin.Api/Controllers/FilterController.cs @@ -182,7 +182,7 @@ namespace Jellyfin.Api.Controllers if ((recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder) { - genreQuery.AncestorIds = parentItem == null ? Array.Empty<Guid>() : new[] { parentItem.Id }; + genreQuery.AncestorIds = parentItem is null ? Array.Empty<Guid>() : new[] { parentItem.Id }; } else { diff --git a/Jellyfin.Api/Controllers/HlsSegmentController.cs b/Jellyfin.Api/Controllers/HlsSegmentController.cs index 78634f0bf..8e78d5a1a 100644 --- a/Jellyfin.Api/Controllers/HlsSegmentController.cs +++ b/Jellyfin.Api/Controllers/HlsSegmentController.cs @@ -167,7 +167,7 @@ namespace Jellyfin.Api.Controllers } } - return playlistPath == null + return playlistPath is null ? NotFound("Hls segment not found.") : GetFileResult(file, playlistPath); } diff --git a/Jellyfin.Api/Controllers/ImageByNameController.cs b/Jellyfin.Api/Controllers/ImageByNameController.cs index 89bbf22c9..c54851b96 100644 --- a/Jellyfin.Api/Controllers/ImageByNameController.cs +++ b/Jellyfin.Api/Controllers/ImageByNameController.cs @@ -77,7 +77,7 @@ namespace Jellyfin.Api.Controllers .Select(i => Path.GetFullPath(Path.Combine(_applicationPaths.GeneralPath, name, filename + i))) .FirstOrDefault(System.IO.File.Exists); - if (path == null) + if (path is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs index f092bd882..adcac8e97 100644 --- a/Jellyfin.Api/Controllers/ImageController.cs +++ b/Jellyfin.Api/Controllers/ImageController.cs @@ -198,7 +198,7 @@ namespace Jellyfin.Api.Controllers } var user = _userManager.GetUserById(userId); - if (user?.ProfileImage == null) + if (user?.ProfileImage is null) { return NoContent(); } @@ -242,7 +242,7 @@ namespace Jellyfin.Api.Controllers } var user = _userManager.GetUserById(userId); - if (user?.ProfileImage == null) + if (user?.ProfileImage is null) { return NoContent(); } @@ -279,7 +279,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -307,7 +307,7 @@ namespace Jellyfin.Api.Controllers [FromRoute] int imageIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -335,7 +335,7 @@ namespace Jellyfin.Api.Controllers [FromRoute, Required] ImageType imageType) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -371,7 +371,7 @@ namespace Jellyfin.Api.Controllers [FromRoute] int imageIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -407,7 +407,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] int newIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -430,7 +430,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult<IEnumerable<ImageInfo>>> GetItemImageInfos([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -537,7 +537,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -620,7 +620,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -703,7 +703,7 @@ namespace Jellyfin.Api.Controllers [FromRoute, Required] int imageIndex) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -786,7 +786,7 @@ namespace Jellyfin.Api.Controllers [FromRoute, Required] int imageIndex) { var item = _libraryManager.GetArtist(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -869,7 +869,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetGenre(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -952,7 +952,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var item = _libraryManager.GetGenre(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1035,7 +1035,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetMusicGenre(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1118,7 +1118,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var item = _libraryManager.GetMusicGenre(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1201,7 +1201,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetPerson(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1284,7 +1284,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var item = _libraryManager.GetPerson(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1367,7 +1367,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var item = _libraryManager.GetStudio(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1450,7 +1450,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var item = _libraryManager.GetStudio(name); - if (item == null) + if (item is null) { return NotFound(); } @@ -1533,7 +1533,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageIndex) { var user = _userManager.GetUserById(userId); - if (user?.ProfileImage == null) + if (user?.ProfileImage is null) { return NotFound(); } @@ -1634,7 +1634,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? foregroundLayer) { var user = _userManager.GetUserById(userId); - if (user?.ProfileImage == null) + if (user?.ProfileImage is null) { return NotFound(); } @@ -1944,10 +1944,10 @@ namespace Jellyfin.Api.Controllers unplayedCount = null; } - if (imageInfo == null) + if (imageInfo is null) { imageInfo = item?.GetImageInfo(imageType, imageIndex ?? 0); - if (imageInfo == null) + if (imageInfo is null) { return NotFound(string.Format(NumberFormatInfo.InvariantInfo, "{0} does not have an image of type {1}", item?.Name, imageType)); } diff --git a/Jellyfin.Api/Controllers/ItemLookupController.cs b/Jellyfin.Api/Controllers/ItemLookupController.cs index c49f85616..34893d682 100644 --- a/Jellyfin.Api/Controllers/ItemLookupController.cs +++ b/Jellyfin.Api/Controllers/ItemLookupController.cs @@ -65,7 +65,7 @@ namespace Jellyfin.Api.Controllers public ActionResult<IEnumerable<ExternalIdInfo>> GetExternalIdInfos([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/ItemRefreshController.cs b/Jellyfin.Api/Controllers/ItemRefreshController.cs index 9340737b5..0dc3fbd05 100644 --- a/Jellyfin.Api/Controllers/ItemRefreshController.cs +++ b/Jellyfin.Api/Controllers/ItemRefreshController.cs @@ -61,7 +61,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] bool replaceAllImages = false) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/ItemUpdateController.cs b/Jellyfin.Api/Controllers/ItemUpdateController.cs index fd137f98f..5f992f033 100644 --- a/Jellyfin.Api/Controllers/ItemUpdateController.cs +++ b/Jellyfin.Api/Controllers/ItemUpdateController.cs @@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult> UpdateItem([FromRoute, Required] Guid itemId, [FromBody, Required] BaseItemDto request) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -198,7 +198,7 @@ namespace Jellyfin.Api.Controllers public ActionResult UpdateItemContentType([FromRoute, Required] Guid itemId, [FromQuery] string? contentType) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs index 7d5cfc7ae..80d1c008b 100644 --- a/Jellyfin.Api/Controllers/LibraryController.cs +++ b/Jellyfin.Api/Controllers/LibraryController.cs @@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers public ActionResult GetFile([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers : _libraryManager.GetUserRootFolder()) : _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found."); } @@ -171,7 +171,7 @@ namespace Jellyfin.Api.Controllers } var parent = item.GetParent(); - if (parent == null) + if (parent is null) { break; } @@ -220,7 +220,7 @@ namespace Jellyfin.Api.Controllers : _libraryManager.GetUserRootFolder()) : _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found."); } @@ -237,7 +237,7 @@ namespace Jellyfin.Api.Controllers } var parent = item.GetParent(); - if (parent == null) + if (parent is null) { break; } @@ -435,7 +435,7 @@ namespace Jellyfin.Api.Controllers { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found"); } @@ -610,7 +610,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult> GetDownload([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs index 394df0f58..94710d78f 100644 --- a/Jellyfin.Api/Controllers/LiveTvController.cs +++ b/Jellyfin.Api/Controllers/LiveTvController.cs @@ -763,7 +763,7 @@ namespace Jellyfin.Api.Controllers await AssertUserCanManageLiveTv().ConfigureAwait(false); var item = _libraryManager.GetItemById(recordingId); - if (item == null) + if (item is null) { return NotFound(); } @@ -840,7 +840,7 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult<SeriesTimerInfoDto>> GetSeriesTimer([FromRoute, Required] string timerId) { var timer = await _liveTvManager.GetSeriesTimer(timerId, CancellationToken.None).ConfigureAwait(false); - if (timer == null) + if (timer is null) { return NotFound(); } @@ -1201,7 +1201,7 @@ namespace Jellyfin.Api.Controllers public ActionResult GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container) { var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfoByUniqueId(streamId); - if (liveStreamInfo == null) + if (liveStreamInfo is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/MediaInfoController.cs b/Jellyfin.Api/Controllers/MediaInfoController.cs index c111e9218..be6453af9 100644 --- a/Jellyfin.Api/Controllers/MediaInfoController.cs +++ b/Jellyfin.Api/Controllers/MediaInfoController.cs @@ -121,7 +121,7 @@ namespace Jellyfin.Api.Controllers var profile = playbackInfoDto?.DeviceProfile; _logger.LogDebug("GetPostedPlaybackInfo profile: {@Profile}", profile); - if (profile == null) + if (profile is null) { var caps = _deviceManager.GetCapabilities(User.GetDeviceId()); if (caps != null) diff --git a/Jellyfin.Api/Controllers/PackageController.cs b/Jellyfin.Api/Controllers/PackageController.cs index 9690aead0..0aa7c2ac9 100644 --- a/Jellyfin.Api/Controllers/PackageController.cs +++ b/Jellyfin.Api/Controllers/PackageController.cs @@ -54,7 +54,7 @@ namespace Jellyfin.Api.Controllers assemblyGuid ?? default) .FirstOrDefault(); - if (result == null) + if (result is null) { return NotFound(); } @@ -110,7 +110,7 @@ namespace Jellyfin.Api.Controllers specificVersion: string.IsNullOrEmpty(version) ? null : Version.Parse(version)) .FirstOrDefault(); - if (package == null) + if (package is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs index 42be969b2..09f7281ec 100644 --- a/Jellyfin.Api/Controllers/PersonsController.cs +++ b/Jellyfin.Api/Controllers/PersonsController.cs @@ -122,7 +122,7 @@ namespace Jellyfin.Api.Controllers .AddClientFields(User); var item = _libraryManager.GetPerson(name); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs index fb045f891..e0c565da1 100644 --- a/Jellyfin.Api/Controllers/PlaylistsController.cs +++ b/Jellyfin.Api/Controllers/PlaylistsController.cs @@ -176,7 +176,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes) { var playlist = (Playlist)_libraryManager.GetItemById(playlistId); - if (playlist == null) + if (playlist is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/PlaystateController.cs b/Jellyfin.Api/Controllers/PlaystateController.cs index 3a2ba033e..58f9b7d35 100644 --- a/Jellyfin.Api/Controllers/PlaystateController.cs +++ b/Jellyfin.Api/Controllers/PlaystateController.cs @@ -353,7 +353,7 @@ namespace Jellyfin.Api.Controllers if (method == PlayMethod.Transcode) { var job = string.IsNullOrWhiteSpace(playSessionId) ? null : _transcodingJobHelper.GetTranscodingJob(playSessionId); - if (job == null) + if (job is null) { return PlayMethod.DirectPlay; } diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs index b227dba2d..361828fbd 100644 --- a/Jellyfin.Api/Controllers/PluginsController.cs +++ b/Jellyfin.Api/Controllers/PluginsController.cs @@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers public ActionResult EnablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version) { var plugin = _pluginManager.GetPlugin(pluginId, version); - if (plugin == null) + if (plugin is null) { return NotFound(); } @@ -95,7 +95,7 @@ namespace Jellyfin.Api.Controllers public ActionResult DisablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version) { var plugin = _pluginManager.GetPlugin(pluginId, version); - if (plugin == null) + if (plugin is null) { return NotFound(); } @@ -119,7 +119,7 @@ namespace Jellyfin.Api.Controllers public ActionResult UninstallPluginByVersion([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version) { var plugin = _pluginManager.GetPlugin(pluginId, version); - if (plugin == null) + if (plugin is null) { return NotFound(); } @@ -146,7 +146,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) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault(); + var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault(); if (plugin != null) { @@ -225,13 +225,13 @@ namespace Jellyfin.Api.Controllers public ActionResult GetPluginImage([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version) { var plugin = _pluginManager.GetPlugin(pluginId, version); - if (plugin == null) + if (plugin is null) { return NotFound(); } var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath ?? string.Empty); - if (plugin.Manifest.ImagePath == null || !System.IO.File.Exists(imagePath)) + if (plugin.Manifest.ImagePath is null || !System.IO.File.Exists(imagePath)) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/RemoteImageController.cs b/Jellyfin.Api/Controllers/RemoteImageController.cs index dbee56e14..da9e8cf90 100644 --- a/Jellyfin.Api/Controllers/RemoteImageController.cs +++ b/Jellyfin.Api/Controllers/RemoteImageController.cs @@ -68,7 +68,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] bool includeAllLanguages = false) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -127,7 +127,7 @@ namespace Jellyfin.Api.Controllers public ActionResult<IEnumerable<ImageProviderInfo>> GetRemoteImageProviders([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] string? imageUrl) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/ScheduledTasksController.cs b/Jellyfin.Api/Controllers/ScheduledTasksController.cs index 68e4f0586..832e14505 100644 --- a/Jellyfin.Api/Controllers/ScheduledTasksController.cs +++ b/Jellyfin.Api/Controllers/ScheduledTasksController.cs @@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers var task = _taskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, taskId, StringComparison.OrdinalIgnoreCase)); - if (task == null) + if (task is null) { return NotFound(); } @@ -99,7 +99,7 @@ namespace Jellyfin.Api.Controllers var task = _taskManager.ScheduledTasks.FirstOrDefault(o => o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase)); - if (task == null) + if (task is null) { return NotFound(); } @@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers var task = _taskManager.ScheduledTasks.FirstOrDefault(o => o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase)); - if (task == null) + if (task is null) { return NotFound(); } @@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers { var task = _taskManager.ScheduledTasks.FirstOrDefault(o => o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase)); - if (task == null) + if (task is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs index aeed0c0d6..3c0603a19 100644 --- a/Jellyfin.Api/Controllers/SearchController.cs +++ b/Jellyfin.Api/Controllers/SearchController.cs @@ -221,7 +221,7 @@ namespace Jellyfin.Api.Controllers { var itemWithImage = item.HasImage(ImageType.Thumb) ? item : null; - if (itemWithImage == null && item is Episode) + if (itemWithImage is null && item is Episode) { itemWithImage = GetParentWithImage<Series>(item, ImageType.Thumb); } diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs index 31b95162d..9218c3b5c 100644 --- a/Jellyfin.Api/Controllers/SessionController.cs +++ b/Jellyfin.Api/Controllers/SessionController.cs @@ -294,7 +294,7 @@ namespace Jellyfin.Api.Controllers { var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false); - if (command == null) + if (command is null) { throw new ArgumentException("Request body may not be null"); } diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.cs index 1258a9876..b9c2a8ad8 100644 --- a/Jellyfin.Api/Controllers/SubtitleController.cs +++ b/Jellyfin.Api/Controllers/SubtitleController.cs @@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs index ea13ceb91..7f4f4d077 100644 --- a/Jellyfin.Api/Controllers/TvShowsController.cs +++ b/Jellyfin.Api/Controllers/TvShowsController.cs @@ -247,7 +247,7 @@ namespace Jellyfin.Api.Controllers .GetSeasons(user, dtoOptions) .FirstOrDefault(i => i.IndexNumber == season.Value); - episodes = seasonItem == null ? + episodes = seasonItem is null ? new List<BaseItem>() : ((Season)seasonItem).GetEpisodes(user, dtoOptions); } diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs index ff653fe6b..4ee3361b5 100644 --- a/Jellyfin.Api/Controllers/UserController.cs +++ b/Jellyfin.Api/Controllers/UserController.cs @@ -124,7 +124,7 @@ namespace Jellyfin.Api.Controllers { var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound("User not found"); } @@ -173,7 +173,7 @@ namespace Jellyfin.Api.Controllers { var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound("User not found"); } @@ -272,7 +272,7 @@ namespace Jellyfin.Api.Controllers var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound("User not found"); } @@ -292,7 +292,7 @@ namespace Jellyfin.Api.Controllers HttpContext.GetNormalizedRemoteIp().ToString(), false).ConfigureAwait(false); - if (success == null) + if (success is null) { return StatusCode(StatusCodes.Status403Forbidden, "Invalid user or password entered."); } @@ -333,7 +333,7 @@ namespace Jellyfin.Api.Controllers var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound("User not found"); } @@ -544,7 +544,7 @@ namespace Jellyfin.Api.Controllers } var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return BadRequest(); } diff --git a/Jellyfin.Api/Controllers/UserLibraryController.cs b/Jellyfin.Api/Controllers/UserLibraryController.cs index 8a2d5a27d..60e190616 100644 --- a/Jellyfin.Api/Controllers/UserLibraryController.cs +++ b/Jellyfin.Api/Controllers/UserLibraryController.cs @@ -402,7 +402,7 @@ namespace Jellyfin.Api.Controllers { var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound(); } @@ -411,7 +411,7 @@ namespace Jellyfin.Api.Controllers ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/UserViewsController.cs b/Jellyfin.Api/Controllers/UserViewsController.cs index 85d154cac..3aeb444df 100644 --- a/Jellyfin.Api/Controllers/UserViewsController.cs +++ b/Jellyfin.Api/Controllers/UserViewsController.cs @@ -117,7 +117,7 @@ namespace Jellyfin.Api.Controllers public ActionResult<IEnumerable<SpecialViewOptionDto>> GetGroupingOptions([FromRoute, Required] Guid userId) { var user = _userManager.GetUserById(userId); - if (user == null) + if (user is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs index c2bb0dfff..bb3162614 100644 --- a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs +++ b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs @@ -55,7 +55,7 @@ namespace Jellyfin.Api.Controllers try { var item = _libraryManager.GetItemById(videoId); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/VideosController.cs b/Jellyfin.Api/Controllers/VideosController.cs index bf08ad376..17e556730 100644 --- a/Jellyfin.Api/Controllers/VideosController.cs +++ b/Jellyfin.Api/Controllers/VideosController.cs @@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers { var video = (Video)_libraryManager.GetItemById(itemId); - if (video == null) + if (video is null) { return NotFound("The video either does not exist or the id does not belong to a video."); } @@ -199,7 +199,7 @@ namespace Jellyfin.Api.Controllers } var primaryVersion = items.FirstOrDefault(i => i.MediaSourceCount > 1 && string.IsNullOrEmpty(i.PrimaryVersionId)); - if (primaryVersion == null) + if (primaryVersion is null) { primaryVersion = items .OrderBy(i => @@ -444,7 +444,7 @@ namespace Jellyfin.Api.Controllers StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager); var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId); - if (liveStreamInfo == null) + if (liveStreamInfo is null) { return NotFound(); } diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs index b732bdff3..f8193f19a 100644 --- a/Jellyfin.Api/Controllers/YearsController.cs +++ b/Jellyfin.Api/Controllers/YearsController.cs @@ -173,7 +173,7 @@ namespace Jellyfin.Api.Controllers public ActionResult<BaseItemDto> GetYear([FromRoute, Required] int year, [FromQuery] Guid? userId) { var item = _libraryManager.GetYear(year); - if (item == null) + if (item is null) { return NotFound(); } diff --git a/Jellyfin.Api/Helpers/AudioHelper.cs b/Jellyfin.Api/Helpers/AudioHelper.cs index bc83ff48a..5c5a2fc34 100644 --- a/Jellyfin.Api/Helpers/AudioHelper.cs +++ b/Jellyfin.Api/Helpers/AudioHelper.cs @@ -85,7 +85,7 @@ namespace Jellyfin.Api.Helpers TranscodingJobType transcodingJobType, StreamingRequestDto streamingRequest) { - if (_httpContextAccessor.HttpContext == null) + if (_httpContextAccessor.HttpContext is null) { throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext)); } @@ -116,7 +116,7 @@ namespace Jellyfin.Api.Helpers StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager); var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId); - if (liveStreamInfo == null) + if (liveStreamInfo is null) { throw new FileNotFoundException(); } diff --git a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs index ee672cab4..904021a86 100644 --- a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs +++ b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs @@ -117,7 +117,7 @@ namespace Jellyfin.Api.Helpers TranscodingJobType transcodingJobType, CancellationTokenSource cancellationTokenSource) { - if (_httpContextAccessor.HttpContext == null) + if (_httpContextAccessor.HttpContext is null) { throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext)); } @@ -271,7 +271,7 @@ namespace Jellyfin.Api.Helpers if (EnableAdaptiveBitrateStreaming(state, isLiveStream, enableAdaptiveBitrateStreaming, _httpContextAccessor.HttpContext.GetNormalizedRemoteIp())) { - var requestedVideoBitrate = state.VideoRequest == null ? 0 : state.VideoRequest.VideoBitRate ?? 0; + var requestedVideoBitrate = state.VideoRequest is null ? 0 : state.VideoRequest.VideoBitRate ?? 0; // By default, vary by just 200k var variation = GetBitrateVariation(totalBitrate); @@ -483,7 +483,7 @@ namespace Jellyfin.Api.Helpers return; } - var selectedIndex = state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Hls ? (int?)null : state.SubtitleStream.Index; + var selectedIndex = state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Hls ? (int?)null : state.SubtitleStream.Index; const string Format = "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"subs\",NAME=\"{0}\",DEFAULT={1},FORCED={2},AUTOSELECT=YES,URI=\"{3}\",LANGUAGE=\"{4}\""; foreach (var stream in subtitles) diff --git a/Jellyfin.Api/Helpers/HlsHelpers.cs b/Jellyfin.Api/Helpers/HlsHelpers.cs index 456762147..0f6d2aef7 100644 --- a/Jellyfin.Api/Helpers/HlsHelpers.cs +++ b/Jellyfin.Api/Helpers/HlsHelpers.cs @@ -47,7 +47,7 @@ namespace Jellyfin.Api.Helpers while (!reader.EndOfStream) { var line = await reader.ReadLineAsync().ConfigureAwait(false); - if (line == null) + if (line is null) { // Nothing currently in buffer. break; diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs index 4441ae023..6134fb727 100644 --- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs +++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs @@ -390,7 +390,7 @@ namespace Jellyfin.Api.Helpers var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false); var profile = request.DeviceProfile; - if (profile == null) + if (profile is null) { var clientCapabilities = _deviceManager.GetCapabilities(httpContext.User.GetDeviceId()); if (clientCapabilities != null) diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index 8c5af013a..035d84513 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -96,7 +96,7 @@ namespace Jellyfin.Api.Helpers httpContext.GetNormalizedRemoteIp().ToString(), user).ConfigureAwait(false); - if (session == null) + if (session is null) { throw new ArgumentException("Session not found."); } diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index c8e62999c..5e01b7dcc 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -76,7 +76,7 @@ namespace Jellyfin.Api.Helpers } streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query); - if (httpRequest.Path.Value == null) + if (httpRequest.Path.Value is null) { throw new ResourceNotFoundException(nameof(httpRequest.Path)); } @@ -142,7 +142,7 @@ namespace Jellyfin.Api.Helpers mediaSource = currentJob.MediaSource; } - if (mediaSource == null) + if (mediaSource is null) { var mediaSources = await mediaSourceManager.GetPlaybackMediaSources(libraryManager.GetItemById(streamingRequest.Id), null, false, false, cancellationToken).ConfigureAwait(false); @@ -150,7 +150,7 @@ namespace Jellyfin.Api.Helpers ? mediaSources[0] : mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.Ordinal)); - if (mediaSource == null && Guid.Parse(streamingRequest.MediaSourceId).Equals(streamingRequest.Id)) + if (mediaSource is null && Guid.Parse(streamingRequest.MediaSourceId).Equals(streamingRequest.Id)) { mediaSource = mediaSources[0]; } @@ -510,16 +510,16 @@ namespace Jellyfin.Api.Helpers { state.DeviceProfile = dlnaManager.GetProfile(deviceProfileId); - if (state.DeviceProfile == null) + if (state.DeviceProfile is null) { var caps = deviceManager.GetCapabilities(deviceProfileId); - state.DeviceProfile = caps == null ? dlnaManager.GetProfile(request.Headers) : caps.DeviceProfile; + state.DeviceProfile = caps is null ? dlnaManager.GetProfile(request.Headers) : caps.DeviceProfile; } } var profile = state.DeviceProfile; - if (profile == null) + if (profile is null) { // Don't use settings from the default profile. // Only use a specific profile if it was requested. diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs index c663c6e31..592f22d8d 100644 --- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs +++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs @@ -829,7 +829,7 @@ namespace Jellyfin.Api.Helpers { var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && string.Equals(j.Path, path, StringComparison.OrdinalIgnoreCase)); - if (job == null) + if (job is null) { return null; } diff --git a/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs b/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs index 2ccfd0c06..da0addd0e 100644 --- a/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs +++ b/Jellyfin.Api/ModelBinders/NullableEnumModelBinderProvider.cs @@ -14,7 +14,7 @@ namespace Jellyfin.Api.ModelBinders public IModelBinder? GetBinder(ModelBinderProviderContext context) { var nullableType = Nullable.GetUnderlyingType(context.Metadata.ModelType); - if (nullableType == null || !nullableType.IsEnum) + if (nullableType is null || !nullableType.IsEnum) { // Type isn't nullable or isn't an enum. return null; diff --git a/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs b/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs index ab67c8732..bb0f51936 100644 --- a/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs +++ b/Jellyfin.Api/Models/PlaybackDtos/TranscodingJobDto.cs @@ -220,7 +220,7 @@ namespace Jellyfin.Api.Models.PlaybackDtos lock (_timerLock) { - if (KillTimer == null) + if (KillTimer is null) { Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite); diff --git a/Jellyfin.Data/Entities/User.cs b/Jellyfin.Data/Entities/User.cs index 26c46a704..e2cd659e7 100644 --- a/Jellyfin.Data/Entities/User.cs +++ b/Jellyfin.Data/Entities/User.cs @@ -373,7 +373,7 @@ namespace Jellyfin.Data.Entities public void SetPermission(PermissionKind kind, bool value) { var currentPermission = Permissions.FirstOrDefault(p => p.Kind == kind); - if (currentPermission == null) + if (currentPermission is null) { Permissions.Add(new Permission(kind, value)); } @@ -442,7 +442,7 @@ namespace Jellyfin.Data.Entities { var value = string.Join(Delimiter, values); var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference); - if (currentPreference == null) + if (currentPreference is null) { Preferences.Add(new Preference(preference, value)); } @@ -462,7 +462,7 @@ namespace Jellyfin.Data.Entities { var value = string.Join(Delimiter, values); var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference); - if (currentPreference == null) + if (currentPreference is null) { Preferences.Add(new Preference(preference, value)); } diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 84b261b54..02b69398e 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -250,7 +250,7 @@ namespace Jellyfin.Drawing.Skia var resultBitmap = SKBitmap.Decode(NormalizePath(path)); - if (resultBitmap == null) + if (resultBitmap is null) { return Decode(path, true, orientation, out origin); } @@ -414,7 +414,7 @@ namespace Jellyfin.Drawing.Skia var hasIndicator = options.AddPlayedIndicator || options.UnplayedCount.HasValue || !options.PercentPlayed.Equals(0); using var bitmap = GetBitmap(inputPath, autoOrient, orientation); - if (bitmap == null) + if (bitmap is null) { throw new InvalidDataException($"Skia unable to read image {inputPath}"); } diff --git a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs index e5fa6c2bd..7fbae3349 100644 --- a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs +++ b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs @@ -85,7 +85,7 @@ namespace Jellyfin.Drawing.Skia break; } - if (currentImage == null) + if (currentImage is null) { throw new ArgumentException("Not enough valid pictures provided to create a splashscreen!"); } diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs index b55a99405..c8b8f3ace 100644 --- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs +++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs @@ -97,7 +97,7 @@ namespace Jellyfin.Drawing.Skia canvas.Clear(SKColors.Black); using var backdrop = SkiaHelper.GetNextValidImage(_skiaEncoder, paths, 0, out _); - if (backdrop == null) + if (backdrop is null) { return bitmap; } @@ -164,7 +164,7 @@ namespace Jellyfin.Drawing.Skia using var currentBitmap = SkiaHelper.GetNextValidImage(_skiaEncoder, paths, imageIndex, out int newIndex); imageIndex = newIndex; - if (currentBitmap == null) + if (currentBitmap is null) { continue; } diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.cs index 9e06cdfe7..519b68161 100644 --- a/Jellyfin.Networking/Manager/NetworkManager.cs +++ b/Jellyfin.Networking/Manager/NetworkManager.cs @@ -232,7 +232,7 @@ namespace Jellyfin.Networking.Manager public Collection<IPObject> CreateIPCollection(string[] values, bool negated = false) { Collection<IPObject> col = new Collection<IPObject>(); - if (values == null) + if (values is null) { return col; } @@ -515,7 +515,7 @@ namespace Jellyfin.Networking.Manager /// <inheritdoc/> public Collection<IPObject> GetFilteredLANSubnets(Collection<IPObject>? filter = null) { - if (filter == null) + if (filter is null) { return _lanSubnets.Exclude(_excludedSubnets, true).AsNetworks(); } @@ -880,7 +880,7 @@ namespace Jellyfin.Networking.Manager { _publishedServerUrls.Clear(); string[] overrides = config.PublishedServerUriBySubnet; - if (overrides == null) + if (overrides is null) { return; } @@ -1235,12 +1235,12 @@ namespace Jellyfin.Networking.Manager // Find all external bind addresses. Store the default gateway, but check to see if there is a better match first. foreach (var addr in addresses.OrderBy(p => p.Tag)) { - if (defaultGateway == null && !IsInLocalNetwork(addr)) + if (defaultGateway is null && !IsInLocalNetwork(addr)) { defaultGateway = addr.Address; } - if (bindAddress == null && addr.Contains(source)) + if (bindAddress is null && addr.Contains(source)) { bindAddress = addr.Address; } diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index eeb958c62..321a16d47 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -55,7 +55,7 @@ namespace Jellyfin.Server.Implementations.Devices await using (dbContext.ConfigureAwait(false)) { deviceOptions = await dbContext.DeviceOptions.AsQueryable().FirstOrDefaultAsync(dev => dev.DeviceId == deviceId).ConfigureAwait(false); - if (deviceOptions == null) + if (deviceOptions is null) { deviceOptions = new DeviceOptions(deviceId); dbContext.DeviceOptions.Add(deviceOptions); @@ -121,7 +121,7 @@ namespace Jellyfin.Server.Implementations.Devices .ConfigureAwait(false); } - var deviceInfo = device == null ? null : ToDeviceInfo(device); + var deviceInfo = device is null ? null : ToDeviceInfo(device); return deviceInfo; } diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs index aa6015caa..bb98a6c34 100644 --- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs +++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs @@ -38,7 +38,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session /// <inheritdoc /> public async Task OnEvent(PlaybackStartEventArgs eventArgs) { - if (eventArgs.MediaInfo == null) + if (eventArgs.MediaInfo is null) { _logger.LogWarning("PlaybackStart reported with null media info."); return; diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs index 1648b1b47..baa957390 100644 --- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs +++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs @@ -40,7 +40,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session { var item = eventArgs.MediaInfo; - if (item == null) + if (item is null) { _logger.LogWarning("PlaybackStopped reported with null media info."); return; @@ -60,7 +60,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session var user = eventArgs.Users[0]; var notificationType = GetPlaybackStoppedNotificationType(item.MediaType); - if (notificationType == null) + if (notificationType is null) { return; } diff --git a/Jellyfin.Server.Implementations/Events/EventManager.cs b/Jellyfin.Server.Implementations/Events/EventManager.cs index 7f7c4750d..f49ae8e27 100644 --- a/Jellyfin.Server.Implementations/Events/EventManager.cs +++ b/Jellyfin.Server.Implementations/Events/EventManager.cs @@ -44,7 +44,7 @@ namespace Jellyfin.Server.Implementations.Events where T : EventArgs { using var scope = _appHost.ServiceProvider?.CreateScope(); - if (scope == null) + if (scope is null) { return; } diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs index f98a0aede..05c622931 100644 --- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs +++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs @@ -27,7 +27,7 @@ public static class ServiceCollectionExtensions .UseCacheKeyPrefix("EF_") // Don't cache null values. Remove this optional setting if it's not necessary. .SkipCachingResults(result => - result.Value == null || (result.Value is EFTableRows rows && rows.RowsCount == 0))); + result.Value is null || (result.Value is EFTableRows rows && rows.RowsCount == 0))); serviceCollection.AddPooledDbContextFactory<JellyfinDb>((serviceProvider, opt) => { diff --git a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs index 33c08c8c2..810e57807 100644 --- a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs +++ b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs @@ -65,7 +65,7 @@ namespace Jellyfin.Server.Implementations.Security .FirstOrDefaultAsync() .ConfigureAwait(false); - if (key == null) + if (key is null) { return; } diff --git a/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs b/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs index 7480a05c2..72f3d6e8e 100644 --- a/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs +++ b/Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs @@ -41,7 +41,7 @@ namespace Jellyfin.Server.Implementations.Users // This is the version that we need to use for local users. Because reasons. public Task<ProviderAuthenticationResult> Authenticate(string username, string password, User resolvedUser) { - if (resolvedUser == null) + if (resolvedUser is null) { throw new AuthenticationException("Specified user does not exist."); } @@ -58,7 +58,7 @@ namespace Jellyfin.Server.Implementations.Users } // Handle the case when the stored password is null, but the user tried to login with a password - if (resolvedUser.Password == null) + if (resolvedUser.Password is null) { throw new AuthenticationException("Invalid username or password"); } diff --git a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs index 87babc05c..fddad1c4f 100644 --- a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs +++ b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs @@ -34,7 +34,7 @@ namespace Jellyfin.Server.Implementations.Users .FirstOrDefault(pref => pref.UserId.Equals(userId) && string.Equals(pref.Client, client) && pref.ItemId.Equals(itemId)); - if (prefs == null) + if (prefs is null) { prefs = new DisplayPreferences(userId, itemId, client); _dbContext.DisplayPreferences.Add(prefs); @@ -49,7 +49,7 @@ namespace Jellyfin.Server.Implementations.Users var prefs = _dbContext.ItemDisplayPreferences .FirstOrDefault(pref => pref.UserId.Equals(userId) && pref.ItemId.Equals(itemId) && string.Equals(pref.Client, client)); - if (prefs == null) + if (prefs is null) { prefs = new ItemDisplayPreferences(userId, Guid.Empty, client); _dbContext.ItemDisplayPreferences.Add(prefs); diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index 25560707a..131853aed 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -401,7 +401,7 @@ namespace Jellyfin.Server.Implementations.Users var authenticationProvider = authResult.AuthenticationProvider; var success = authResult.Success; - if (user == null) + if (user is null) { string updatedUsername = authResult.Username; @@ -434,7 +434,7 @@ namespace Jellyfin.Server.Implementations.Users } } - if (user == null) + if (user is null) { _logger.LogInformation( "Authentication request for {UserName} has been denied (IP: {IP}).", @@ -708,7 +708,7 @@ namespace Jellyfin.Server.Implementations.Users /// <inheritdoc/> public async Task ClearProfileImageAsync(User user) { - if (user.ProfileImage == null) + if (user.ProfileImage is null) { return; } diff --git a/Jellyfin.Server/Filters/FileResponseFilter.cs b/Jellyfin.Server/Filters/FileResponseFilter.cs index eae9a8004..544fdbfd6 100644 --- a/Jellyfin.Server/Filters/FileResponseFilter.cs +++ b/Jellyfin.Server/Filters/FileResponseFilter.cs @@ -31,7 +31,7 @@ namespace Jellyfin.Server.Filters .FirstOrDefault(o => o.Key.Equals(SuccessCode, StringComparison.Ordinal)); // Operation doesn't have a response. - if (response.Value == null) + if (response.Value is null) { continue; } diff --git a/Jellyfin.Server/Formatters/CssOutputFormatter.cs b/Jellyfin.Server/Formatters/CssOutputFormatter.cs index cfc9d1ad3..fdaa48f84 100644 --- a/Jellyfin.Server/Formatters/CssOutputFormatter.cs +++ b/Jellyfin.Server/Formatters/CssOutputFormatter.cs @@ -30,7 +30,7 @@ namespace Jellyfin.Server.Formatters public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) { var stringResponse = context.Object?.ToString(); - return stringResponse == null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse); + return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse); } } } diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs index be0baea2d..156368d69 100644 --- a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs +++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs @@ -27,7 +27,7 @@ namespace Jellyfin.Server.Formatters public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) { var stringResponse = context.Object?.ToString(); - return stringResponse == null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse); + return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse); } } } diff --git a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs index 37716482c..0fad77cfe 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs @@ -91,7 +91,7 @@ namespace Jellyfin.Server.Migrations.Routines foreach (var result in results) { var dto = JsonSerializer.Deserialize<DisplayPreferencesDto>(result[3].ToBlob(), _jsonOptions); - if (dto == null) + if (dto is null) { continue; } @@ -108,7 +108,7 @@ namespace Jellyfin.Server.Migrations.Routines displayPrefs.Add(displayPreferencesKey); var existingUser = _userManager.GetUserById(dtoUserId); - if (existingUser == null) + if (existingUser is null) { _logger.LogWarning("User with ID {UserId} does not exist in the database, skipping migration.", dtoUserId); continue; diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs index 0c2cc69a7..2dbd82e8f 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs @@ -76,7 +76,7 @@ namespace Jellyfin.Server.Migrations.Routines foreach (var entry in queryResult) { UserMockup? mockup = JsonSerializer.Deserialize<UserMockup>(entry[2].ToBlob(), JsonDefaults.Options); - if (mockup == null) + if (mockup is null) { continue; } diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 7ed838825..b0455aafb 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -677,7 +677,7 @@ namespace Jellyfin.Server { var xdgRuntimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR"); var socketFile = "jellyfin.sock"; - if (xdgRuntimeDir == null) + if (xdgRuntimeDir is null) { // Fall back to config dir socketPath = Path.Join(appPaths.ConfigurationDirectoryPath, socketFile); diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs index 1e5877c84..6608704c0 100644 --- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -15,8 +15,8 @@ namespace MediaBrowser.Common.Extensions /// <returns><c>true</c> if the request is coming from LAN, <c>false</c> otherwise.</returns> public static bool IsLocal(this HttpContext context) { - return (context.Connection.LocalIpAddress == null - && context.Connection.RemoteIpAddress == null) + return (context.Connection.LocalIpAddress is null + && context.Connection.RemoteIpAddress is null) || Equals(context.Connection.LocalIpAddress, context.Connection.RemoteIpAddress); } diff --git a/MediaBrowser.Common/Net/NetworkExtensions.cs b/MediaBrowser.Common/Net/NetworkExtensions.cs index 7ad005854..5e5e5b81b 100644 --- a/MediaBrowser.Common/Net/NetworkExtensions.cs +++ b/MediaBrowser.Common/Net/NetworkExtensions.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Common.Net /// <returns>True if both are equal.</returns> public static bool Compare(this Collection<IPObject> source, Collection<IPObject> dest) { - if (dest == null || source.Count != dest.Count) + if (dest is null || source.Count != dest.Count) { return false; } @@ -187,7 +187,7 @@ namespace MediaBrowser.Common.Net /// <returns>A new collection, with the items excluded.</returns> public static Collection<IPObject> Exclude(this Collection<IPObject> source, Collection<IPObject> excludeList, bool isNetwork) { - if (source.Count == 0 || excludeList == null) + if (source.Count == 0 || excludeList is null) { return new Collection<IPObject>(source); } diff --git a/MediaBrowser.Common/Plugins/BasePluginOfT.cs b/MediaBrowser.Common/Plugins/BasePluginOfT.cs index 0da5592d3..19db30cb8 100644 --- a/MediaBrowser.Common/Plugins/BasePluginOfT.cs +++ b/MediaBrowser.Common/Plugins/BasePluginOfT.cs @@ -103,7 +103,7 @@ namespace MediaBrowser.Common.Plugins get { // Lazy load - if (_configuration == null) + if (_configuration is null) { lock (_configurationSyncLock) { diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index 4c8e2d504..96af423cc 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Plugins { get { - if (_version == null) + if (_version is null) { _version = Version.Parse(Manifest.Version); } @@ -85,9 +85,9 @@ namespace MediaBrowser.Common.Plugins /// <returns>Comparison result.</returns> public static int Compare(LocalPlugin a, LocalPlugin b) { - if (a == null || b == null) + if (a is null || b is null) { - throw new ArgumentNullException(a == null ? nameof(a) : nameof(b)); + throw new ArgumentNullException(a is null ? nameof(a) : nameof(b)); } var compare = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); @@ -128,7 +128,7 @@ namespace MediaBrowser.Common.Plugins /// <inheritdoc /> public bool Equals(LocalPlugin? other) { - if (other == null) + if (other is null) { return false; } diff --git a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs index 61539cae5..b0e394dc5 100644 --- a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs +++ b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs @@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.BaseItemManager var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase)); - return itemConfig == null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); + return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } /// <inheritdoc /> @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.BaseItemManager var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase)); - return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); + return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } /// <summary> diff --git a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs index b036425ab..62b70ce53 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Drawing { var imageInfo = item.GetImageInfo(imageType, imageIndex); - if (imageInfo == null) + if (imageInfo is null) { return null; } diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index e671e5c71..4dc78ff86 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Controller.Entities { lock (_childIdsLock) { - if (_childrenIds == null || _childrenIds.Length == 0) + if (_childrenIds is null || _childrenIds.Length == 0) { var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToArray(); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 7f5f9f74b..20f009588 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -494,7 +494,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (_sortName == null) + if (_sortName is null) { if (!string.IsNullOrEmpty(ForcedSortName)) { @@ -880,7 +880,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> protected virtual string CreateSortName() { - if (Name == null) + if (Name is null) { return null; // some items may not have name filled in properly } @@ -1073,7 +1073,7 @@ namespace MediaBrowser.Controller.Entities { var stream = i.VideoStream; - return stream == null || stream.Width == null ? 0 : stream.Width.Value; + return stream is null || stream.Width is null ? 0 : stream.Width.Value; }) .ToList(); } @@ -1330,7 +1330,7 @@ namespace MediaBrowser.Controller.Entities public void SetParent(Folder parent) { - ParentId = parent == null ? Guid.Empty : parent.Id; + ParentId = parent is null ? Guid.Empty : parent.Id; } /// <summary> @@ -1534,7 +1534,7 @@ namespace MediaBrowser.Controller.Entities var maxAllowedRating = user.MaxParentalAgeRating; - if (maxAllowedRating == null) + if (maxAllowedRating is null) { return true; } @@ -1701,7 +1701,7 @@ namespace MediaBrowser.Controller.Entities var item = FindLinkedChild(info); // If still null, log - if (item == null) + if (item is null) { // Don't keep searching over and over info.ItemId = Guid.Empty; @@ -1725,7 +1725,7 @@ namespace MediaBrowser.Controller.Entities var itemByPath = LibraryManager.FindByPath(path, null); - if (itemByPath == null) + if (itemByPath is null) { Logger.LogWarning("Unable to find linked item at path {0}", info.Path); } @@ -1737,7 +1737,7 @@ namespace MediaBrowser.Controller.Entities { var item = LibraryManager.GetItemById(info.LibraryItemId); - if (item == null) + if (item is null) { Logger.LogWarning("Unable to find linked item at path {0}", info.Path); } @@ -1892,7 +1892,7 @@ namespace MediaBrowser.Controller.Entities var existingImage = GetImageInfo(image.Type, index); - if (existingImage == null) + if (existingImage is null) { AddImage(image); } @@ -1915,7 +1915,7 @@ namespace MediaBrowser.Controller.Entities var image = GetImageInfo(type, index); - if (image == null) + if (image is null) { AddImage(GetImageInfo(file, type)); } @@ -1942,7 +1942,7 @@ namespace MediaBrowser.Controller.Entities { var info = GetImageInfo(type, index); - if (info == null) + if (info is null) { // Nothing to do return; @@ -2035,7 +2035,7 @@ namespace MediaBrowser.Controller.Entities { var chapter = ItemRepository.GetChapter(this, imageIndex); - if (chapter == null) + if (chapter is null) { return null; } @@ -2147,7 +2147,7 @@ namespace MediaBrowser.Controller.Entities foreach (var newImage in images) { - if (newImage == null) + if (newImage is null) { throw new ArgumentException("null image found in list"); } @@ -2155,7 +2155,7 @@ namespace MediaBrowser.Controller.Entities var existing = existingImages .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase)); - if (existing == null) + if (existing is null) { newImageList.Add(newImage); } @@ -2241,7 +2241,7 @@ namespace MediaBrowser.Controller.Entities var info1 = GetImageInfo(type, index1); var info2 = GetImageInfo(type, index2); - if (info1 == null || info2 == null) + if (info1 is null || info2 is null) { // Nothing to do return Task.CompletedTask; @@ -2290,7 +2290,7 @@ namespace MediaBrowser.Controller.Entities var userdata = UserDataManager.GetUserData(user, this); - return userdata == null || !userdata.Played; + return userdata is null || !userdata.Played; } ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo() @@ -2445,14 +2445,14 @@ namespace MediaBrowser.Controller.Entities // Try to retrieve it from the db. If we don't find it, use the resolved version var video = LibraryManager.GetItemById(id) as Video; - if (video == null) + if (video is null) { video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video; newOptions.ForceSave = true; } - if (video == null) + if (video is null) { return Task.FromResult(true); } diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs index 948eb4375..dc06bf9bd 100644 --- a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs +++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Entities } var v = sourceProp.GetValue(source); - if (v == null) + if (v is null) { continue; } diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs index 1acb92fdc..d4a779390 100644 --- a/MediaBrowser.Controller/Entities/Extensions.cs +++ b/MediaBrowser.Controller/Entities/Extensions.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Entities var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase)); - if (current == null) + if (current is null) { var mediaUrl = new MediaUrl { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 808f91810..9ef5504af 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -703,7 +703,7 @@ namespace MediaBrowser.Controller.Entities IEnumerable<BaseItem> items; Func<BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager); - if (query.User == null) + if (query.User is null) { items = GetRecursiveChildren(filter); } @@ -961,7 +961,7 @@ namespace MediaBrowser.Controller.Entities IEnumerable<BaseItem> items; - if (query.User == null) + if (query.User is null) { items = Children.Where(filter); } @@ -1311,7 +1311,7 @@ namespace MediaBrowser.Controller.Entities } // If there are not sub-folders, proceed as normal. - if (children == null) + if (children is null) { children = GetEligibleChildrenForRecursiveChildren(user); } @@ -1320,7 +1320,7 @@ namespace MediaBrowser.Controller.Entities { bool? isVisibleToUser = null; - if (query == null || UserViewBuilder.FilterItem(child, query)) + if (query is null || UserViewBuilder.FilterItem(child, query)) { isVisibleToUser = child.IsVisible(user); @@ -1345,7 +1345,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in GetLinkedChildren(user)) { - if (query == null || UserViewBuilder.FilterItem(child, query)) + if (query is null || UserViewBuilder.FilterItem(child, query)) { if (child.IsVisible(user)) { @@ -1402,7 +1402,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in Children) { - if (filter == null || filter(child)) + if (filter is null || filter(child)) { result[child.Id] = child; } @@ -1420,7 +1420,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in GetLinkedChildren()) { - if (filter == null || filter(child)) + if (filter is null || filter(child)) { result[child.Id] = child; } @@ -1478,7 +1478,7 @@ namespace MediaBrowser.Controller.Entities public List<BaseItem> GetLinkedChildren(User user) { - if (!FilterLinkedChildrenPerUser || user == null) + if (!FilterLinkedChildrenPerUser || user is null) { return GetLinkedChildren(); } @@ -1504,7 +1504,7 @@ namespace MediaBrowser.Controller.Entities { var child = GetLinkedChild(i); - if (child == null) + if (child is null) { continue; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 1bf528538..fc019c0ee 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -316,7 +316,7 @@ namespace MediaBrowser.Controller.Entities { set { - if (value == null) + if (value is null) { ParentId = Guid.Empty; ParentType = null; diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs index ea8555dbf..0171af27c 100644 --- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs +++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs @@ -39,6 +39,6 @@ namespace MediaBrowser.Controller.Entities public string BlurHash { get; set; } [JsonIgnore] - public bool IsLocalFile => Path == null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase); + public bool IsLocalFile => Path is null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase); } } diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs index 8571bfcea..46d969ffe 100644 --- a/MediaBrowser.Controller/Entities/PeopleHelper.cs +++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs @@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.Entities { // If the actor already exists without a role and we have one, fill it in var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))); - if (existing == null) + if (existing is null) { // Wasn't there - add it people.Add(person); @@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities string.Equals(p.Type, person.Type, StringComparison.OrdinalIgnoreCase)); // Check for dupes based on the combination of Name and Type - if (existing == null) + if (existing is null) { people.Add(person); } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 15b721fe6..2d9cdb8d0 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesSortName() { var series = Series; - return series == null ? SeriesName : series.SortName; + return series is null ? SeriesName : series.SortName; } public override double GetDefaultPrimaryImageAspectRatio() @@ -181,14 +181,14 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesPresentationUniqueKey() { var series = Series; - return series == null ? null : series.PresentationUniqueKey; + return series is null ? null : series.PresentationUniqueKey; } public string FindSeasonName() { var season = Season; - if (season == null) + if (season is null) { if (ParentIndexNumber.HasValue) { @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesName() { var series = Series; - return series == null ? SeriesName : series.Name; + return series is null ? SeriesName : series.Name; } public Guid FindSeasonId() @@ -212,7 +212,7 @@ namespace MediaBrowser.Controller.Entities.TV var season = FindParent<Season>(); // Episodes directly in series folder - if (season == null) + if (season is null) { var series = Series; @@ -226,7 +226,7 @@ namespace MediaBrowser.Controller.Entities.TV } } - return season == null ? Guid.Empty : season.Id; + return season is null ? Guid.Empty : season.Id; } /// <summary> @@ -262,7 +262,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid FindSeriesId() { var series = FindParent<Series>(); - return series == null ? Guid.Empty : series.Id; + return series is null ? Guid.Empty : series.Id; } public override IEnumerable<Guid> GetAncestorIds() diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 599d35da6..19fe16c8f 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesSortName() { var series = Series; - return series == null ? SeriesName : series.SortName; + return series is null ? SeriesName : series.SortName; } public override List<string> GetUserDataKeys() @@ -149,7 +149,7 @@ namespace MediaBrowser.Controller.Entities.TV protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) { - if (query.User == null) + if (query.User is null) { return base.GetItemsInternal(query); } @@ -208,13 +208,13 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesPresentationUniqueKey() { var series = Series; - return series == null ? null : series.PresentationUniqueKey; + return series is null ? null : series.PresentationUniqueKey; } public string FindSeriesName() { var series = Series; - return series == null ? SeriesName : series.Name; + return series is null ? SeriesName : series.Name; } public Guid FindSeriesId() diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index d66802a64..069071ee5 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -266,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.TV DtoOptions = options }; - if (user == null || !user.DisplayMissingEpisodes) + if (user is null || !user.DisplayMissingEpisodes) { query.IsMissing = false; } @@ -384,7 +384,7 @@ namespace MediaBrowser.Controller.Entities.TV public List<BaseItem> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<BaseItem> allSeriesEpisodes, DtoOptions options) { - if (allSeriesEpisodes == null) + if (allSeriesEpisodes is null) { return GetSeasonEpisodes(parentSeason, user, options); } diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index e547db523..b19b1fa13 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Entities { lock (_childIdsLock) { - if (_childrenIds == null) + if (_childrenIds is null) { var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToList(); diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index f467a6038..7ebf9e5f8 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -559,7 +559,7 @@ namespace MediaBrowser.Controller.Entities var val = query.Is3D.Value; var video = item as Video; - if (video == null || val != video.Video3DFormat.HasValue) + if (video is null || val != video.Video3DFormat.HasValue) { return false; } @@ -689,7 +689,7 @@ namespace MediaBrowser.Controller.Entities var video = item as Video; - if (video == null || val != video.HasSubtitles) + if (video is null || val != video.HasSubtitles) { return false; } @@ -776,7 +776,7 @@ namespace MediaBrowser.Controller.Entities if (query.VideoTypes.Length > 0) { var video = item as Video; - if (video == null || !query.VideoTypes.Contains(video.VideoType)) + if (video is null || !query.VideoTypes.Contains(video.VideoType)) { return false; } @@ -913,7 +913,7 @@ namespace MediaBrowser.Controller.Entities { var episode = item as Episode; - if (episode == null) + if (episode is null) { return false; } @@ -929,7 +929,7 @@ namespace MediaBrowser.Controller.Entities private IEnumerable<BaseItem> GetMediaFolders(User user) { - if (user == null) + if (user is null) { return _libraryManager.RootFolder .Children @@ -945,7 +945,7 @@ namespace MediaBrowser.Controller.Entities private BaseItem[] GetMediaFolders(User user, IEnumerable<string> viewTypes) { - if (user == null) + if (user is null) { return GetMediaFolders(null) .Where(i => @@ -967,7 +967,7 @@ namespace MediaBrowser.Controller.Entities private BaseItem[] GetMediaFolders(Folder parent, User user, IEnumerable<string> viewTypes) { - if (parent == null || parent is UserView) + if (parent is null || parent is UserView) { return GetMediaFolders(user, viewTypes); } diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 91d162b41..f93c890fe 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Library public LibraryOptions LibraryOptions { - get => _libraryOptions ??= Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent); + get => _libraryOptions ??= Parent is null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent); set => _libraryOptions = value; } @@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Library get { var paths = string.IsNullOrEmpty(Path) ? Array.Empty<string>() : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); + return AdditionalLocations is null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } @@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Library // Just in case the user decided to nest episodes. // Not officially supported but in some cases we can handle it. - if (item == null) + if (item is null) { var parents = parent.GetParents(); foreach (var currentParent in parents) @@ -289,7 +289,7 @@ namespace MediaBrowser.Controller.Library { if (args != null) { - if (args.Path == null && Path == null) + if (args.Path is null && Path is null) { return true; } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 9d78b8b6c..919570e89 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Library private static string RemoveDiacritics(string? name) { - if (name == null) + if (name is null) { return string.Empty; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 335222da9..978826042 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Controller.LiveTv Path = Path, RunTimeTicks = RunTimeTicks, Type = MediaSourceType.Placeholder, - IsInfiniteStream = RunTimeTicks == null + IsInfiniteStream = RunTimeTicks is null }; list.Add(info); diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index fae53acbf..d423a2fbe 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -162,7 +162,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null + if (state.VideoStream is null || !options.EnableTonemapping || GetVideoColorBitDepth(state) != 10) { @@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsVulkanHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null) + if (state.VideoStream is null) { return false; } @@ -202,7 +202,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsVaapiVppTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null + if (state.VideoStream is null || !options.EnableVppTonemapping || GetVideoColorBitDepth(state) != 10) { @@ -1066,7 +1066,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetVideoBitrateParam(EncodingJobInfo state, string videoCodec) { - if (state.OutputVideoBitrate == null) + if (state.OutputVideoBitrate is null) { return string.Empty; } @@ -2076,7 +2076,7 @@ namespace MediaBrowser.Controller.MediaEncoding public int? GetAudioBitrateParam(int? audioBitRate, string audioCodec, MediaStream audioStream) { - if (audioStream == null) + if (audioStream is null) { return null; } @@ -2167,7 +2167,7 @@ namespace MediaBrowser.Controller.MediaEncoding /// <returns>System.Nullable{System.Int32}.</returns> public int? GetNumAudioChannelsParam(EncodingJobInfo state, MediaStream audioStream, string outputAudioCodec) { - if (audioStream == null) + if (audioStream is null) { return null; } @@ -2320,7 +2320,7 @@ namespace MediaBrowser.Controller.MediaEncoding // If we don't have known media info // If input is video, use -sn to drop subtitles // Otherwise just return empty - if (state.VideoStream == null && state.AudioStream == null) + if (state.VideoStream is null && state.AudioStream is null) { return state.IsInputVideo ? "-sn" : string.Empty; } @@ -2385,7 +2385,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var subtitleMethod = state.SubtitleDeliveryMethod; - if (state.SubtitleStream == null || subtitleMethod == SubtitleDeliveryMethod.Hls) + if (state.SubtitleStream is null || subtitleMethod == SubtitleDeliveryMethod.Hls) { args += " -map -0:s"; } @@ -2731,7 +2731,7 @@ namespace MediaBrowser.Controller.MediaEncoding } // default - if (filter == null) + if (filter is null) { if (requestedHeight > 0) { @@ -4440,7 +4440,7 @@ namespace MediaBrowser.Controller.MediaEncoding string outputVideoCodec) { var videoStream = state.VideoStream; - if (videoStream == null) + if (videoStream is null) { return string.Empty; } @@ -4623,7 +4623,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var videoStream = state.VideoStream; var mediaSource = state.MediaSource; - if (videoStream == null || mediaSource == null) + if (videoStream is null || mediaSource is null) { return null; } @@ -5469,7 +5469,7 @@ namespace MediaBrowser.Controller.MediaEncoding return; } - var inputChannels = audioStream == null ? 6 : audioStream.Channels ?? 6; + var inputChannels = audioStream is null ? 6 : audioStream.Channels ?? 6; if (inputChannels >= 6) { return; @@ -5521,7 +5521,7 @@ namespace MediaBrowser.Controller.MediaEncoding private void NormalizeSubtitleEmbed(EncodingJobInfo state) { - if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) + if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) { return; } @@ -5536,7 +5536,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetSubtitleEmbedArguments(EncodingJobInfo state) { - if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) + if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) { return string.Empty; } @@ -5694,7 +5694,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetProgressiveVideoAudioArguments(EncodingJobInfo state, EncodingOptions encodingOptions) { // If the video doesn't have an audio stream, return a default. - if (state.AudioStream == null && state.VideoStream != null) + if (state.AudioStream is null && state.VideoStream != null) { return string.Empty; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index c9625cf1d..5d13cb8ed 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.MediaEncoding { if (!_transcodeReasons.HasValue) { - if (BaseRequest.TranscodeReasons == null) + if (BaseRequest.TranscodeReasons is null) { _transcodeReasons = 0; return 0; @@ -305,7 +305,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (BaseRequest.Static || EncodingHelper.IsCopyCodec(OutputVideoCodec)) { - return VideoStream == null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate); + return VideoStream is null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate); } return BaseRequest.MaxFramerate ?? BaseRequest.Framerate; @@ -419,7 +419,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (VideoStream == null) + if (VideoStream is null) { return null; } @@ -437,7 +437,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (AudioStream == null) + if (AudioStream is null) { return null; } diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 58a0fa2a9..952dd4870 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -59,7 +59,7 @@ namespace MediaBrowser.Controller.Providers /// </summary> public void ResetPeople() { - if (People == null) + if (People is null) { People = new List<PersonInfo>(); } @@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Providers } } - if (userData == null) + if (userData is null) { userData = new UserItemData() { diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index b4520ae48..d30472f22 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null) + if (Capabilities is null) { return Array.Empty<string>(); } @@ -182,7 +182,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null || !Capabilities.SupportsMediaControl) + if (Capabilities is null || !Capabilities.SupportsMediaControl) { return false; } @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null || !Capabilities.SupportsMediaControl) + if (Capabilities is null || !Capabilities.SupportsMediaControl) { return false; } @@ -239,7 +239,7 @@ namespace MediaBrowser.Controller.Session /// </summary> /// <value>The supported commands.</value> public IReadOnlyList<GeneralCommandType> SupportedCommands - => Capabilities == null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands; + => Capabilities is null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands; public Tuple<ISessionController, bool> EnsureController<T>(Func<SessionInfo, ISessionController> factory) { @@ -296,7 +296,7 @@ namespace MediaBrowser.Controller.Session { _lastProgressInfo = progressInfo; - if (_progressTimer == null) + if (_progressTimer is null) { _progressTimer = new Timer(OnProgressTimerCallback, null, 1000, 1000); } @@ -315,7 +315,7 @@ namespace MediaBrowser.Controller.Session } var progressInfo = _lastProgressInfo; - if (progressInfo == null) + if (progressInfo is null) { return; } diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs index 9f8e921b4..548ccee2d 100644 --- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.LocalMetadata var file = GetXmlFile(info, directoryService); - if (file == null) + if (file is null) { return Task.FromResult(result); } @@ -98,7 +98,7 @@ namespace MediaBrowser.LocalMetadata { var file = GetXmlFile(new ItemInfo(item), directoryService); - if (file == null) + if (file is null) { return false; } diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index dc13bf4f6..a8e2946f1 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.LocalMetadata.Images public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService) { var parentPath = Path.GetDirectoryName(item.Path); - if (parentPath == null) + if (parentPath is null) { return Enumerable.Empty<LocalImageInfo>(); } diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index 70fd68129..e92c4f83e 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -453,7 +453,7 @@ namespace MediaBrowser.LocalMetadata.Images { var image = GetImage(files, name, prefix); - if (image == null) + if (image is null) { return false; } diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs index 22abf93ac..0ee2bdd38 100644 --- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs +++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs @@ -62,14 +62,14 @@ namespace MediaBrowser.MediaEncoding.Attachments var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false); var mediaSource = mediaSources .FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase)); - if (mediaSource == null) + if (mediaSource is null) { throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found"); } var mediaAttachment = mediaSource.MediaAttachments .FirstOrDefault(i => i.Index == attachmentStreamIndex); - if (mediaAttachment == null) + if (mediaAttachment is null) { throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}"); } diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index 6ebaa4fff..bde3d2e84 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo MediaStreams = Array.Empty<MediaStream>() }; - if (playlist == null) + if (playlist is null) { return outputStream; } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 8c8fc6b0f..1ae3c976d 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -190,7 +190,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.LogInformation("Found ffmpeg version {Version}", version != null ? version.ToString() : "unknown"); - if (version == null) + if (version is null) { if (MaxVersion != null) // Version is unknown { diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index e50aa679a..9abfb9102 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -531,7 +531,7 @@ namespace MediaBrowser.MediaEncoding.Encoder throw; } - if (result == null || (result.Streams == null && result.Format == null)) + if (result is null || (result.Streams is null && result.Format is null)) { throw new FfmpegException("ffprobe failed - streams and format are both null."); } diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 417f1520f..d5e90e855 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -156,7 +156,7 @@ namespace MediaBrowser.MediaEncoding.Probing else { var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist"); - info.Artists = artist == null + info.Artists = artist is null ? Array.Empty<string>() : SplitDistinctArtists(artist, _nameDelimiters, true).ToArray(); } @@ -989,7 +989,7 @@ namespace MediaBrowser.MediaEncoding.Probing /// <returns>System.String.</returns> private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key) { - if (tags == null) + if (tags is null) { return null; } @@ -1121,7 +1121,7 @@ namespace MediaBrowser.MediaEncoding.Probing { // Get the first info stream var stream = result.Streams?.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase)); - if (stream == null) + if (stream is null) { return; } @@ -1144,7 +1144,7 @@ namespace MediaBrowser.MediaEncoding.Probing private int? GetBPSFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1161,7 +1161,7 @@ namespace MediaBrowser.MediaEncoding.Probing private double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1177,7 +1177,7 @@ namespace MediaBrowser.MediaEncoding.Probing private long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo) { - if (streamInfo?.Tags == null) + if (streamInfo?.Tags is null) { return null; } @@ -1195,7 +1195,7 @@ namespace MediaBrowser.MediaEncoding.Probing private void SetSize(InternalMediaInfoResult data, MediaInfo info) { - if (data.Format == null) + if (data.Format is null) { return; } @@ -1510,7 +1510,7 @@ namespace MediaBrowser.MediaEncoding.Probing { var tags = data.Format?.Tags; - if (tags == null) + if (tags is null) { return; } diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs index 33755e746..df4018fdd 100644 --- a/MediaBrowser.Model/Dlna/AudioOptions.cs +++ b/MediaBrowser.Model/Dlna/AudioOptions.cs @@ -77,7 +77,7 @@ namespace MediaBrowser.Model.Dlna return MaxBitrate; } - if (Profile == null) + if (Profile is null) { return null; } diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index c6befdd85..9f7654a69 100644 --- a/MediaBrowser.Model/Dlna/ContainerProfile.cs +++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Model.Dlna public static bool ContainsContainer(string[]? profileContainers, bool isNegativeList, string? inputContainer) { - if (profileContainers == null || profileContainers.Length == 0) + if (profileContainers is null || profileContainers.Length == 0) { // Empty profiles always support all containers/codecs return true; diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 6e9b943f7..94112ab16 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -247,7 +247,7 @@ namespace MediaBrowser.Model.Dlna if (profile != null) { - var playProfiles = playProfile == null ? profile.DirectPlayProfiles : new[] { playProfile }; + var playProfiles = playProfile is null ? profile.DirectPlayProfiles : new[] { playProfile }; foreach (var format in formats) { foreach (var directPlayProfile in playProfiles) @@ -370,7 +370,7 @@ namespace MediaBrowser.Model.Dlna var directPlayProfile = options.Profile.DirectPlayProfiles .FirstOrDefault(x => x.Type == DlnaProfileType.Audio && IsAudioDirectPlaySupported(x, item, audioStream)); - if (directPlayProfile == null) + if (directPlayProfile is null) { _logger.LogDebug( "Profile: {0}, No audio direct play profiles found for {1} with codec {2}", @@ -422,7 +422,7 @@ namespace MediaBrowser.Model.Dlna private static TranscodeReason GetTranscodeReasonsFromDirectPlayProfile(MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream, IEnumerable<DirectPlayProfile> directPlayProfiles) { - var mediaType = videoStream == null ? DlnaProfileType.Audio : DlnaProfileType.Video; + var mediaType = videoStream is null ? DlnaProfileType.Audio : DlnaProfileType.Video; var containerSupported = false; var audioSupported = false; @@ -436,9 +436,9 @@ namespace MediaBrowser.Model.Dlna { containerSupported = true; - videoSupported = videoStream == null || profile.SupportsVideoCodec(videoStream.Codec); + videoSupported = videoStream is null || profile.SupportsVideoCodec(videoStream.Codec); - audioSupported = audioStream == null || profile.SupportsAudioCodec(audioStream.Codec); + audioSupported = audioStream is null || profile.SupportsAudioCodec(audioStream.Codec); if (videoSupported && audioSupported) { @@ -586,7 +586,7 @@ namespace MediaBrowser.Model.Dlna } // Collect candidate audio streams - ICollection<MediaStream> candidateAudioStreams = audioStream == null ? Array.Empty<MediaStream>() : new[] { audioStream }; + ICollection<MediaStream> candidateAudioStreams = audioStream is null ? Array.Empty<MediaStream>() : new[] { audioStream }; if (!options.AudioStreamIndex.HasValue || options.AudioStreamIndex < 0) { if (audioStream?.IsDefault == true) @@ -729,8 +729,8 @@ namespace MediaBrowser.Model.Dlna if (options.AllowVideoStreamCopy) { // prefer direct copy profile - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : item.Timestamp; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : item.Timestamp; int? numAudioStreams = item.GetStreamCount(MediaStreamType.Audio); int? numVideoStreams = item.GetStreamCount(MediaStreamType.Video); @@ -832,13 +832,13 @@ namespace MediaBrowser.Model.Dlna double? videoLevel = videoStream?.Level; string videoProfile = videoStream?.Profile; string videoRangeType = videoStream?.VideoRangeType; - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; bool? isAnamorphic = videoStream?.IsAnamorphic; bool? isInterlaced = videoStream?.IsInterlaced; string videoCodecTag = videoStream?.CodecTag; bool? isAvc = videoStream?.IsAVC; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : item.Timestamp; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : item.Timestamp; int? packetLength = videoStream?.PacketLength; int? refFrames = videoStream?.RefFrames; @@ -870,12 +870,12 @@ namespace MediaBrowser.Model.Dlna int audioBitrate = GetAudioBitrate(options.GetMaxBitrate(false) ?? 0, playlistItem.TargetAudioCodec, audioStream, playlistItem); playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate); - bool? isSecondaryAudio = audioStream == null ? null : item.IsSecondaryAudio(audioStream); - int? inputAudioBitrate = audioStream == null ? null : audioStream.BitRate; - int? audioChannels = audioStream == null ? null : audioStream.Channels; - string audioProfile = audioStream == null ? null : audioStream.Profile; - int? inputAudioSampleRate = audioStream == null ? null : audioStream.SampleRate; - int? inputAudioBitDepth = audioStream == null ? null : audioStream.BitDepth; + bool? isSecondaryAudio = audioStream is null ? null : item.IsSecondaryAudio(audioStream); + int? inputAudioBitrate = audioStream is null ? null : audioStream.BitRate; + int? audioChannels = audioStream is null ? null : audioStream.Channels; + string audioProfile = audioStream is null ? null : audioStream.Profile; + int? inputAudioSampleRate = audioStream is null ? null : audioStream.SampleRate; + int? inputAudioBitDepth = audioStream is null ? null : audioStream.BitDepth; var appliedAudioConditions = options.Profile.CodecProfiles .Where(i => i.Type == CodecType.VideoAudio && @@ -965,7 +965,7 @@ namespace MediaBrowser.Model.Dlna int defaultBitrate; int encoderAudioBitrateLimit = int.MaxValue; - if (audioStream == null) + if (audioStream is null) { defaultBitrate = 192000; } @@ -1080,13 +1080,13 @@ namespace MediaBrowser.Model.Dlna double? videoLevel = videoStream?.Level; string videoProfile = videoStream?.Profile; string videoRangeType = videoStream?.VideoRangeType; - float videoFramerate = videoStream == null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; + float videoFramerate = videoStream is null ? 0 : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate ?? 0; bool? isAnamorphic = videoStream?.IsAnamorphic; bool? isInterlaced = videoStream?.IsInterlaced; string videoCodecTag = videoStream?.CodecTag; bool? isAvc = videoStream?.IsAVC; - TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : mediaSource.Timestamp; + TransportStreamTimestamp? timestamp = videoStream is null ? TransportStreamTimestamp.None : mediaSource.Timestamp; int? packetLength = videoStream?.PacketLength; int? refFrames = videoStream?.RefFrames; @@ -1177,7 +1177,7 @@ namespace MediaBrowser.Model.Dlna if (candidateAudioStreams.Any()) { selectedAudioStream = candidateAudioStreams.FirstOrDefault(audioStream => directPlayProfile.SupportsAudioCodec(audioStream.Codec)); - if (selectedAudioStream == null) + if (selectedAudioStream is null) { directPlayProfileReasons |= TranscodeReason.AudioCodecNotSupported; } @@ -1501,12 +1501,12 @@ namespace MediaBrowser.Model.Dlna throw new ArgumentException("DeviceId is required"); } - if (options.Profile == null) + if (options.Profile is null) { throw new ArgumentException("Profile is required"); } - if (options.MediaSources == null) + if (options.MediaSources is null) { throw new ArgumentException("MediaSources is required"); } diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 5cfa2e7e3..b82f233ae 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -215,7 +215,7 @@ namespace MediaBrowser.Model.Dlna var stream = TargetVideoStream; return MaxFramerate.HasValue && !IsDirectStream ? MaxFramerate - : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; + : stream is null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; } } @@ -460,7 +460,7 @@ namespace MediaBrowser.Model.Dlna return !IsDirectStream ? defaultValue - : MediaSource == null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None; + : MediaSource is null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None; } } diff --git a/MediaBrowser.Model/Drawing/DrawingUtils.cs b/MediaBrowser.Model/Drawing/DrawingUtils.cs index 556792768..2040d26bb 100644 --- a/MediaBrowser.Model/Drawing/DrawingUtils.cs +++ b/MediaBrowser.Model/Drawing/DrawingUtils.cs @@ -71,18 +71,18 @@ namespace MediaBrowser.Model.Drawing int? fillHeight) { // Return original size if input is invalid. - if ((fillWidth == null || fillWidth == 0) - && (fillHeight == null || fillHeight == 0)) + if ((fillWidth is null || fillWidth == 0) + && (fillHeight is null || fillHeight == 0)) { return size; } - if (fillWidth == null || fillWidth == 0) + if (fillWidth is null || fillWidth == 0) { fillWidth = 1; } - if (fillHeight == null || fillHeight == 0) + if (fillHeight is null || fillHeight == 0) { fillHeight = 1; } diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index c348e83ae..520832aee 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -134,7 +134,7 @@ namespace MediaBrowser.Model.Dto public void InferTotalBitrate(bool force = false) { - if (MediaStreams == null) + if (MediaStreams is null) { return; } diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index d3b8400f3..cf453d62c 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Model.Entities { ArgumentNullException.ThrowIfNull(instance); - if (instance.ProviderIds == null) + if (instance.ProviderIds is null) { id = null; return false; diff --git a/MediaBrowser.Model/Notifications/NotificationOptions.cs b/MediaBrowser.Model/Notifications/NotificationOptions.cs index d1b5491bd..8708d55f7 100644 --- a/MediaBrowser.Model/Notifications/NotificationOptions.cs +++ b/MediaBrowser.Model/Notifications/NotificationOptions.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Model.Notifications { NotificationOption opt = GetOptions(notificationType); - return opt == null + return opt is null || !opt.DisabledServices.Contains(service, StringComparison.OrdinalIgnoreCase); } diff --git a/MediaBrowser.Model/Updates/VersionInfo.cs b/MediaBrowser.Model/Updates/VersionInfo.cs index 03a540dde..320199f98 100644 --- a/MediaBrowser.Model/Updates/VersionInfo.cs +++ b/MediaBrowser.Model/Updates/VersionInfo.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Model.Updates [JsonPropertyName("version")] public string Version { - get => _version == null ? string.Empty : _version.ToString(); + get => _version is null ? string.Empty : _version.ToString(); set => _version = SysVersion.Parse(value); } diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index cbbb343e5..df9d15ec2 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -66,7 +66,7 @@ namespace MediaBrowser.Providers.BoxSets var libraryFolderIds = item.GetLibraryFolderIds(); var itemLibraryFolderIds = item.LibraryFolderIds; - if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds)) + if (itemLibraryFolderIds is null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds)) { item.LibraryFolderIds = libraryFolderIds; updatedType |= ItemUpdateType.MetadataImport; diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index bbbbfad54..23e9cbd34 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -399,7 +399,7 @@ namespace MediaBrowser.Providers.Manager { var currentImage = item.GetImageInfo(type, 0); - if (currentImage == null || !string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase)) + if (currentImage is null || !string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase)) { item.SetImagePath(type, image.FileInfo); changed = true; @@ -471,7 +471,7 @@ namespace MediaBrowser.Providers.Manager CancellationToken cancellationToken) { var eligibleImages = images - .Where(i => i.Type == type && (i.Width == null || i.Width >= minWidth)) + .Where(i => i.Type == type && (i.Width is null || i.Width >= minWidth)) .ToList(); if (EnableImageStub(item) && eligibleImages.Count > 0) @@ -539,7 +539,7 @@ namespace MediaBrowser.Providers.Manager if (item is IItemByName and not MusicArtist) { var hasDualAccess = item as IHasDualAccess; - if (hasDualAccess == null || hasDualAccess.IsAccessedByName) + if (hasDualAccess is null || hasDualAccess.IsAccessedByName) { return true; } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 0f3f1bdcb..8bd1b487d 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -918,12 +918,12 @@ namespace MediaBrowser.Providers.Manager var source = sourceResult.Item; var target = targetResult.Item; - if (source == null) + if (source is null) { throw new ArgumentException("Item cannot be null.", nameof(sourceResult)); } - if (target == null) + if (target is null) { throw new ArgumentException("Item cannot be null.", nameof(targetResult)); } @@ -1005,7 +1005,7 @@ namespace MediaBrowser.Providers.Manager if (!lockedFields.Contains(MetadataField.Cast)) { - if (replaceData || targetResult.People == null || targetResult.People.Count == 0) + if (replaceData || targetResult.People is null || targetResult.People.Count == 0) { targetResult.People = sourceResult.People; } @@ -1178,7 +1178,7 @@ namespace MediaBrowser.Providers.Manager { if (source is Video sourceCast && target is Video targetCast) { - if (replaceData || targetCast.Video3DFormat == null) + if (replaceData || targetCast.Video3DFormat is null) { targetCast.Video3DFormat = sourceCast.Video3DFormat; } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index ac4dc1bc3..07d6b2b5e 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -135,7 +135,7 @@ namespace MediaBrowser.Providers.Manager var service = _metadataServices.FirstOrDefault(current => current.CanRefreshPrimary(type)); service ??= _metadataServices.FirstOrDefault(current => current.CanRefresh(item)); - if (service == null) + if (service is null) { _logger.LogError("Unable to find a metadata service for item of type {TypeName}", item.GetType().Name); return Task.FromResult(ItemUpdateType.None); @@ -660,7 +660,7 @@ namespace MediaBrowser.Providers.Manager if (!includeDisabled) { - if (libraryOptions.MetadataSavers == null) + if (libraryOptions.MetadataSavers is null) { if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparison.OrdinalIgnoreCase)) { @@ -725,7 +725,7 @@ namespace MediaBrowser.Providers.Manager { LibraryOptions libraryOptions; - if (referenceItem == null) + if (referenceItem is null) { // Give it a dummy path just so that it looks like a file system item var dummy = new TItemType @@ -776,7 +776,7 @@ namespace MediaBrowser.Providers.Manager { var existingMatch = resultList.FirstOrDefault(i => i.ProviderIds.Any(p => string.Equals(result.GetProviderId(p.Key), p.Value, StringComparison.OrdinalIgnoreCase))); - if (existingMatch == null) + if (existingMatch is null) { resultList.Add(result); } @@ -831,7 +831,7 @@ namespace MediaBrowser.Providers.Manager { var provider = _metadataProviders.OfType<IRemoteSearchProvider>().FirstOrDefault(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase)); - if (provider == null) + if (provider is null) { throw new ArgumentException("Search provider not found."); } @@ -1002,7 +1002,7 @@ namespace MediaBrowser.Providers.Manager try { var item = libraryManager.GetItemById(refreshItem.Item1); - if (item == null) + if (item is null) { continue; } diff --git a/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs b/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs index d60d829de..a326de18f 100644 --- a/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs @@ -162,7 +162,7 @@ namespace MediaBrowser.Providers.MediaInfo && imageFileNames.Any(name => stream.Comment.Contains(name, StringComparison.OrdinalIgnoreCase))); // Primary type only: default to first image if none found by label - if (imageStream == null) + if (imageStream is null) { if (type == ImageType.Primary) { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 7412a10d0..5bd0c90ce 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -195,7 +195,7 @@ namespace MediaBrowser.Providers.MediaInfo // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); // For DVDs this may not always be accurate, so don't set the runtime if the item already has one - var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0; + var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks is null || video.RunTimeTicks.Value == 0; if (needToSetRuntime) { @@ -572,7 +572,7 @@ namespace MediaBrowser.Providers.MediaInfo bool requirePerfectMatch; bool enabled; - if (libraryOptions.SubtitleDownloadLanguages == null) + if (libraryOptions.SubtitleDownloadLanguages is null) { subtitleDownloadLanguages = subtitleOptions.DownloadLanguages; skipIfEmbeddedSubtitlesPresent = subtitleOptions.SkipIfEmbeddedSubtitlesPresent; diff --git a/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs index 75f997a28..3bdc92796 100644 --- a/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/ProbeProvider.cs @@ -108,7 +108,7 @@ namespace MediaBrowser.Providers.MediaInfo public bool HasChanged(BaseItem item, IDirectoryService directoryService) { var video = item as Video; - if (video == null || video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso) + if (video is null || video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso) { var path = item.Path; diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs index eb9071a52..f21939d2a 100644 --- a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs +++ b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.MediaInfo bool skipIfEmbeddedSubtitlesPresent; bool skipIfAudioTrackMatches; - if (libraryOptions.SubtitleDownloadLanguages == null) + if (libraryOptions.SubtitleDownloadLanguages is null) { subtitleDownloadLanguages = options.DownloadLanguages; skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent; @@ -172,7 +172,7 @@ namespace MediaBrowser.Providers.MediaInfo bool skipIfAudioTrackMatches; bool requirePerfectMatch; - if (libraryOptions.SubtitleDownloadLanguages == null) + if (libraryOptions.SubtitleDownloadLanguages is null) { subtitleDownloadLanguages = options.DownloadLanguages; skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent; diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index d4bf62970..ba7ad4072 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -89,14 +89,14 @@ namespace MediaBrowser.Providers.MediaInfo var query = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex }; var videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault(); - if (videoStream == null) + if (videoStream is null) { query.Type = MediaStreamType.Video; query.Index = null; videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault(); } - if (videoStream == null) + if (videoStream is null) { _logger.LogInformation("Skipping image extraction: no video stream found for {Path}.", item.Path ?? string.Empty); return new DynamicImageResponse { HasImage = false }; diff --git a/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs b/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs index 8bfdc461e..38379ae5d 100644 --- a/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs +++ b/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableInt32Converter.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb if (reader.TokenType == JsonTokenType.String) { var str = reader.GetString(); - if (str == null || str.Equals("N/A", StringComparison.OrdinalIgnoreCase)) + if (str is null || str.Equals("N/A", StringComparison.OrdinalIgnoreCase)) { return null; } diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs index 10077e5c8..d3e5c9ee0 100644 --- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb var seasonResult = await GetSeasonRootObject(seriesImdbId, seasonNumber, cancellationToken).ConfigureAwait(false); - if (seasonResult?.Episodes == null) + if (seasonResult?.Episodes is null) { return false; } @@ -161,7 +161,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb } // finally, search by numbers - if (result == null) + if (result is null) { foreach (var episode in seasonResult.Episodes) { @@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb } } - if (result == null) + if (result is null) { return false; } diff --git a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs index ffbb338e8..4ff9e0247 100644 --- a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.Plugins.StudioImages var imageInfo = GetImage(item, thumbsPath, ImageType.Thumb, "thumb"); - if (imageInfo == null) + if (imageInfo is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs index ef878e670..20898d213 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetImageProvider.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets // TODO use image languages if All Languages isn't toggled, but there's currently no way to get that value in here var collection = await _tmdbClientManager.GetCollectionAsync(tmdbId, null, null, cancellationToken).ConfigureAwait(false); - if (collection?.Images == null) + if (collection?.Images is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs index 90f2aa88f..0a8583205 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets { var collection = await _tmdbClientManager.GetCollectionAsync(tmdbId, language, TmdbUtils.GetImageLanguagesParam(language), cancellationToken).ConfigureAwait(false); - if (collection == null) + if (collection is null) { return Enumerable.Empty<RemoteSearchResult>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs index 1646a93d2..55e96f1fe 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieImageProvider.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies .GetMovieAsync(movieTmdbId, null, null, cancellationToken) .ConfigureAwait(false); - if (movie?.Images == null) + if (movie?.Images is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs index dd2d5d97d..4f9dfb3ef 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs @@ -177,7 +177,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies .GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken) .ConfigureAwait(false); - if (movieResult == null) + if (movieResult is null) { return new MetadataResult<Movie>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs index d7f5c99dd..aa46d8f25 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonImageProvider.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People var language = item.GetPreferredMetadataLanguage(); var personResult = await _tmdbClientManager.GetPersonAsync(int.Parse(personTmdbId, CultureInfo.InvariantCulture), language, cancellationToken).ConfigureAwait(false); - if (personResult?.Images?.Profiles == null) + if (personResult?.Images?.Profiles is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs index 943a3a75b..127d41cc7 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeImageProvider.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV .ConfigureAwait(false); var stills = episodeResult?.Images?.Stills; - if (stills == null) + if (stills is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs index e20284e6f..d003017ff 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs @@ -107,7 +107,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV .GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken) .ConfigureAwait(false); - if (episodeResult == null) + if (episodeResult is null) { return metadataResult; } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs index da32ea408..fda00537d 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonImageProvider.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV var seriesTmdbId = Convert.ToInt32(series?.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture); - if (seriesTmdbId <= 0 || season?.IndexNumber == null) + if (seriesTmdbId <= 0 || season?.IndexNumber is null) { return Enumerable.Empty<RemoteImageInfo>(); } @@ -75,7 +75,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV .ConfigureAwait(false); var posters = seasonResult?.Images?.Posters; - if (posters == null) + if (posters is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs index 2cf0f399e..e38af68a6 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV .GetSeasonAsync(Convert.ToInt32(seriesTmdbId, CultureInfo.InvariantCulture), seasonNumber.Value, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken) .ConfigureAwait(false); - if (seasonResult == null) + if (seasonResult is null) { return result; } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs index e96b680b4..9062f1b85 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesImageProvider.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV .GetSeriesAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), null, null, cancellationToken) .ConfigureAwait(false); - if (series?.Images == null) + if (series?.Images is null) { return Enumerable.Empty<RemoteImageInfo>(); } diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs index 7d7733407..7f943a7b6 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs @@ -174,7 +174,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb string.Equals(displayOrder, "tv", StringComparison.Ordinal) ? TvGroupType.TV : null; - if (groupType == null) + if (groupType is null) { return null; } @@ -190,7 +190,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb var series = await GetSeriesAsync(tvShowId, language, imageLanguages, cancellationToken).ConfigureAwait(false); var episodeGroupId = series?.EpisodeGroups.Results.Find(g => g.Type == groupType)?.Id; - if (episodeGroupId == null) + if (episodeGroupId is null) { return null; } diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index c09b6d813..a261d7cdb 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.TV targetItem.Status = sourceItem.Status; } - if (replaceData || targetItem.AirDays == null || targetItem.AirDays.Length == 0) + if (replaceData || targetItem.AirDays is null || targetItem.AirDays.Length == 0) { targetItem.AirDays = sourceItem.AirDays; } @@ -201,7 +201,7 @@ namespace MediaBrowser.Providers.TV var seasonNumber = episode.ParentIndexNumber >= 0 ? episode.ParentIndexNumber : null; var existingSeason = seasons.FirstOrDefault(i => i.IndexNumber == seasonNumber); - if (existingSeason == null) + if (existingSeason is null) { var season = await CreateSeasonAsync(series, seasonNumber, cancellationToken).ConfigureAwait(false); seasons.Add(season); diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 9e197e737..d31c07d14 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -85,7 +85,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers /// <exception cref="ArgumentException"><c>metadataFile</c> is <c>null</c> or empty.</exception> public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken) { - if (item.Item == null) + if (item.Item is null) { throw new ArgumentException("Item can't be null.", nameof(item)); } @@ -880,7 +880,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers var fileSystemMetadata = _directoryService.GetFile(val); // non existing file returns null - if (fileSystemMetadata == null || !fileSystemMetadata.Exists) + if (fileSystemMetadata is null || !fileSystemMetadata.Exists) { Logger.LogWarning("Artwork file {Path} specified in nfo file for {ItemName} does not exist.", uri, itemResult.Item.Name); return; diff --git a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs index abd3e78d7..af581fc5d 100644 --- a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs +++ b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.XbmcMetadata.Providers var file = GetXmlFile(info, directoryService); - if (file == null) + if (file is null) { return Task.FromResult(result); } @@ -64,7 +64,7 @@ namespace MediaBrowser.XbmcMetadata.Providers { var file = GetXmlFile(new ItemInfo(item), directoryService); - if (file == null) + if (file is null) { return false; } diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 740ca4c49..9eae87b3b 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -855,7 +855,7 @@ namespace MediaBrowser.XbmcMetadata.Savers var user = userManager.GetUserById(Guid.Parse(userId)); - if (user == null) + if (user is null) { return; } diff --git a/src/Jellyfin.Extensions/AlphanumericComparator.cs b/src/Jellyfin.Extensions/AlphanumericComparator.cs index 98a32d5b2..1b19752bb 100644 --- a/src/Jellyfin.Extensions/AlphanumericComparator.cs +++ b/src/Jellyfin.Extensions/AlphanumericComparator.cs @@ -16,15 +16,15 @@ namespace Jellyfin.Extensions /// <returns>A signed integer that indicates the relative values of <c>x</c> and <c>y</c>.</returns> public static int CompareValues(string? s1, string? s2) { - if (s1 == null && s2 == null) + if (s1 is null && s2 is null) { return 0; } - else if (s1 == null) + else if (s1 is null) { return -1; } - else if (s2 == null) + else if (s2 is null) { return 1; } diff --git a/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs b/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs index e1bd2fe0f..a36c3b7c1 100644 --- a/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs +++ b/tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs @@ -472,7 +472,7 @@ namespace Jellyfin.Model.Tests } } } - else if (playMethod == null) + else if (playMethod is null) { Assert.Null(val.SubProtocol); Assert.Equal("stream", uri.Filename); diff --git a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs index 1762b91b9..511a014a6 100644 --- a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs @@ -61,7 +61,7 @@ namespace Jellyfin.Naming.Tests.Video Assert.Equal(is3D, result.Is3D); - if (format3D == null) + if (format3D is null) { Assert.Null(result?.Format3D); } diff --git a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs index 79f2366b8..0ebcf5d81 100644 --- a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs @@ -25,7 +25,7 @@ namespace Jellyfin.Naming.Tests.Video files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(), _namingOptions).ToList(); - Assert.Single(result.Where(v => v.ExtraType == null)); + Assert.Single(result.Where(v => v.ExtraType is null)); Assert.Single(result.Where(v => v.ExtraType != null)); } @@ -44,7 +44,7 @@ namespace Jellyfin.Naming.Tests.Video files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(), _namingOptions).ToList(); - Assert.Single(result.Where(v => v.ExtraType == null)); + Assert.Single(result.Where(v => v.ExtraType is null)); Assert.Single(result.Where(v => v.ExtraType != null)); Assert.Equal(2, result[0].AlternateVersions.Count); } diff --git a/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs b/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs index 28b2e1d8f..f94d6717b 100644 --- a/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs +++ b/tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs @@ -328,11 +328,11 @@ namespace Jellyfin.Providers.Tests.Manager People = oldValue }; - var lockedFields = lockField == null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField }; + var lockedFields = lockField is null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField }; MetadataService<Movie, MovieInfo>.MergeBaseItemData(source, target, lockedFields, replaceData, false); actualValue = target.People; - return newValue?.Equals(actualValue) ?? actualValue == null; + return newValue?.Equals(actualValue) ?? actualValue is null; } /// <summary> @@ -367,12 +367,12 @@ namespace Jellyfin.Providers.Tests.Manager }; property.SetValue(target.Item, oldValue); - var lockedFields = lockField == null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField }; + var lockedFields = lockField is null ? Array.Empty<MetadataField>() : new[] { (MetadataField)lockField }; // generic type doesn't actually matter to call the static method, just has to be filled in MetadataService<TItemType, TIdType>.MergeBaseItemData(source, target, lockedFields, replaceData, false); actualValue = property.GetValue(target.Item); - return newValue?.Equals(actualValue) ?? actualValue == null; + return newValue?.Equals(actualValue) ?? actualValue is null; } } } diff --git a/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs b/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs index 725e295b9..c1f2f5f71 100644 --- a/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs +++ b/tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs @@ -430,7 +430,7 @@ namespace Jellyfin.Providers.Tests.Manager .Returns((int)order); } - var provider = hasOrder == null + var provider = hasOrder is null ? new Mock<TProviderType>(MockBehavior.Strict) : hasOrder.As<TProviderType>(); provider.Setup(p => p.Name) @@ -473,12 +473,12 @@ namespace Jellyfin.Providers.Tests.Manager Mock<IHasOrder>? hasOrder = null; if (order != null) { - hasOrder = forcedProvider == null ? new Mock<IHasOrder>() : forcedProvider.As<IHasOrder>(); + hasOrder = forcedProvider is null ? new Mock<IHasOrder>() : forcedProvider.As<IHasOrder>(); hasOrder.Setup(i => i.Order) .Returns((int)order); } - var provider = hasOrder == null + var provider = hasOrder is null ? new Mock<TProviderType>(MockBehavior.Strict) : hasOrder.As<TProviderType>(); provider.Setup(p => p.Name) diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs index 9b80f0b94..6b2d9021c 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs @@ -80,7 +80,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo var actual = await embeddedImageProvider.GetImage(input, type, CancellationToken.None); Assert.NotNull(actual); - if (expectedFormat == null) + if (expectedFormat is null) { Assert.False(actual.HasImage); } @@ -131,7 +131,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo var actual = await embeddedImageProvider.GetImage(input, type, CancellationToken.None); Assert.NotNull(actual); - if (expectedFormat == null) + if (expectedFormat is null) { Assert.False(actual.HasImage); } diff --git a/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs b/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs index 31f33c682..1bd51b246 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/TypedBaseItem/BaseItemKindTests.cs @@ -50,7 +50,7 @@ namespace Jellyfin.Server.Implementations.Tests.TypedBaseItem private static bool IsProjectAssemblyName(string? name) { - if (name == null) + if (name is null) { return false; } |
