Browse Source

FxCop -> Net Analyzers (part 2)

Bond_009 4 năm trước cách đây
mục cha
commit
a8ed753f6c
70 tập tin đã thay đổi với 151 bổ sung213 xóa
  1. 1 1
      Emby.Dlna/DlnaManager.cs
  2. 1 4
      Emby.Server.Implementations/ApplicationHost.cs
  3. 1 1
      Emby.Server.Implementations/Channels/ChannelManager.cs
  4. 1 1
      Emby.Server.Implementations/Data/SqliteItemRepository.cs
  5. 1 1
      Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
  6. 1 1
      Emby.Server.Implementations/Library/LiveStreamHelper.cs
  7. 1 1
      Emby.Server.Implementations/Library/MediaSourceManager.cs
  8. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
  9. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
  10. 1 1
      Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
  11. 1 1
      Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
  12. 1 1
      Emby.Server.Implementations/Localization/LocalizationManager.cs
  13. 2 2
      Emby.Server.Implementations/Plugins/PluginManager.cs
  14. 1 1
      Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
  15. 1 1
      Emby.Server.Implementations/Updates/InstallationManager.cs
  16. 1 1
      Jellyfin.Api/Controllers/ConfigurationController.cs
  17. 1 1
      Jellyfin.Api/Controllers/PluginsController.cs
  18. 7 53
      Jellyfin.Data/DayOfWeekHelper.cs
  19. 1 0
      Jellyfin.Data/Entities/Libraries/Collection.cs
  20. 2 0
      Jellyfin.Data/Entities/Libraries/MediaFileStream.cs
  21. 2 0
      Jellyfin.Data/Entities/Permission.cs
  22. 2 4
      Jellyfin.Data/Jellyfin.Data.csproj
  23. 7 4
      Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
  24. 4 9
      Jellyfin.Drawing.Skia/SkiaEncoder.cs
  25. 2 4
      Jellyfin.Networking/Jellyfin.Networking.csproj
  26. 4 4
      Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs
  27. 7 7
      Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
  28. 2 2
      Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs
  29. 3 3
      Jellyfin.Server.Implementations/Events/Consumers/Users/UserUpdatedNotifier.cs
  30. 2 0
      Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
  31. 1 1
      Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs
  32. 2 1
      Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
  33. 1 1
      Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
  34. 1 1
      Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs
  35. 1 1
      Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs
  36. 3 5
      Jellyfin.Server/Jellyfin.Server.csproj
  37. 3 0
      Jellyfin.Server/Migrations/MigrationOptions.cs
  38. 1 1
      Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
  39. 2 2
      Jellyfin.Server/Program.cs
  40. 2 2
      MediaBrowser.Common/IApplicationHost.cs
  41. 3 3
      MediaBrowser.Common/Json/JsonDefaults.cs
  42. 2 4
      MediaBrowser.Common/MediaBrowser.Common.csproj
  43. 1 1
      MediaBrowser.Common/Net/IPHost.cs
  44. 3 3
      MediaBrowser.Common/Net/IPNetAddress.cs
  45. 1 1
      MediaBrowser.Common/Plugins/BasePlugin.cs
  46. 17 19
      MediaBrowser.Common/Plugins/BasePluginOfT.cs
  47. 3 3
      MediaBrowser.Common/Plugins/LocalPlugin.cs
  48. 1 0
      MediaBrowser.Common/Progress/ActionableProgress.cs
  49. 1 0
      MediaBrowser.Common/Progress/SimpleProgress.cs
  50. 1 1
      MediaBrowser.Controller/Entities/CollectionFolder.cs
  51. 2 4
      MediaBrowser.Controller/MediaBrowser.Controller.csproj
  52. 1 1
      MediaBrowser.Controller/Providers/ILocalImageProvider.cs
  53. 1 1
      MediaBrowser.LocalMetadata/Images/CollectionFolderLocalImageProvider.cs
  54. 1 1
      MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
  55. 4 3
      MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs
  56. 6 8
      MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
  57. 2 4
      MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
  58. 2 2
      MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
  59. 3 3
      MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
  60. 3 3
      MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
  61. 4 13
      MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
  62. 1 1
      MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
  63. 1 1
      MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs
  64. 1 1
      MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs
  65. 1 1
      MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs
  66. 1 1
      MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs
  67. 1 1
      MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
  68. 1 1
      MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
  69. 1 1
      tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs
  70. 1 1
      tests/Jellyfin.Server.Integration.Tests/Controllers/DashboardControllerTests.cs

+ 1 - 1
Emby.Dlna/DlnaManager.cs

@@ -36,7 +36,7 @@ namespace Emby.Dlna
         private readonly ILogger<DlnaManager> _logger;
         private readonly IServerApplicationHost _appHost;
         private static readonly Assembly _assembly = typeof(DlnaManager).Assembly;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         private readonly Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>> _profiles = new Dictionary<string, Tuple<InternalProfileInfo, DeviceProfile>>(StringComparer.Ordinal);
 

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

@@ -10,8 +10,6 @@ using System.Net;
 using System.Reflection;
 using System.Runtime.InteropServices;
 using System.Security.Cryptography.X509Certificates;
-using System.Text;
-using System.Text.Json;
 using System.Threading;
 using System.Threading.Tasks;
 using Emby.Dlna;
@@ -51,7 +49,6 @@ using Jellyfin.Networking.Manager;
 using MediaBrowser.Common;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Events;
-using MediaBrowser.Common.Json;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Plugins;
 using MediaBrowser.Common.Updates;
@@ -470,7 +467,7 @@ namespace Emby.Server.Implementations
         }
 
         /// <inheritdoc />
