Skip to content

Commit

Permalink
Migrated to .net8, dropped older targets
Browse files Browse the repository at this point in the history
  • Loading branch information
stesee authored Nov 17, 2023
2 parents 3a85a31 + 9f53afb commit f968729
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: cla-assistant/github-action@v2.3.0
uses: cla-assistant/github-action@v2.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
47 changes: 21 additions & 26 deletions .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 All @@ -14,12 +14,12 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -32,12 +32,12 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -48,27 +48,25 @@ jobs:
if: env.NUGET_TOKEN_EXISTS != ''
run: |
dotnet nuget push ./ImageSharpCompare/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.CURRENT_VERSION }}
prerelease: false
title: "Release Build"
files: |
./ImageSharpCompare/bin/Release/*.nupkg
./ImageSharpCompare/bin/Release/*.snupkg
- name: Github release
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
gh release create ${{env.CURRENT_VERSION}} ./ImageSharpCompare/bin/Release/*.*nupkg --generate-notes
deployTest:
if: github.ref != 'refs/heads/release'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -80,13 +78,10 @@ jobs:
run: |
ls ./ImageSharpCompare/bin/Release
dotnet nuget push ./ImageSharpCompare/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
- uses: "marvinpinto/action-automatic-releases@latest"
if: github.ref == 'refs/heads/main'
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-prerelease"
prerelease: true
title: "Prerelease Build"
files: |
./ImageSharpCompare/bin/Release/*.nupkg
./ImageSharpCompare/bin/Release/*.snupkg
- name: Github prerelease
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
gh release create ${{env.CURRENT_VERSION}} ./ImageSharpCompare/bin/Release/*.*nupkg --prerelease --generate-notes
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
12 changes: 5 additions & 7 deletions ImageSharpCompare/ImageSharpCompare.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<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 @@ -46,9 +44,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.49.0.57237">
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<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>
</PackageReference>
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)
{
}
}
}
13 changes: 6 additions & 7 deletions ImageSharpCompareTestNunit/ImageSharpCompareTestNunit.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.49.0.57237">
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit f968729

Please sign in to comment.