Răsfoiți Sursa

Fix and disable new dotnet6 warnings

Cody Robibero 3 ani în urmă
părinte
comite
64652b6392

+ 4 - 1
Directory.Build.props

@@ -3,10 +3,13 @@
 
   <PropertyGroup>
     <Nullable>enable</Nullable>
-    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)/jellyfin.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
 
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+  </PropertyGroup>
+
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
     <AnalysisMode>AllEnabledByDefault</AnalysisMode>
   </PropertyGroup>

+ 1 - 1
Emby.Drawing/ImageProcessor.cs

@@ -26,7 +26,7 @@ namespace Emby.Drawing
     public sealed class ImageProcessor : IImageProcessor, IDisposable
     {
         // Increment this when there's a change requiring caches to be invalidated
-        private const string Version = "3";
+        private const char Version = '3';
 
         private static readonly HashSet<string> _transparentImageTypes
             = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };

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

@@ -1805,7 +1805,7 @@ namespace Jellyfin.Api.Controllers
                 _logger.LogError(ex, "Error deleting partial stream file(s) {path}", path);
 
                 var task = Task.Delay(100);
-                Task.WaitAll(task);
+                task.Wait();
                 DeleteFile(path, retryCount + 1);
             }
             catch (Exception ex)

+ 3 - 3
Jellyfin.Api/Controllers/HlsSegmentController.cs

@@ -64,7 +64,7 @@ namespace Jellyfin.Api.Controllers
             var transcodePath = _serverConfigurationManager.GetTranscodePath();
             file = Path.GetFullPath(Path.Combine(transcodePath, file));
             var fileDir = Path.GetDirectoryName(file);
-            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath))
+            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath, StringComparison.InvariantCulture))
             {
                 return BadRequest("Invalid segment.");
             }
@@ -90,7 +90,7 @@ namespace Jellyfin.Api.Controllers
             var transcodePath = _serverConfigurationManager.GetTranscodePath();
             file = Path.GetFullPath(Path.Combine(transcodePath, file));
             var fileDir = Path.GetDirectoryName(file);
-            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath) || Path.GetExtension(file) != ".m3u8")
+            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath, StringComparison.InvariantCulture) || Path.GetExtension(file) != ".m3u8")
             {
                 return BadRequest("Invalid segment.");
             }
@@ -144,7 +144,7 @@ namespace Jellyfin.Api.Controllers
 
             file = Path.GetFullPath(Path.Combine(transcodeFolderPath, file));
             var fileDir = Path.GetDirectoryName(file);
-            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodeFolderPath))
+            if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodeFolderPath, StringComparison.InvariantCulture))
             {
                 return BadRequest("Invalid segment.");
             }

+ 3 - 3
Jellyfin.Api/Controllers/ImageByNameController.cs

@@ -82,7 +82,7 @@ namespace Jellyfin.Api.Controllers
                 return NotFound();
             }
 
-            if (!path.StartsWith(_applicationPaths.GeneralPath))
+            if (!path.StartsWith(_applicationPaths.GeneralPath, StringComparison.InvariantCulture))
             {
                 return BadRequest("Invalid image path.");
             }
@@ -177,7 +177,7 @@ namespace Jellyfin.Api.Controllers
 
                 if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
                 {
-                    if (!path.StartsWith(basePath))
+                    if (!path.StartsWith(basePath, StringComparison.InvariantCulture))
                     {
                         return BadRequest("Invalid image path.");
                     }
@@ -196,7 +196,7 @@ namespace Jellyfin.Api.Controllers
 
                 if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
                 {
-                    if (!path.StartsWith(basePath))
+                    if (!path.StartsWith(basePath, StringComparison.InvariantCulture))
                     {
                         return BadRequest("Invalid image path.");
                     }

+ 1 - 1
Jellyfin.Api/Helpers/ClassMigrationHelper.cs

@@ -19,7 +19,7 @@ namespace Jellyfin.Api.Helpers
             // If any this null throw an exception.
             if (source == null || destination == null)
             {
-                throw new Exception("Source or/and Destination Objects are null");
+                throw new ArgumentException("Source or/and Destination Objects are null");
             }
 
             // Getting the Types of the objects.

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

@@ -148,7 +148,7 @@ namespace Jellyfin.Api.Helpers
 
                     mediaSource = string.IsNullOrEmpty(streamingRequest.MediaSourceId)
                         ? mediaSources[0]
-                        : mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.InvariantCulture));
+                        : mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.Ordinal));
 
                     if (mediaSource == null && Guid.Parse(streamingRequest.MediaSourceId) == streamingRequest.Id)
                     {

+ 2 - 0
Jellyfin.Api/Helpers/TranscodingJobHelper.cs

@@ -283,6 +283,7 @@ namespace Jellyfin.Api.Helpers
 
             lock (job.ProcessLock!)
             {
+                #pragma warning disable CA1849 // Can't await in lock block
                 job.TranscodingThrottler?.Stop().GetAwaiter().GetResult();
 
                 var process = job.Process;
@@ -308,6 +309,7 @@ namespace Jellyfin.Api.Helpers
                     {
                     }
                 }
+                #pragma warning restore CA1849
             }
 
             if (delete(job.Path!))