-        public IReadOnlyCollection<T> GetExports<T>(CreationDelegate defaultFunc, bool manageLifetime = true)
+        public IReadOnlyCollection<T> GetExports<T>(CreationDelegateFactory defaultFunc, bool manageLifetime = true)
         {
             // Convert to list so this isn't executed for each iteration
             var parts = GetExportTypes<T>()

+ 1 - 1
Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.Channels
         private readonly IProviderManager _providerManager;
         private readonly IMemoryCache _memoryCache;
         private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ChannelManager"/> class.

+ 1 - 1
Emby.Server.Implementations/Data/SqliteItemRepository.cs

@@ -88,7 +88,7 @@ namespace Emby.Server.Implementations.Data
             _imageProcessor = imageProcessor;
 
             _typeMapper = new TypeMapper();
-            _jsonOptions = JsonDefaults.GetOptions();
+            _jsonOptions = JsonDefaults.Options;
 
             DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
         }

+ 1 - 1
Emby.Server.Implementations/HttpServer/WebSocketConnection.cs

@@ -56,7 +56,7 @@ namespace Emby.Server.Implementations.HttpServer
             RemoteEndPoint = remoteEndPoint;
             QueryString = query;
 
-            _jsonOptions = JsonDefaults.GetOptions();
+            _jsonOptions = JsonDefaults.Options;
             LastActivityDate = DateTime.Now;
         }
 

+ 1 - 1
Emby.Server.Implementations/Library/LiveStreamHelper.cs

@@ -25,7 +25,7 @@ namespace Emby.Server.Implementations.Library
         private readonly IMediaEncoder _mediaEncoder;
         private readonly ILogger _logger;
         private readonly IApplicationPaths _appPaths;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         public LiveStreamHelper(IMediaEncoder mediaEncoder, ILogger logger, IApplicationPaths appPaths)
         {

+ 1 - 1
Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -46,7 +46,7 @@ namespace Emby.Server.Implementations.Library
 
         private readonly ConcurrentDictionary<string, ILiveStream> _openStreams = new ConcurrentDictionary<string, ILiveStream>(StringComparer.OrdinalIgnoreCase);
         private readonly SemaphoreSlim _liveStreamSemaphore = new SemaphoreSlim(1, 1);
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         private IMediaSourceProvider[] _providers;
 

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         private readonly IServerApplicationPaths _appPaths;
         private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
         private readonly IServerConfigurationManager _serverConfigurationManager;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         private bool _hasExited;
         private Stream _logFileStream;
         private string _targetPath;

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs

@@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
     {
         private readonly string _dataPath;
         private readonly object _fileDataLock = new object();
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         private T[] _items;
 
         public ItemDataProvider(

+ 1 - 1
Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
         private readonly ICryptoProvider _cryptoProvider;
 
         private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         private DateTime _lastErrorResponse;
 
         public SchedulesDirect(

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

@@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
             _networkManager = networkManager;
             _streamHelper = streamHelper;
 
-            _jsonOptions = JsonDefaults.GetOptions();
+            _jsonOptions = JsonDefaults.Options;
         }
 
         public string Name => "HD Homerun";

+ 1 - 1
Emby.Server.Implementations/Localization/LocalizationManager.cs

@@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Localization
 
         private List<CultureDto> _cultures;
 
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="LocalizationManager" /> class.

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

@@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Plugins
             _logger = logger ?? throw new ArgumentNullException(nameof(logger));
             _pluginsPath = pluginsPath;
             _appVersion = appVersion ?? throw new ArgumentNullException(nameof(appVersion));
-            _jsonOptions = new JsonSerializerOptions(JsonDefaults.GetOptions())
+            _jsonOptions = new JsonSerializerOptions(JsonDefaults.Options)
             {
                 WriteIndented = true
             };
@@ -678,7 +678,7 @@ namespace Emby.Server.Implementations.Plugins
                 var entry = versions[x];
                 if (!string.Equals(lastName, entry.Name, StringComparison.OrdinalIgnoreCase))
                 {
-                    entry.DllFiles.AddRange(Directory.EnumerateFiles(entry.Path, "*.dll", SearchOption.AllDirectories));
+                    entry.DllFiles = Directory.GetFiles(entry.Path, "*.dll", SearchOption.AllDirectories);
                     if (entry.IsEnabledAndSupported)
                     {
                         lastName = entry.Name;

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

@@ -69,7 +69,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
         /// <summary>
         /// The options for the json Serializer.
         /// </summary>
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class.

+ 1 - 1
Emby.Server.Implementations/Updates/InstallationManager.cs

@@ -92,7 +92,7 @@ namespace Emby.Server.Implementations.Updates
             _httpClientFactory = httpClientFactory;
             _config = config;
             _zipClient = zipClient;
-            _jsonSerializerOptions = JsonDefaults.GetOptions();
+            _jsonSerializerOptions = JsonDefaults.Options;
             _pluginManager = pluginManager;
         }
 

+ 1 - 1
Jellyfin.Api/Controllers/ConfigurationController.cs

@@ -25,7 +25,7 @@ namespace Jellyfin.Api.Controllers
         private readonly IServerConfigurationManager _configurationManager;
         private readonly IMediaEncoder _mediaEncoder;
 
-        private readonly JsonSerializerOptions _serializerOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _serializerOptions = JsonDefaults.Options;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ConfigurationController"/> class.

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

@@ -45,7 +45,7 @@ namespace Jellyfin.Api.Controllers
         {
             _installationManager = installationManager;
             _pluginManager = pluginManager;
-            _serializerOptions = JsonDefaults.GetOptions();
+            _serializerOptions = JsonDefaults.Options;
             _config = config;
         }
 

+ 7 - 53
Jellyfin.Data/DayOfWeekHelper.cs

@@ -1,67 +1,21 @@
 #pragma warning disable CS1591
 
 using System;
-using System.Collections.Generic;
 using Jellyfin.Data.Enums;
 
 namespace Jellyfin.Data
 {
     public static class DayOfWeekHelper
     {
-        public static List<DayOfWeek> GetDaysOfWeek(DynamicDayOfWeek day)
+        public static DayOfWeek[] GetDaysOfWeek(DynamicDayOfWeek day)
         {
-            var days = new List<DayOfWeek>(7);
-
-            if (day == DynamicDayOfWeek.Sunday
-                || day == DynamicDayOfWeek.Weekend
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Sunday);
-            }
-
-            if (day == DynamicDayOfWeek.Monday
-                || day == DynamicDayOfWeek.Weekday
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Monday);
-            }
-
-            if (day == DynamicDayOfWeek.Tuesday
-                || day == DynamicDayOfWeek.Weekday
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Tuesday);
-            }
-
-            if (day == DynamicDayOfWeek.Wednesday
-                || day == DynamicDayOfWeek.Weekday
-                || day == DynamicDayOfWeek.Everyday)
+            return day switch
             {
-                days.Add(DayOfWeek.Wednesday);
-            }
-
-            if (day == DynamicDayOfWeek.Thursday
-                || day == DynamicDayOfWeek.Weekday
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Thursday);
-            }
-
-            if (day == DynamicDayOfWeek.Friday
-                || day == DynamicDayOfWeek.Weekday
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Friday);
-            }
-
-            if (day == DynamicDayOfWeek.Saturday
-                || day == DynamicDayOfWeek.Weekend
-                || day == DynamicDayOfWeek.Everyday)
-            {
-                days.Add(DayOfWeek.Saturday);
-            }
-
-            return days;
+                DynamicDayOfWeek.Everyday => new[] { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday },
+                DynamicDayOfWeek.Weekday => new[] { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday },
+                DynamicDayOfWeek.Weekend => new[] { DayOfWeek.Saturday, DayOfWeek.Sunday },
+                _ => new[] { (DayOfWeek)day }
+            };
         }
     }
 }

