mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Enable StyleCop analyzer and fix existing issues
This commit is contained in:
		
							parent
							
								
									b8c8d45b8d
								
							
						
					
					
						commit
						2c3e1b8562
					
				@ -26,7 +26,7 @@
 | 
				
			|||||||
  <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
 | 
					  <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
 | 
				
			||||||
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" PrivateAssets="All" />
 | 
					    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" PrivateAssets="All" />
 | 
				
			||||||
    <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
 | 
					    <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
 | 
				
			||||||
    <!-- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" /> -->
 | 
					    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
 | 
				
			||||||
    <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
 | 
					    <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -37,10 +37,10 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
                paint.TextSize = 30;
 | 
					                paint.TextSize = 30;
 | 
				
			||||||
                paint.IsAntialias = true;
 | 
					                paint.IsAntialias = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var text = "✔️";
 | 
					 | 
				
			||||||
                var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
 | 
					 | 
				
			||||||
                // or:
 | 
					                // or:
 | 
				
			||||||
                // var emojiChar = 0x1F680;
 | 
					                // var emojiChar = 0x1F680;
 | 
				
			||||||
 | 
					                var text = "✔️";
 | 
				
			||||||
 | 
					                var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // ask the font manager for a font with that character
 | 
					                // ask the font manager for a font with that character
 | 
				
			||||||
                var fontManager = SKFontManager.Default;
 | 
					                var fontManager = SKFontManager.Default;
 | 
				
			||||||
 | 
				
			|||||||
@ -10,12 +10,6 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
    [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")]
 | 
					    [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")]
 | 
				
			||||||
    public class SkiaCodecException : SkiaException
 | 
					    public class SkiaCodecException : SkiaException
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Returns the non-successful codec result returned by Skia.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        /// <value>The non-successful codec result returned by Skia.</value>
 | 
					 | 
				
			||||||
        public SKCodecResult CodecResult { get; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
 | 
					        /// Initializes a new instance of the <see cref="SkiaCodecException" /> class.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@ -37,6 +31,11 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
            CodecResult = result;
 | 
					            CodecResult = result;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets the non-successful codec result returned by Skia.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public SKCodecResult CodecResult { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <inheritdoc />
 | 
					        /// <inheritdoc />
 | 
				
			||||||
        public override string ToString()
 | 
					        public override string ToString()
 | 
				
			||||||
            => string.Format(
 | 
					            => string.Format(
 | 
				
			||||||
 | 
				
			|||||||
@ -28,6 +28,9 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Initializes a new instance of the <see cref="SkiaEncoder"/> class.
 | 
					        /// Initializes a new instance of the <see cref="SkiaEncoder"/> class.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="logger">The application logger.</param>
 | 
				
			||||||
 | 
					        /// <param name="appPaths">The application paths.</param>
 | 
				
			||||||
 | 
					        /// <param name="localizationManager">The application localization manager.</param>
 | 
				
			||||||
        public SkiaEncoder(
 | 
					        public SkiaEncoder(
 | 
				
			||||||
            ILogger<SkiaEncoder> logger,
 | 
					            ILogger<SkiaEncoder> logger,
 | 
				
			||||||
            IApplicationPaths appPaths,
 | 
					            IApplicationPaths appPaths,
 | 
				
			||||||
@ -80,7 +83,7 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
            => new HashSet<ImageFormat>() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png };
 | 
					            => new HashSet<ImageFormat>() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Test to determine if the native lib is available
 | 
					        /// Test to determine if the native lib is available.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public static void TestSkia()
 | 
					        public static void TestSkia()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -288,6 +291,14 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Decode an image.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="path">The filepath of the image to decode.</param>
 | 
				
			||||||
 | 
					        /// <param name="forceCleanBitmap">Whether to force clean the bitmap.</param>
 | 
				
			||||||
 | 
					        /// <param name="orientation">The orientation of the image.</param>
 | 
				
			||||||
 | 
					        /// <param name="origin">The detected origin of the image.</param>
 | 
				
			||||||
 | 
					        /// <returns>The resulting bitmap of the image.</returns>
 | 
				
			||||||
        internal SKBitmap Decode(string path, bool forceCleanBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
					        internal SKBitmap Decode(string path, bool forceCleanBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!File.Exists(path))
 | 
					            if (!File.Exists(path))
 | 
				
			||||||
@ -629,6 +640,7 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return outputPath;
 | 
					            return outputPath;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Initializes a new instance of the <see cref="StripCollageBuilder"/> class.
 | 
					        /// Initializes a new instance of the <see cref="StripCollageBuilder"/> class.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="skiaEncoder">The encoder to use for building collages.</param>
 | 
				
			||||||
        public StripCollageBuilder(SkiaEncoder skiaEncoder)
 | 
					        public StripCollageBuilder(SkiaEncoder skiaEncoder)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _skiaEncoder = skiaEncoder;
 | 
					            _skiaEncoder = skiaEncoder;
 | 
				
			||||||
@ -123,6 +124,7 @@ namespace Jellyfin.Drawing.Skia
 | 
				
			|||||||
                        using (var resizeBitmap = new SKBitmap(iWidth, iHeight, currentBitmap.ColorType, currentBitmap.AlphaType))
 | 
					                        using (var resizeBitmap = new SKBitmap(iWidth, iHeight, currentBitmap.ColorType, currentBitmap.AlphaType))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            currentBitmap.ScalePixels(resizeBitmap, SKFilterQuality.High);
 | 
					                            currentBitmap.ScalePixels(resizeBitmap, SKFilterQuality.High);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            // crop image
 | 
					                            // crop image
 | 
				
			||||||
                            int ix = (int)Math.Abs((iWidth - iSlice) / 2);
 | 
					                            int ix = (int)Math.Abs((iWidth - iSlice) / 2);
 | 
				
			||||||
                            using (var image = SKImage.FromBitmap(resizeBitmap))
 | 
					                            using (var image = SKImage.FromBitmap(resizeBitmap))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user