The Free Software Media System - Server Backend & API
Minor cleanup
Bond_0095036afd69127
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.csindex 2a4a8fb132..c42cec593a 100644--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs@@ -365,11 +365,7 @@ namespace Emby.Server.Implementations.AppBasevalidatingStore.Validate(currentConfiguration, configuration);}- NamedConfigurationUpdating?.Invoke(this, new ConfigurationUpdateEventArgs- {- Key = key,- NewConfiguration = configuration- });+ NamedConfigurationUpdating?.Invoke(this, new ConfigurationUpdateEventArgs(key, configuration));_configurations.AddOrUpdate(key, configuration, (_, _) => configuration);@@ -391,11 +387,7 @@ namespace Emby.Server.Implementations.AppBase/// <param name="configuration">The old configuration.</param>protected virtual void OnNamedConfigurationUpdated(string key, object configuration){- NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs- {- Key = key,- NewConfiguration = configuration- });+ NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs(key, configuration));}/// <inheritdoc />diff --git a/Jellyfin.Api/Attributes/HttpSubscribeAttribute.cs b/Jellyfin.Api/Attributes/HttpSubscribeAttribute.csindex af8727552c..7ac089a344 100644--- a/Jellyfin.Api/Attributes/HttpSubscribeAttribute.cs+++ b/Jellyfin.Api/Attributes/HttpSubscribeAttribute.cs@@ -25,11 +25,6 @@ namespace Jellyfin.Api.Attributes/// <param name="template">The route template. May not be null.</param>public HttpSubscribeAttribute(string template): base(_supportedMethods, template)- {- if (template == null)- {- throw new ArgumentNullException(nameof(template));- }- }+ => ArgumentNullException.ThrowIfNull(template, nameof(template));}}diff --git a/Jellyfin.Api/Attributes/HttpUnsubscribeAttribute.cs b/Jellyfin.Api/Attributes/HttpUnsubscribeAttribute.csindex 1c0b70e719..16b3d08160 100644--- a/Jellyfin.Api/Attributes/HttpUnsubscribeAttribute.cs+++ b/Jellyfin.Api/Attributes/HttpUnsubscribeAttribute.cs@@ -25,11 +25,6 @@ namespace Jellyfin.Api.Attributes/// <param name="template">The route template. May not be null.</param>public HttpUnsubscribeAttribute(string template): base(_supportedMethods, template)- {- if (template == null)- {- throw new ArgumentNullException(nameof(template));- }- }+ => ArgumentNullException.ThrowIfNull(template, nameof(template));}}diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.csindex 27eb223390..64ee5680ce 100644--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs@@ -89,12 +89,9 @@ namespace Jellyfin.Api.Controllers// Load all custom display preferencesvar customDisplayPreferences = _displayPreferencesManager.ListCustomItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client);- if (customDisplayPreferences != null)+ foreach (var (key, value) in customDisplayPreferences){- foreach (var (key, value) in customDisplayPreferences)- {- dto.CustomPrefs.TryAdd(key, value);- }+ dto.CustomPrefs.TryAdd(key, value);}// This will essentially be a noop if no changes have been made, but new prefs must be saved at least.diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.csindex 6875282318..13f155f357 100644--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs@@ -145,9 +145,11 @@ namespace Jellyfin.Drawing.Skia/// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception>public string GetImageBlurHash(int xComp, int yComp, string path){- if (path == null)+ ArgumentNullException.ThrowIfNull(path, nameof(path));++ if (path.Length == 0){- throw new ArgumentNullException(nameof(path));+ throw new ArgumentException("String can't be empty", nameof(path));}var extension = Path.GetExtension(path.AsSpan()).TrimStart('.');diff --git a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.csindex f5d38db20f..65edb30ad2 100644--- a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs+++ b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs@@ -79,7 +79,7 @@ namespace Jellyfin.Server.Implementations.Users}/// <inheritdoc />- public void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string> customPreferences)+ public void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string?> customPreferences){var existingPrefs = _dbContext.CustomItemDisplayPreferences.AsQueryable()diff --git a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.csindex 7e7e4ca95b..28ed3894fd 100644--- a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs+++ b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs@@ -69,15 +69,8 @@ namespace Jellyfin.Server.Infrastructure/// <inheritdoc />protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength){- if (context == null)- {- throw new ArgumentNullException(nameof(context));- }-- if (result == null)- {- throw new ArgumentNullException(nameof(result));- }+ ArgumentNullException.ThrowIfNull(context, nameof(context));+ ArgumentNullException.ThrowIfNull(result, nameof(result));if (range != null && rangeLength == 0){diff --git a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.csindex 2df87d8792..90b1ff70c2 100644--- a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs+++ b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs@@ -1,22 +1,33 @@-#nullable disable-#pragma warning disable CS1591-using System;namespace MediaBrowser.Common.Configuration{+ /// <summary>+ /// <see cref="EventArgs" /> for the ConfigurationUpdated event.+ /// </summary>public class ConfigurationUpdateEventArgs : EventArgs{/// <summary>- /// Gets or sets the key.+ /// Initializes a new instance of the <see cref="ConfigurationUpdateEventArgs"/> class.+ /// </summary>+ /// <param name="key">The configuration key.</param>+ /// <param name="newConfiguration">The new configuration.</param>+ public ConfigurationUpdateEventArgs(string key, object newConfiguration)+ {+ Key = key;+ NewConfiguration = newConfiguration;+ }++ /// <summary>+ /// Gets the key./// </summary>/// <value>The key.</value>- public string Key { get; set; }+ public string Key { get; }/// <summary>- /// Gets or sets the new configuration.+ /// Gets the new configuration./// </summary>/// <value>The new configuration.</value>- public object NewConfiguration { get; set; }+ public object NewConfiguration { get; }}}diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.csindex 1370e6d79e..57c6546675 100644--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs@@ -1,5 +1,3 @@-#nullable disable-namespace MediaBrowser.Common.Configuration{/// <summary>diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.csindex 272a37df1b..afafaf1c24 100644--- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs+++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System.Text.Json.Serialization;@@ -13,7 +11,7 @@ namespace MediaBrowser.Controller.Entitiespublic abstract class BasePluginFolder : Folder, ICollectionFolder{[JsonIgnore]- public virtual string CollectionType => null;+ public virtual string? CollectionType => null;[JsonIgnore]public override bool SupportsInheritedParentImages => false;diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.csindex 9ce8eebe34..14534aa50b 100644--- a/MediaBrowser.Controller/Entities/Extensions.cs+++ b/MediaBrowser.Controller/Entities/Extensions.cs@@ -1,5 +1,3 @@-#nullable disable-using System;using System.Linq;using Jellyfin.Extensions;@@ -19,9 +17,11 @@ namespace MediaBrowser.Controller.Entities/// <param name="url">Trailer URL.</param>public static void AddTrailerUrl(this BaseItem item, string url){- if (string.IsNullOrEmpty(url))+ ArgumentNullException.ThrowIfNull(url, nameof(url));++ if (url.Length == 0){- throw new ArgumentNullException(nameof(url));+ throw new ArgumentException("String can't be empty", nameof(url));}var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));diff --git a/MediaBrowser.Controller/IDisplayPreferencesManager.cs b/MediaBrowser.Controller/IDisplayPreferencesManager.csindex 1678d50675..10c0f56e09 100644--- a/MediaBrowser.Controller/IDisplayPreferencesManager.cs+++ b/MediaBrowser.Controller/IDisplayPreferencesManager.cs@@ -1,5 +1,3 @@-#nullable disable-using System;using System.Collections.Generic;using Jellyfin.Data.Entities;@@ -50,7 +48,7 @@ namespace MediaBrowser.Controller/// <param name="itemId">The item id.</param>/// <param name="client">The client string.</param>/// <returns>The dictionary of custom item display preferences.</returns>- Dictionary<string, string> ListCustomItemDisplayPreferences(Guid userId, Guid itemId, string client);+ Dictionary<string, string?> ListCustomItemDisplayPreferences(Guid userId, Guid itemId, string client);/// <summary>/// Sets the custom item display preference for the user and client.@@ -59,7 +57,7 @@ namespace MediaBrowser.Controller/// <param name="itemId">The item id.</param>/// <param name="client">The client id.</param>/// <param name="customPreferences">A dictionary of custom item display preferences.</param>- void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string> customPreferences);+ void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string?> customPreferences);/// <summary>/// Saves changes made to the database.