+ 1 - 0
Jellyfin.Data/Entities/Libraries/Collection.cs

@@ -1,3 +1,4 @@
+#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
 #pragma warning disable CA2227
 
 using System.Collections.Generic;

+ 2 - 0
Jellyfin.Data/Entities/Libraries/MediaFileStream.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
+
 using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;

+ 2 - 0
Jellyfin.Data/Entities/Permission.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
+
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Enums;

+ 2 - 4
Jellyfin.Data/Jellyfin.Data.csproj

@@ -5,6 +5,8 @@
     <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
     <PublishRepositoryUrl>true</PublishRepositoryUrl>
     <EmbedUntrackedSources>true</EmbedUntrackedSources>
     <IncludeSymbols>true</IncludeSymbols>
@@ -24,10 +26,6 @@
     <PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
   </PropertyGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
   <ItemGroup>
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
   </ItemGroup>

+ 7 - 4
Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj

@@ -11,6 +11,8 @@
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Nullable>enable</Nullable>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
   <ItemGroup>
@@ -30,6 +32,11 @@
     <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <!-- Needed for https://github.com/dotnet/roslyn-analyzers/issues/4382 which is in the SDK yet -->
+    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3" PrivateAssets="All" />
+  </ItemGroup>
+
   <!-- Code analysers-->
   <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
     <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
@@ -37,8 +44,4 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
 </Project>

+ 4 - 9
Jellyfin.Drawing.Skia/SkiaEncoder.cs

@@ -274,8 +274,8 @@ namespace Jellyfin.Drawing.Skia
 
             if (requiresTransparencyHack || forceCleanBitmap)
             {
-                using var codec = SKCodec.Create(NormalizePath(path));
-                if (codec == null)
+                using SKCodec codec = SKCodec.Create(NormalizePath(path), out SKCodecResult res);
+                if (res != SKCodecResult.Success)
                 {
                     origin = GetSKEncodedOrigin(orientation);
                     return null;
@@ -345,11 +345,6 @@ namespace Jellyfin.Drawing.Skia
 
         private SKBitmap OrientImage(SKBitmap bitmap, SKEncodedOrigin origin)
         {
-            if (origin == SKEncodedOrigin.Default)
-            {
-                return bitmap;
-            }
-
             var needsFlip = origin == SKEncodedOrigin.LeftBottom
                             || origin == SKEncodedOrigin.LeftTop
                             || origin == SKEncodedOrigin.RightBottom
@@ -447,7 +442,7 @@ namespace Jellyfin.Drawing.Skia
         }
 
         /// <inheritdoc/>
-        public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
+        public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat)
         {
             if (inputPath.Length == 0)
             {
@@ -459,7 +454,7 @@ namespace Jellyfin.Drawing.Skia
                 throw new ArgumentException("String can't be empty.", nameof(outputPath));
             }
 
-            var skiaOutputFormat = GetImageFormat(selectedOutputFormat);
+            var skiaOutputFormat = GetImageFormat(outputFormat);
 
             var hasBackgroundColor = !string.IsNullOrWhiteSpace(options.BackgroundColor);
             var hasForegroundColor = !string.IsNullOrWhiteSpace(options.ForegroundLayer);

+ 2 - 4
Jellyfin.Networking/Jellyfin.Networking.csproj

@@ -5,6 +5,8 @@
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Nullable>enable</Nullable>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
   <ItemGroup>
@@ -18,10 +20,6 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
   <ItemGroup>
     <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
     <ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />

+ 4 - 4
Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs

@@ -29,20 +29,20 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Security
         }
 
         /// <inheritdoc />
-        public async Task OnEvent(GenericEventArgs<AuthenticationResult> e)
+        public async Task OnEvent(GenericEventArgs<AuthenticationResult> eventArgs)
         {
             await _activityManager.CreateAsync(new ActivityLog(
                 string.Format(
                     CultureInfo.InvariantCulture,
                     _localizationManager.GetLocalizedString("AuthenticationSucceededWithUserName"),
-                    e.Argument.User.Name),
+                    eventArgs.Argument.User.Name),
                 "AuthenticationSucceeded",
-                e.Argument.User.Id)
+                eventArgs.Argument.User.Id)
             {
                 ShortOverview = string.Format(
                     CultureInfo.InvariantCulture,
                     _localizationManager.GetLocalizedString("LabelIpAddressValue"),
-                    e.Argument.SessionInfo.RemoteEndPoint),
+                    eventArgs.Argument.SessionInfo.RemoteEndPoint),
             }).ConfigureAwait(false);
         }
     }

