Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped .net6 target #81

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
81 changes: 19 additions & 62 deletions ImageSharpCompare/ImageSharpCompare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -137,15 +129,9 @@ public static bool ImagesAreEqual(Stream actual, Stream expected, ResizeOption r
/// <returns>True if every pixel of actual is equal to expected</returns>
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;
Expand Down Expand Up @@ -180,15 +166,9 @@ public static bool ImagesAreEqual(Image actual, Image expected, ResizeOption res
/// <returns>True if every pixel of actual is equal to expected</returns>
public static bool ImagesAreEqual(Image<Rgb24> actual, Image<Rgb24> 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))
{
Expand Down Expand Up @@ -291,15 +271,9 @@ public static ICompareResult CalcDiff(Stream actualImage, Stream expectedImage,
/// <returns>Mean and absolute pixel error</returns>
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;
Expand Down Expand Up @@ -391,20 +365,11 @@ public static ICompareResult CalcDiff(Image<Rgb24> actual, Image<Rgb24> expected
/// <returns>Mean and absolute pixel error</returns>
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;
Expand Down Expand Up @@ -448,10 +413,7 @@ public static ICompareResult CalcDiff(Image actual, Image expected, Image maskIm
/// <returns>Mean and absolute pixel error</returns>
public static ICompareResult CalcDiff(Image<Rgb24> actual, Image<Rgb24> expected, Image<Rgb24> maskImage, ResizeOption resizeOption = ResizeOption.DontResize)
{
if (maskImage == null)
{
throw new ArgumentNullException(nameof(maskImage));
}
ArgumentNullException.ThrowIfNull(maskImage);

var imagesHaveSameDimension = ImagesHaveSameDimension(actual, expected) && ImagesHaveSameDimension(actual, maskImage);

Expand Down Expand Up @@ -586,15 +548,9 @@ public static Image CalcDiffMaskImage(Stream actualImage, Stream expectedImage,
/// <returns>Image representing diff, black means no diff between actual image and expected image, white means max diff</returns>
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;
Expand Down Expand Up @@ -631,6 +587,9 @@ public static Image CalcDiffMaskImage(Image actual, Image expected, ResizeOption
/// <returns>Image representing diff, black means no diff between actual image and expected image, white means max diff</returns>
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;
Expand Down Expand Up @@ -725,6 +684,7 @@ public static Image CalcDiffMaskImage(Image<Rgb24> actual, Image<Rgb24> expected
/// <returns>Image representing diff, black means no diff between actual image and expected image, white means max diff</returns>
public static Image CalcDiffMaskImage(Image<Rgb24> actual, Image<Rgb24> expected, Image<Rgb24> mask, ResizeOption resizeOption = ResizeOption.DontResize)
{
ArgumentNullException.ThrowIfNull(mask);
var imagesHaveSameDimensions = ImagesHaveSameDimension(actual, expected) && ImagesHaveSameDimension(actual, mask);

if (!imagesHaveSameDimensions && resizeOption == ResizeOption.DontResize)
Expand Down Expand Up @@ -792,10 +752,7 @@ private static Image<Rgb24> ToRgb24Image(Image actual, out bool ownsImage)
/// <param name="imageRgba32"></param>
public static Image<Rgb24> ConvertRgba32ToRgb24(Image<Rgba32> imageRgba32)
{
if (imageRgba32 == null)
{
throw new ArgumentNullException(nameof(imageRgba32));
}
ArgumentNullException.ThrowIfNull(imageRgba32);

var maskRgb24 = new Image<Rgb24>(imageRgba32.Width, imageRgba32.Height);

Expand Down
6 changes: 2 additions & 4 deletions ImageSharpCompare/ImageSharpCompare.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RepositoryUrl>https://github.com/Codeuctivity/ImageSharp.Compare</RepositoryUrl>
Expand All @@ -17,15 +17,13 @@
<PackageProjectUrl>https://github.com/Codeuctivity/ImageSharp.Compare</PackageProjectUrl>
<Description>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.</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyOriginatorKeyFile>ImageSharpCompare.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
Expand All @@ -47,7 +45,7 @@

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
12 changes: 0 additions & 12 deletions ImageSharpCompare/ImageSharpCompareException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Runtime.Serialization;

namespace Codeuctivity.ImageSharpCompare
{
/// <summary>
/// ImageSharpCompareException gets thrown if comparing of images fails
/// </summary>
[Serializable]
public class ImageSharpCompareException : Exception
{
/// <summary>
Expand Down Expand Up @@ -34,15 +32,5 @@ public ImageSharpCompareException(string message) : base(message)
public ImageSharpCompareException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// ImageSharpCompareException gets thrown if comparing of images fails
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
/// <returns></returns>
protected ImageSharpCompareException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
3 changes: 1 addition & 2 deletions ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
Expand Down