+ 2 - 0
MediaBrowser.Controller/Entities/Folder.cs

@@ -1013,6 +1013,7 @@ namespace MediaBrowser.Controller.Entities
                 items = CollapseBoxSetItemsIfNeeded(items, query, this, user, ConfigurationManager, CollectionManager);
             }
 
+            #pragma warning disable CA1309
             if (!string.IsNullOrEmpty(query.NameStartsWithOrGreater))
             {
                 items = items.Where(i => string.Compare(query.NameStartsWithOrGreater, i.SortName, StringComparison.InvariantCultureIgnoreCase) < 1);
@@ -1027,6 +1028,7 @@ namespace MediaBrowser.Controller.Entities
             {
                 items = items.Where(i => string.Compare(query.NameLessThan, i.SortName, StringComparison.InvariantCultureIgnoreCase) == 1);
             }
+            #pragma warning restore CA1309
 
             // This must be the last filter
             if (!string.IsNullOrEmpty(query.AdjacentTo))

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

@@ -412,7 +412,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
                 {
                     var actors = reader.ReadInnerXml();
 
-                    if (actors.Contains("<", StringComparison.Ordinal))
+                    if (actors.Contains('<', StringComparison.Ordinal))
                     {
                         // This is one of the mis-named "Actors" full nodes created by MB2
                         // Create a reader and pass it to the persons node processor

+ 0 - 14
MediaBrowser.Model/Dlna/DlnaMaps.cs

@@ -6,20 +6,6 @@ namespace MediaBrowser.Model.Dlna
 {
     public static class DlnaMaps
     {
-        private static readonly string DefaultStreaming =
-            FlagsToString(DlnaFlags.StreamingTransferMode |
-                           DlnaFlags.BackgroundTransferMode |
-                           DlnaFlags.ConnectionStall |
-                           DlnaFlags.ByteBasedSeek |
-                           DlnaFlags.DlnaV15);
-
-        private static readonly string DefaultInteractive =
-            FlagsToString(DlnaFlags.InteractiveTransferMode |
-                        DlnaFlags.BackgroundTransferMode |
-                        DlnaFlags.ConnectionStall |
-                        DlnaFlags.ByteBasedSeek |
-                        DlnaFlags.DlnaV15);
-
         public static string FlagsToString(DlnaFlags flags)
         {
             return string.Format(CultureInfo.InvariantCulture, "{0:X8}{1:D24}", (ulong)flags, 0);

+ 1 - 1
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -794,7 +794,7 @@ namespace MediaBrowser.Model.Dlna
                 }
 
                 // strip spaces to avoid having to encode h264 profile names
-                list.Add(new NameValuePair(pair.Key, pair.Value.Replace(" ", string.Empty)));
+                list.Add(new NameValuePair(pair.Key, pair.Value.Replace(" ", string.Empty, StringComparison.Ordinal)));
             }
 
             if (!item.IsDirectStream)

+ 2 - 2
MediaBrowser.Providers/MediaInfo/EmbeddedImageProvider.cs

@@ -125,7 +125,7 @@ namespace MediaBrowser.Providers.MediaInfo
 
             if (attachmentStream != null)
             {
-                return await ExtractAttachment(item, cancellationToken, attachmentStream, mediaSource);
+                return await ExtractAttachment(item, attachmentStream, mediaSource, cancellationToken);
             }
 
             // Fall back to EmbeddedImage streams
@@ -169,7 +169,7 @@ namespace MediaBrowser.Providers.MediaInfo
             };
         }
 
-        private async Task<DynamicImageResponse> ExtractAttachment(Video item, CancellationToken cancellationToken, MediaAttachment attachmentStream, MediaSourceInfo mediaSource)
+        private async Task<DynamicImageResponse> ExtractAttachment(Video item, MediaAttachment attachmentStream, MediaSourceInfo mediaSource, CancellationToken cancellationToken)
         {
             var extension = string.IsNullOrEmpty(attachmentStream.MimeType)
                 ? Path.GetExtension(attachmentStream.FileName)