+ 7 - 7
Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs

@@ -33,10 +33,10 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.System
         }
 
         /// <inheritdoc />
-        public async Task OnEvent(TaskCompletionEventArgs e)
+        public async Task OnEvent(TaskCompletionEventArgs eventArgs)
         {
-            var result = e.Result;
-            var task = e.Task;
+            var result = eventArgs.Result;
+            var task = eventArgs.Task;
 
             if (task.ScheduledTask is IConfigurableScheduledTask activityTask
                 && !activityTask.IsLogged)
@@ -54,14 +54,14 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.System
             {
                 var vals = new List<string>();
 
-                if (!string.IsNullOrEmpty(e.Result.ErrorMessage))
+                if (!string.IsNullOrEmpty(eventArgs.Result.ErrorMessage))
                 {
-                    vals.Add(e.Result.ErrorMessage);
+                    vals.Add(eventArgs.Result.ErrorMessage);
                 }
 
-                if (!string.IsNullOrEmpty(e.Result.LongErrorMessage))
+                if (!string.IsNullOrEmpty(eventArgs.Result.LongErrorMessage))
                 {
-                    vals.Add(e.Result.LongErrorMessage);
+                    vals.Add(eventArgs.Result.LongErrorMessage);
                 }
 
                 await _activityManager.CreateAsync(new ActivityLog(

+ 2 - 2
Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs

@@ -30,13 +30,13 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Updates
         }
 
         /// <inheritdoc />
-        public async Task OnEvent(PluginUninstalledEventArgs e)
+        public async Task OnEvent(PluginUninstalledEventArgs eventArgs)
         {
             await _activityManager.CreateAsync(new ActivityLog(
                     string.Format(
                         CultureInfo.InvariantCulture,
                         _localizationManager.GetLocalizedString("PluginUninstalledWithName"),
-                        e.Argument.Name),
+                        eventArgs.Argument.Name),
                     NotificationType.PluginUninstalled.ToString(),
                     Guid.Empty))
                 .ConfigureAwait(false);

+ 3 - 3
Jellyfin.Server.Implementations/Events/Consumers/Users/UserUpdatedNotifier.cs

@@ -30,12 +30,12 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Users
         }
 
         /// <inheritdoc />
-        public async Task OnEvent(UserUpdatedEventArgs e)
+        public async Task OnEvent(UserUpdatedEventArgs eventArgs)
         {
             await _sessionManager.SendMessageToUserSessions(
-                new List<Guid> { e.Argument.Id },
+                new List<Guid> { eventArgs.Argument.Id },
                 SessionMessageType.UserUpdated,
-                _userManager.GetUserDto(e.Argument),
+                _userManager.GetUserDto(eventArgs.Argument),
                 CancellationToken.None).ConfigureAwait(false);
         }
     }

+ 2 - 0
Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj

@@ -6,6 +6,8 @@
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Nullable>enable</Nullable>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

+ 1 - 1
Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs

@@ -66,7 +66,7 @@ namespace Jellyfin.Server.Implementations.Users
                 else if (string.Equals(
                     spr.Pin.Replace("-", string.Empty, StringComparison.Ordinal),
                     pin.Replace("-", string.Empty, StringComparison.Ordinal),
-                    StringComparison.InvariantCultureIgnoreCase))
+                    StringComparison.OrdinalIgnoreCase))
                 {
                     var resetUser = userManager.GetUserByName(spr.UserName)
                         ?? throw new ResourceNotFoundException($"User with a username of {spr.UserName} not found");

+ 2 - 1
Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs

@@ -1,4 +1,5 @@
 #pragma warning disable CA1307
+#pragma warning disable CA1309
 
 using System;
 using System.Collections.Generic;
@@ -35,7 +36,7 @@ namespace Jellyfin.Server.Implementations.Users
 
             if (prefs == null)
             {
-                prefs = new DisplayPreferences(userId,  itemId, client);
+                prefs = new DisplayPreferences(userId, itemId, client);
                 _dbContext.DisplayPreferences.Add(prefs);
             }
 

+ 1 - 1
Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs

@@ -225,7 +225,7 @@ namespace Jellyfin.Server.Extensions
                 .AddJsonOptions(options =>
                 {
                     // Update all properties that are set in JsonDefaults
-                    var jsonOptions = JsonDefaults.GetPascalCaseOptions();
+                    var jsonOptions = JsonDefaults.PascalCaseOptions;
 
                     // From JsonDefaults
                     options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;

+ 1 - 1
Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs

@@ -12,7 +12,7 @@ namespace Jellyfin.Server.Formatters
         /// <summary>
         /// Initializes a new instance of the <see cref="CamelCaseJsonProfileFormatter"/> class.
         /// </summary>
-        public CamelCaseJsonProfileFormatter() : base(JsonDefaults.GetCamelCaseOptions())
+        public CamelCaseJsonProfileFormatter() : base(JsonDefaults.CamelCaseOptions)
         {
             SupportedMediaTypes.Clear();
             SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(JsonDefaults.CamelCaseMediaType));

+ 1 - 1
Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs

@@ -13,7 +13,7 @@ namespace Jellyfin.Server.Formatters
         /// <summary>
         /// Initializes a new instance of the <see cref="PascalCaseJsonProfileFormatter"/> class.
         /// </summary>
-        public PascalCaseJsonProfileFormatter() : base(JsonDefaults.GetPascalCaseOptions())
+        public PascalCaseJsonProfileFormatter() : base(JsonDefaults.PascalCaseOptions)
         {
             SupportedMediaTypes.Clear();
             // Add application/json for default formatter

+ 3 - 5
Jellyfin.Server/Jellyfin.Server.csproj

@@ -13,7 +13,9 @@
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Nullable>enable</Nullable>
-    <DisableImplicitAspNetCoreAnalyzers>true</DisableImplicitAspNetCoreAnalyzers>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
+    <!-- <DisableImplicitAspNetCoreAnalyzers>true</DisableImplicitAspNetCoreAnalyzers> -->
   </PropertyGroup>
 
   <ItemGroup>
@@ -31,10 +33,6 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
   <ItemGroup>
     <PackageReference Include="CommandLineParser" Version="2.8.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />

+ 3 - 0
Jellyfin.Server/Migrations/MigrationOptions.cs

@@ -16,9 +16,12 @@ namespace Jellyfin.Server.Migrations
             Applied = new List<(Guid Id, string Name)>();
         }
 
+// .Net xml serializer can't handle interfaces
+#pragma warning disable CA1002 // Do not expose generic lists
         /// <summary>
         /// Gets the list of applied migration routine names.
         /// </summary>
         public List<(Guid Id, string Name)> Applied { get; }
+#pragma warning restore CA1002
     }
 }

+ 1 - 1
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.GetOptions());
+                    UserMockup? mockup = JsonSerializer.Deserialize<UserMockup>(entry[2].ToBlob(), JsonDefaults.Options);
                     if (mockup == null)
                     {
                         continue;

+ 2 - 2
Jellyfin.Server/Program.cs

@@ -222,7 +222,7 @@ namespace Jellyfin.Server
             }
             finally
             {
-                appHost?.Dispose();
+                appHost.Dispose();
             }
 
             if (_restartOnShutdown)
