[Wox.Infrastructure] Enable analyzer and fix warnings (#16996)

This commit is contained in:
CleanCodeDeveloper
2022-03-14 16:44:17 +01:00
committed by GitHub
parent 7365ba14d0
commit 561882c2f1
7 changed files with 15 additions and 10 deletions

View File

@@ -16,9 +16,9 @@ namespace Wox.Infrastructure.Image
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA5350:Do Not Use Weak Cryptographic Algorithms", Justification = "Level of protection needed for the image data does not require a security guarantee")]
public string GetHashFromImage(ImageSource imageSource)
public string GetHashFromImage(ImageSource image)
{
if (!(imageSource is BitmapSource image))
if (!(image is BitmapSource bitmapSource))
{
return null;
}
@@ -30,7 +30,7 @@ namespace Wox.Infrastructure.Image
// PngBitmapEncoder enc2 = new PngBitmapEncoder();
// enc2.Frames.Add(BitmapFrame.Create(tt));
var enc = new JpegBitmapEncoder();
var bitmapFrame = BitmapFrame.Create(image);
var bitmapFrame = BitmapFrame.Create(bitmapSource);
bitmapFrame.Freeze();
enc.Frames.Add(bitmapFrame);
enc.Save(outStream);