From db688912b55c12a9f420f16e144fe23b3013323a Mon Sep 17 00:00:00 2001 From: Stefan Seeland <168659+stesee@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:33:13 +0100 Subject: [PATCH] Dropped .net6 target --- .github/workflows/dotnet.yml | 2 +- ImageSharpCompare/ImageSharpCompare.cs | 81 +++++-------------- ImageSharpCompare/ImageSharpCompare.csproj | 6 +- .../ImageSharpCompareException.cs | 12 --- .../ImageSharpCompareTestNunit.csproj | 3 +- 5 files changed, 23 insertions(+), 81 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index e8198cd..1dba7c1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,6 +1,6 @@ name: .NET build and test env: - CURRENT_VERSION: 3.0.${{ github.run_number }} + CURRENT_VERSION: 4.0.${{ github.run_number }} LAST_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} on: diff --git a/ImageSharpCompare/ImageSharpCompare.cs b/ImageSharpCompare/ImageSharpCompare.cs index 6a3d434..a7b15ae 100644 --- a/ImageSharpCompare/ImageSharpCompare.cs +++ b/ImageSharpCompare/ImageSharpCompare.cs @@ -20,16 +20,8 @@ public static class ImageSharpCompare private static bool ImagesHaveSameDimension(Image actual, Image expected) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } - - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } - + ArgumentNullException.ThrowIfNull(actual); + ArgumentNullException.ThrowIfNull(expected); return actual.Height == expected.Height && actual.Width == expected.Width; } @@ -137,15 +129,9 @@ public static bool ImagesAreEqual(Stream actual, Stream expected, ResizeOption r /// True if every pixel of actual is equal to expected public static bool ImagesAreEqual(Image actual, Image expected, ResizeOption resizeOption = ResizeOption.DontResize) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } + ArgumentNullException.ThrowIfNull(actual); - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } + ArgumentNullException.ThrowIfNull(expected); var ownsActual = false; var ownsExpected = false; @@ -180,15 +166,9 @@ public static bool ImagesAreEqual(Image actual, Image expected, ResizeOption res /// True if every pixel of actual is equal to expected public static bool ImagesAreEqual(Image actual, Image expected, ResizeOption resizeOption = ResizeOption.DontResize) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } + ArgumentNullException.ThrowIfNull(actual); - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } + ArgumentNullException.ThrowIfNull(expected); if (resizeOption == ResizeOption.DontResize && !ImagesHaveSameDimension(actual, expected)) { @@ -291,15 +271,9 @@ public static ICompareResult CalcDiff(Stream actualImage, Stream expectedImage, /// Mean and absolute pixel error public static ICompareResult CalcDiff(Image actual, Image expected, ResizeOption resizeOption = ResizeOption.DontResize) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } + ArgumentNullException.ThrowIfNull(actual); - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } + ArgumentNullException.ThrowIfNull(expected); var ownsActual = false; var ownsExpected = false; @@ -391,20 +365,11 @@ public static ICompareResult CalcDiff(Image actual, Image expected /// Mean and absolute pixel error public static ICompareResult CalcDiff(Image actual, Image expected, Image maskImage, ResizeOption resizeOption = ResizeOption.DontResize) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } + ArgumentNullException.ThrowIfNull(actual); - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } + ArgumentNullException.ThrowIfNull(expected); - if (maskImage == null) - { - throw new ArgumentNullException(nameof(maskImage)); - } + ArgumentNullException.ThrowIfNull(maskImage); var ownsActual = false; var ownsExpected = false; @@ -448,10 +413,7 @@ public static ICompareResult CalcDiff(Image actual, Image expected, Image maskIm /// Mean and absolute pixel error public static ICompareResult CalcDiff(Image actual, Image expected, Image maskImage, ResizeOption resizeOption = ResizeOption.DontResize) { - if (maskImage == null) - { - throw new ArgumentNullException(nameof(maskImage)); - } + ArgumentNullException.ThrowIfNull(maskImage); var imagesHaveSameDimension = ImagesHaveSameDimension(actual, expected) && ImagesHaveSameDimension(actual, maskImage); @@ -586,15 +548,9 @@ public static Image CalcDiffMaskImage(Stream actualImage, Stream expectedImage, /// Image representing diff, black means no diff between actual image and expected image, white means max diff public static Image CalcDiffMaskImage(Image actual, Image expected, ResizeOption resizeOption = ResizeOption.DontResize) { - if (actual == null) - { - throw new ArgumentNullException(nameof(actual)); - } + ArgumentNullException.ThrowIfNull(actual); - if (expected == null) - { - throw new ArgumentNullException(nameof(expected)); - } + ArgumentNullException.ThrowIfNull(expected); var ownsActual = false; var ownsExpected = false; @@ -631,6 +587,9 @@ public static Image CalcDiffMaskImage(Image actual, Image expected, ResizeOption /// Image representing diff, black means no diff between actual image and expected image, white means max diff public static Image CalcDiffMaskImage(Image actual, Image expected, Image mask, ResizeOption resizeOption = ResizeOption.DontResize) { + ArgumentNullException.ThrowIfNull(actual); + ArgumentNullException.ThrowIfNull(expected); + ArgumentNullException.ThrowIfNull(mask); var ownsActual = false; var ownsExpected = false; var ownsMask = false; @@ -725,6 +684,7 @@ public static Image CalcDiffMaskImage(Image actual, Image expected /// Image representing diff, black means no diff between actual image and expected image, white means max diff public static Image CalcDiffMaskImage(Image actual, Image expected, Image mask, ResizeOption resizeOption = ResizeOption.DontResize) { + ArgumentNullException.ThrowIfNull(mask); var imagesHaveSameDimensions = ImagesHaveSameDimension(actual, expected) && ImagesHaveSameDimension(actual, mask); if (!imagesHaveSameDimensions && resizeOption == ResizeOption.DontResize) @@ -792,10 +752,7 @@ private static Image ToRgb24Image(Image actual, out bool ownsImage) /// public static Image ConvertRgba32ToRgb24(Image imageRgba32) { - if (imageRgba32 == null) - { - throw new ArgumentNullException(nameof(imageRgba32)); - } + ArgumentNullException.ThrowIfNull(imageRgba32); var maskRgb24 = new Image(imageRgba32.Width, imageRgba32.Height); diff --git a/ImageSharpCompare/ImageSharpCompare.csproj b/ImageSharpCompare/ImageSharpCompare.csproj index 7572bce..61acea5 100644 --- a/ImageSharpCompare/ImageSharpCompare.csproj +++ b/ImageSharpCompare/ImageSharpCompare.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 true true https://github.com/Codeuctivity/ImageSharp.Compare @@ -17,7 +17,6 @@ https://github.com/Codeuctivity/ImageSharp.Compare Compares Images and calculates mean error, absolute error and diff image. Supports optional tolerance mask/images to ignore areas of an image. Use this for automated visual comparing in your unit tests. Apache-2.0 - false ImageSharpCompare.snk true true @@ -25,7 +24,6 @@ true true enable - 8.0 true AllEnabledByDefault latest @@ -47,7 +45,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ImageSharpCompare/ImageSharpCompareException.cs b/ImageSharpCompare/ImageSharpCompareException.cs index a3a67bc..72ecbf7 100644 --- a/ImageSharpCompare/ImageSharpCompareException.cs +++ b/ImageSharpCompare/ImageSharpCompareException.cs @@ -1,12 +1,10 @@ using System; -using System.Runtime.Serialization; namespace Codeuctivity.ImageSharpCompare { /// /// ImageSharpCompareException gets thrown if comparing of images fails /// - [Serializable] public class ImageSharpCompareException : Exception { /// @@ -34,15 +32,5 @@ public ImageSharpCompareException(string message) : base(message) public ImageSharpCompareException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// ImageSharpCompareException gets thrown if comparing of images fails - /// - /// - /// - /// - protected ImageSharpCompareException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } \ No newline at end of file diff --git a/ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj b/ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj index 9de9329..147b79c 100644 --- a/ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj +++ b/ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj @@ -1,9 +1,8 @@  - net6.0;net8.0 + net8.0 false - 8.0 enable true