@@ -623,7 +623,7 @@ namespace Jellyfin.Server
             string commandLineArgsString;
             if (options.RestartArgs != null)
             {
-                commandLineArgsString = options.RestartArgs ?? string.Empty;
+                commandLineArgsString = options.RestartArgs;
             }
             else
             {

+ 2 - 2
MediaBrowser.Common/IApplicationHost.cs

@@ -10,7 +10,7 @@ namespace MediaBrowser.Common
     /// </summary>
     /// <param name="type">Type to create.</param>
     /// <returns>New instance of type <param>type</param>.</returns>
-    public delegate object CreationDelegate(Type type);
+    public delegate object CreationDelegateFactory(Type type);
 
     /// <summary>
     /// An interface to be implemented by the applications hosting a kernel.
@@ -112,7 +112,7 @@ namespace MediaBrowser.Common
         /// <param name="defaultFunc">Delegate function that gets called to create the object.</param>
         /// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
         /// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
-        IReadOnlyCollection<T> GetExports<T>(CreationDelegate defaultFunc, bool manageLifetime = true);
+        IReadOnlyCollection<T> GetExports<T>(CreationDelegateFactory defaultFunc, bool manageLifetime = true);
 
         /// <summary>
         /// Gets the export types.

+ 3 - 3
MediaBrowser.Common/Json/JsonDefaults.cs

@@ -61,7 +61,7 @@ namespace MediaBrowser.Common.Json
         /// If the defaults must be modified the author must use the copy constructor.
         /// </remarks>
         /// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
-        public static JsonSerializerOptions GetOptions()
+        public static JsonSerializerOptions Options
             => _jsonSerializerOptions;
 
         /// <summary>
@@ -72,7 +72,7 @@ namespace MediaBrowser.Common.Json
         /// If the defaults must be modified the author must use the copy constructor.
         /// </remarks>
         /// <returns>The camelCase <see cref="JsonSerializerOptions" /> options.</returns>
-        public static JsonSerializerOptions GetCamelCaseOptions()
+        public static JsonSerializerOptions CamelCaseOptions
             => _camelCaseJsonSerializerOptions;
 
         /// <summary>
@@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Json
         /// If the defaults must be modified the author must use the copy constructor.
         /// </remarks>
         /// <returns>The PascalCase <see cref="JsonSerializerOptions" /> options.</returns>
-        public static JsonSerializerOptions GetPascalCaseOptions()
+        public static JsonSerializerOptions PascalCaseOptions
             => _pascalCaseJsonSerializerOptions;
     }
 }

+ 2 - 4
MediaBrowser.Common/MediaBrowser.Common.csproj

@@ -33,6 +33,8 @@
     <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
     <PublishRepositoryUrl>true</PublishRepositoryUrl>
     <EmbedUntrackedSources>true</EmbedUntrackedSources>
     <IncludeSymbols>true</IncludeSymbols>
@@ -51,10 +53,6 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
   <ItemGroup>
     <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
       <_Parameter1>Jellyfin.Common.Tests</_Parameter1>

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

@@ -406,7 +406,7 @@ namespace MediaBrowser.Common.Net
             }
 
             // If we haven't resolved before, or our timer has run out...
-            if ((_addresses.Length == 0 && !Resolved) || (DateTime.UtcNow > _lastResolved?.AddMinutes(Timeout)))
+            if ((_addresses.Length == 0 && !Resolved) || (DateTime.UtcNow > _lastResolved.Value.AddMinutes(Timeout)))
             {
                 _lastResolved = DateTime.UtcNow;
                 ResolveHostInternal().GetAwaiter().GetResult();

+ 3 - 3
MediaBrowser.Common/Net/IPNetAddress.cs

@@ -216,11 +216,11 @@ namespace MediaBrowser.Common.Net
         }
 
         /// <inheritdoc/>
-        public override bool Equals(IPAddress address)
+        public override bool Equals(IPAddress ip)
         {
-            if (address != null && !address.Equals(IPAddress.None) && !Address.Equals(IPAddress.None))
+            if (ip != null && !ip.Equals(IPAddress.None) && !Address.Equals(IPAddress.None))
             {
-                return address.Equals(Address);
+                return ip.Equals(Address);
             }
 
             return false;

+ 1 - 1
MediaBrowser.Common/Plugins/BasePlugin.cs

@@ -50,7 +50,7 @@ namespace MediaBrowser.Common.Plugins
         /// Gets a value indicating whether the plugin can be uninstalled.
         /// </summary>
         public bool CanUninstall => !Path.GetDirectoryName(AssemblyFilePath)
-            .Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.InvariantCulture);
+            .Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.Ordinal);
 
         /// <summary>
         /// Gets the plugin info.

+ 17 - 19
MediaBrowser.Common/Plugins/BasePluginOfT.cs

@@ -39,29 +39,27 @@ namespace MediaBrowser.Common.Plugins
         {
             ApplicationPaths = applicationPaths;
             XmlSerializer = xmlSerializer;
-            if (this is IPluginAssembly assemblyPlugin)
-            {
-                var assembly = GetType().Assembly;
-                var assemblyName = assembly.GetName();
-                var assemblyFilePath = assembly.Location;
 
-                var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
-                if (!Directory.Exists(dataFolderPath) && Version != null)
-                {
-                    // Try again with the version number appended to the folder name.
-                    dataFolderPath = dataFolderPath + "_" + Version.ToString();
-                }
+            var assembly = GetType().Assembly;
+            var assemblyName = assembly.GetName();
+            var assemblyFilePath = assembly.Location;
 
-                assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
+            var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
+            if (!Directory.Exists(dataFolderPath) && Version != null)
+            {
+                // Try again with the version number appended to the folder name.
+                dataFolderPath = dataFolderPath + "_" + Version.ToString();
+            }
 
-                var idAttributes = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
-                if (idAttributes.Length > 0)
-                {
-                    var attribute = (GuidAttribute)idAttributes[0];
-                    var assemblyId = new Guid(attribute.Value);
+            SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
 
-                    assemblyPlugin.SetId(assemblyId);
-                }
+            var idAttributes = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
+            if (idAttributes.Length > 0)
+            {
+                var attribute = (GuidAttribute)idAttributes[0];
+                var assemblyId = new Guid(attribute.Value);
+
+                SetId(assemblyId);
             }
         }
 

+ 3 - 3
MediaBrowser.Common/Plugins/LocalPlugin.cs

@@ -22,7 +22,7 @@ namespace MediaBrowser.Common.Plugins
         public LocalPlugin(string path, bool isSupported, PluginManifest manifest)
         {
             Path = path;
-            DllFiles = new List<string>();
+            DllFiles = Array.Empty<string>();
             _supported = isSupported;
             Manifest = manifest;
         }
@@ -59,9 +59,9 @@ namespace MediaBrowser.Common.Plugins
         public string Path { get; }
 
         /// <summary>
-        /// Gets the list of dll files for this plugin.
+        /// Gets or sets the list of dll files for this plugin.
         /// </summary>
-        public List<string> DllFiles { get; }
+        public IReadOnlyList<string> DllFiles { get; set; }
 
         /// <summary>
         /// Gets or sets the instance of this plugin.

+ 1 - 0
MediaBrowser.Common/Progress/ActionableProgress.cs

@@ -1,4 +1,5 @@
 #pragma warning disable CS1591
+#pragma warning disable CA1003
 
 using System;
 

+ 1 - 0
MediaBrowser.Common/Progress/SimpleProgress.cs

@@ -1,4 +1,5 @@
 #pragma warning disable CS1591
+#pragma warning disable CA1003
 
 using System;
 

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

@@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Entities
     /// </summary>
     public class CollectionFolder : Folder, ICollectionFolder
     {
-        private static readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private static readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         public static IXmlSerializer XmlSerializer { get; set; }
 
         public static IServerApplicationHost ApplicationHost { get; set; }

+ 2 - 4
MediaBrowser.Controller/MediaBrowser.Controller.csproj

@@ -34,6 +34,8 @@
     <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release' ">true</TreatWarningsAsErrors>
+    <AnalysisMode Condition=" '$(Configuration)' == 'Debug' ">AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
     <PublishRepositoryUrl>true</PublishRepositoryUrl>
     <EmbedUntrackedSources>true</EmbedUntrackedSources>
     <IncludeSymbols>true</IncludeSymbols>
@@ -52,8 +54,4 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
 </Project>

+ 1 - 1
MediaBrowser.Controller/Providers/ILocalImageProvider.cs

@@ -10,6 +10,6 @@ namespace MediaBrowser.Controller.Providers
     /// </summary>
     public interface ILocalImageProvider : IImageProvider
     {
-        List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService);
+        IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService);
     }
 }

+ 1 - 1
MediaBrowser.LocalMetadata/Images/CollectionFolderLocalImageProvider.cs

@@ -35,7 +35,7 @@ namespace MediaBrowser.LocalMetadata.Images
         }
 
         /// <inheritdoc />
-        public List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
         {
             var collectionFolder = (CollectionFolder)item;
 

+ 1 - 1
MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs

@@ -39,7 +39,7 @@ namespace MediaBrowser.LocalMetadata.Images
         }
 
         /// <inheritdoc />
-        public List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
         {
             var parentPath = Path.GetDirectoryName(item.Path);
 

+ 4 - 3
MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs

@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Audio;
@@ -69,13 +70,13 @@ namespace MediaBrowser.LocalMetadata.Images
         }
 
         /// <inheritdoc />
-        public List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
         {
             var path = item.GetInternalMetadataPath();
 
             if (!Directory.Exists(path))
             {
-                return new List<LocalImageInfo>();
+                return Enumerable.Empty<LocalImageInfo>();
             }
 
             try
@@ -85,7 +86,7 @@ namespace MediaBrowser.LocalMetadata.Images
             catch (IOException ex)
             {
                 _logger.LogError(ex, "Error while getting images for {Library}", item.Name);
-                return new List<LocalImageInfo>();
+                return Enumerable.Empty<LocalImageInfo>();
             }
         }
     }

+ 6 - 8
MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs

@@ -108,7 +108,7 @@ namespace MediaBrowser.LocalMetadata.Images
         {
             if (!item.IsFileProtocol)
             {
-                return new List<FileSystemMetadata>();
+                return Enumerable.Empty<FileSystemMetadata>();
             }
 
             var path = item.ContainingFolderPath;
@@ -116,7 +116,7 @@ namespace MediaBrowser.LocalMetadata.Images
             // Exit if the cache dir does not exist, alternative solution is to create it, but that's a lot of empty dirs...
             if (!Directory.Exists(path))
             {
-                return Array.Empty<FileSystemMetadata>();
+                return Enumerable.Empty<FileSystemMetadata>();
             }
 
             if (includeDirectories)
@@ -133,7 +133,7 @@ namespace MediaBrowser.LocalMetadata.Images
         }
 
         /// <inheritdoc />
-        public List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
         {
             var files = GetFiles(item, true, directoryService).ToList();
 
@@ -151,7 +151,7 @@ namespace MediaBrowser.LocalMetadata.Images
         /// <param name="path">The images path.</param>
         /// <param name="directoryService">Instance of the <see cref="IDirectoryService"/> interface.</param>
         /// <returns>The local image info.</returns>
-        public List<LocalImageInfo> GetImages(BaseItem item, string path, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, string path, IDirectoryService directoryService)
         {
             return GetImages(item, new[] { path }, directoryService);
         }
@@ -163,7 +163,7 @@ namespace MediaBrowser.LocalMetadata.Images
         /// <param name="paths">The image paths.</param>
         /// <param name="directoryService">Instance of the <see cref="IDirectoryService"/> interface.</param>
         /// <returns>The local image info.</returns>
-        public List<LocalImageInfo> GetImages(BaseItem item, IEnumerable<string> paths, IDirectoryService directoryService)
+        public IEnumerable<LocalImageInfo> GetImages(BaseItem item, IEnumerable<string> paths, IDirectoryService directoryService)
         {
             IEnumerable<FileSystemMetadata> files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false));
 
@@ -181,9 +181,7 @@ namespace MediaBrowser.LocalMetadata.Images
         {
             if (supportParentSeriesFiles)
             {
-                var season = item as Season;
-
-                if (season != null)
+                if (item is Season season)
                 {
                     PopulateSeasonImagesFromSeriesFolder(season, images, directoryService);
                 }

+ 2 - 4
MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj

@@ -16,6 +16,8 @@
     <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Nullable>enable</Nullable>
+    <AnalysisMode>AllEnabledByDefault</AnalysisMode>
+    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
   <ItemGroup>
@@ -29,8 +31,4 @@
     <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
   </ItemGroup>
 
-  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-    <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-
 </Project>

+ 2 - 2
MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs

@@ -1275,8 +1275,8 @@ namespace MediaBrowser.LocalMetadata.Parsers
 
             // Only split by comma if there is no pipe in the string
             // We have to be careful to not split names like Matthew, Jr.
-            var separator = value.IndexOf('|', StringComparison.Ordinal) == -1
-                            && value.IndexOf(';', StringComparison.Ordinal) == -1 ? new[] { ',' } : new[] { '|', ';' };
+            var separator = !value.Contains('|', StringComparison.Ordinal)
+                            && !value.Contains(';', StringComparison.Ordinal) ? new[] { ',' } : new[] { '|', ';' };
 
             value = value.Trim().Trim(separator);
 

+ 3 - 3
MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs

@@ -23,7 +23,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
         }
 
         /// <inheritdoc />
-        protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<BoxSet> item)
+        protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<BoxSet> itemResult)
         {
             switch (reader.Name)
             {
@@ -33,7 +33,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
                     {
                         using (var subReader = reader.ReadSubtree())
                         {
-                            FetchFromCollectionItemsNode(subReader, item);
+                            FetchFromCollectionItemsNode(subReader, itemResult);
                         }
                     }
                     else
@@ -44,7 +44,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
                     break;
 
                 default:
-                    base.FetchDataFromXmlNode(reader, item);
+                    base.FetchDataFromXmlNode(reader, itemResult);
                     break;
             }
         }

+ 3 - 3
MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs

@@ -23,9 +23,9 @@ namespace MediaBrowser.LocalMetadata.Parsers
         }
 
         /// <inheritdoc />
-        protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Playlist> result)
+        protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Playlist> itemResult)
         {
-            var item = result.Item;
+            var item = itemResult.Item;
 
             switch (reader.Name)
             {
@@ -53,7 +53,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
                     break;
 
                 default:
-                    base.FetchDataFromXmlNode(reader, result);
+                    base.FetchDataFromXmlNode(reader, itemResult);
                     break;
             }
         }

+ 4 - 13
MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs

@@ -5,7 +5,6 @@ using System.Linq;
 using System.Text;
 using System.Threading;
 using System.Xml;
-using MediaBrowser.Common.Extensions;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Movies;
@@ -37,7 +36,7 @@ namespace MediaBrowser.LocalMetadata.Savers
         /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
         /// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
         /// <param name="logger">Instance of the <see cref="ILogger{BaseXmlSaver}"/> interface.</param>
-        public BaseXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger<BaseXmlSaver> logger)
+        protected BaseXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger<BaseXmlSaver> logger)
         {
             FileSystem = fileSystem;
             ConfigurationManager = configurationManager;
@@ -421,20 +420,17 @@ namespace MediaBrowser.LocalMetadata.Savers
                 writer.WriteEndElement();
             }
 
-            var boxset = item as BoxSet;
-            if (boxset != null)
+            if (item is BoxSet boxset)
             {
                 AddLinkedChildren(boxset, writer, "CollectionItems", "CollectionItem");
             }
 
-            var playlist = item as Playlist;
-            if (playlist != null && !Playlist.IsPlaylistFile(playlist.Path))
+            if (item is Playlist playlist && !Playlist.IsPlaylistFile(playlist.Path))
             {
                 AddLinkedChildren(playlist, writer, "PlaylistItems", "PlaylistItem");
             }
 
-            var hasShares = item as IHasShares;
-            if (hasShares != null)
+            if (item is IHasShares hasShares)
             {
                 AddShares(hasShares, writer);
             }
@@ -542,10 +538,5 @@ namespace MediaBrowser.LocalMetadata.Savers
 
             writer.WriteEndElement();
         }
-
-        private bool IsPersonType(PersonInfo person, string type)
-        {
-            return string.Equals(person.Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(person.Role, type, StringComparison.OrdinalIgnoreCase);
-        }
     }
 }

+ 1 - 1
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -86,7 +86,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             _localization = localization;
             _encodingHelperFactory = encodingHelperFactory;
             _startupOptionFFmpegPath = config.GetValue<string>(Controller.Extensions.ConfigurationExtensions.FfmpegPathKey) ?? string.Empty;
-            _jsonSerializerOptions = JsonDefaults.GetOptions();
+            _jsonSerializerOptions = JsonDefaults.Options;
         }
 
         /// <inheritdoc />

+ 1 - 1
MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs

@@ -22,7 +22,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
     {
         private readonly IServerConfigurationManager _config;
         private readonly IHttpClientFactory _httpClientFactory;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         public AudioDbAlbumImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory)
         {

+ 1 - 1
MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs

@@ -29,7 +29,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
         private readonly IServerConfigurationManager _config;
         private readonly IFileSystem _fileSystem;
         private readonly IHttpClientFactory _httpClientFactory;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         public static AudioDbAlbumProvider Current;
 

+ 1 - 1
MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs

@@ -22,7 +22,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
     {
         private readonly IServerConfigurationManager _config;
         private readonly IHttpClientFactory _httpClientFactory;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         public AudioDbArtistImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory)
         {

+ 1 - 1
MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs

@@ -31,7 +31,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
         private readonly IServerConfigurationManager _config;
         private readonly IFileSystem _fileSystem;
         private readonly IHttpClientFactory _httpClientFactory;
-        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
         public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory)
         {

+ 1 - 1
MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs

@@ -48,7 +48,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
             _configurationManager = configurationManager;
             _appHost = appHost;
 
-            _jsonOptions = new JsonSerializerOptions(JsonDefaults.GetOptions());
+            _jsonOptions = new JsonSerializerOptions(JsonDefaults.Options);
             _jsonOptions.Converters.Add(new JsonOmdbNotAvailableStringConverter());
             _jsonOptions.Converters.Add(new JsonOmdbNotAvailableInt32Converter());
         }

+ 1 - 1
MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs

@@ -39,7 +39,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
             _configurationManager = configurationManager;
             _appHost = appHost;
 
-            _jsonOptions = new JsonSerializerOptions(JsonDefaults.GetOptions());
+            _jsonOptions = new JsonSerializerOptions(JsonDefaults.Options);
             _jsonOptions.Converters.Add(new JsonOmdbNotAvailableStringConverter());
             _jsonOptions.Converters.Add(new JsonOmdbNotAvailableInt32Converter());
         }

+ 1 - 1
tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs

@@ -16,7 +16,7 @@ namespace Jellyfin.MediaEncoding.Tests
             var path = Path.Join("Test Data", fileName);
             using (var stream = File.OpenRead(path))
             {
-                await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream, JsonDefaults.GetOptions()).ConfigureAwait(false);
+                await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream, JsonDefaults.Options).ConfigureAwait(false);
             }
         }
     }

+ 1 - 1
tests/Jellyfin.Server.Integration.Tests/Controllers/DashboardControllerTests.cs

@@ -13,7 +13,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
     public sealed class DashboardControllerTests : IClassFixture<JellyfinApplicationFactory>
     {
         private readonly JellyfinApplicationFactory _factory;
-        private readonly JsonSerializerOptions _jsonOpions = JsonDefaults.GetOptions();
+        private readonly JsonSerializerOptions _jsonOpions = JsonDefaults.Options;
 
         public DashboardControllerTests(JellyfinApplicationFactory factory)
         {