diff --git a/.gitmodules b/.gitmodules index 94d28dd526..0c2e133f45 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "shared-infrastructure"] path = shared-infrastructure - url = https://github.com/SixLabors/SharedInfrastructure + url = https://github.com/stefannikolei/SharedInfrastructure diff --git a/shared-infrastructure b/shared-infrastructure index 7ac5703452..6491506cf4 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 7ac5703452348d9295db31fc0912c2bd9e419dc9 +Subproject commit 6491506cf4a330de2d743453b30c506ed7c74af7 diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 71f2bc333c..0e22a882a1 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -21,7 +21,6 @@ - diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index db8892cd75..f7afa5d15b 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -4,7 +4,7 @@ using SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; using SixLabors.ImageSharp.Tests.ProfilingBenchmarks; using SixLabors.ImageSharp.Tests.ProfilingSandbox; -using Xunit.Abstractions; +using Xunit; // in this file, comments are used for disabling stuff for local execution #pragma warning disable SA1515 @@ -32,7 +32,12 @@ static void RunToVector4ProfilingTest() sealed class ConsoleOutput : ITestOutputHelper { + public void Write(string message) => Console.Write(message); + + public void Write(string format, params object[] args) => Console.Write(format, args); + public void WriteLine(string message) => Console.WriteLine(message); public void WriteLine(string format, params object[] args) => Console.WriteLine(format, args); + public string Output { get; } } diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs index cb349af96a..2e5b294a2a 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs @@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using Wacton.Unicolour; using Wacton.Unicolour.Icc; -using Xunit.Abstractions; using Rgb = SixLabors.ImageSharp.ColorProfiles.Rgb; namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc; diff --git a/tests/ImageSharp.Tests/Common/NumericsTests.cs b/tests/ImageSharp.Tests/Common/NumericsTests.cs index ebee570600..dde1d2feaa 100644 --- a/tests/ImageSharp.Tests/Common/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Common/NumericsTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Common; diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index dfd0a6b307..e75bb3943b 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -7,7 +7,6 @@ using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Common; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index 610693c7f4..fe9d5ed6d2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -7,7 +7,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index fb1e062f20..c5a24b484e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -4,7 +4,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index b17a39f388..b0e35c7b0a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -4,7 +4,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs index 36b792fa1c..2cc0a961ff 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs @@ -2,7 +2,6 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index ba0dce4c54..07b7bddadd 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Tests.ColorProfiles; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 2f84a1a7b7..f3005d124b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index b6a59fa93e..a14df945a1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs index c593a029ab..d049472c86 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index 2fcd953ae0..80b42cce61 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -4,7 +4,6 @@ // ReSharper disable InconsistentNaming using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs index b447349720..b6c5ba1c92 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs index 2e97b9596b..4f6870bcd7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 1610df6eb4..2028c09a83 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index 13300ee804..14c7aacd57 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -7,7 +7,6 @@ using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index 33e95c5aa0..57866989ab 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index 7c7f47f946..8b58dd2f03 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -5,7 +5,6 @@ using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Formats.Jpeg.Components; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index 7a31e35d0c..4928515a24 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 3a31b395f7..84a95ee9d5 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png.Filters; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Png; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index eef8d5ba84..a60f4bd72e 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -200,14 +200,14 @@ public void WorksWithAllBitDepths(TestImageProvider provider, Pn return; } - foreach (object[] filterMethod in PngFilterMethods) + foreach (TheoryDataRow filterMethod in PngFilterMethods) { foreach (PngInterlaceMode interlaceMode in InterlaceMode) { TestPngEncoderCore( provider, pngColorType, - (PngFilterMethod)filterMethod[0], + filterMethod.Data, pngBitDepth, interlaceMode, appendPngColorType: true, @@ -236,14 +236,14 @@ public void WorksWithAllBitDepths(TestImageProvider provider, Pn public void WorksWithAllBitDepthsAndExcludeAllFilter(TestImageProvider provider, PngColorType pngColorType, PngBitDepth pngBitDepth) where TPixel : unmanaged, IPixel { - foreach (object[] filterMethod in PngFilterMethods) + foreach (TheoryDataRow filterMethod in PngFilterMethods) { foreach (PngInterlaceMode interlaceMode in InterlaceMode) { TestPngEncoderCore( provider, pngColorType, - (PngFilterMethod)filterMethod[0], + filterMethod.Data, pngBitDepth, interlaceMode, appendPngColorType: true, diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs index 017926fc5d..ec9ee571c6 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs @@ -7,7 +7,6 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Helpers; diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs index 0656f9e0bc..06ce7fd634 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs @@ -58,7 +58,7 @@ private static TheoryData CreateLoadData() public static TheoryData LoadData { get; } = CreateLoadData(); // TODO: Figure out cancellation failures on Linux - [ConditionalTheory(typeof(TestEnvironment), nameof(TestEnvironment.IsWindows))] + [Theory(Skip = "Skipped on non-Windows platforms", SkipType = typeof(TestEnvironment), SkipUnless = nameof(TestEnvironment.IsWindows))] [MemberData(nameof(LoadData))] public async Task LoadAsync_IsCancellable(bool useMemoryStream, string file, double percentageOfStreamReadToCancel) { diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index a1d5b0ee2b..25d30b514d 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -45,7 +45,6 @@ - diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index fd9760f48f..453b0ed036 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -14,9 +14,7 @@ public partial class UniformUnmanagedMemoryPoolTests public class Trim { [CollectionDefinition(nameof(NonParallelTests), DisableParallelization = true)] - public class NonParallelTests - { - } + public class NonParallelTests { } [Fact] public void TrimPeriodElapsed_TrimsHalfOfUnusedArrays() @@ -24,7 +22,10 @@ public void TrimPeriodElapsed_TrimsHalfOfUnusedArrays() RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() + { + TrimPeriodMilliseconds = 5_000, + }; UniformUnmanagedMemoryPool pool = new(128, 256, trimSettings); UnmanagedMemoryHandle[] a = pool.Rent(64); @@ -37,7 +38,8 @@ static void RunTest() // 128 - 32 - 16 = 80 Assert.True( UnmanagedMemoryHandle.TotalOutstandingHandles <= 80, - $"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 80"); + $"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 80" + ); pool.Return(b); } } @@ -46,18 +48,16 @@ static void RunTest() // MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed, // which is strongly timing-sensitive, and might be flaky under high load. [CollectionDefinition(nameof(NonParallelCollection), DisableParallelization = true)] - public class NonParallelCollection - { - } + public class NonParallelCollection { } [Collection(nameof(NonParallelCollection))] public class NonParallel { - public static readonly bool IsNotMacOS = !TestEnvironment.IsMacOS; + public static bool IsNotMacOS => !TestEnvironment.IsMacOS; // TODO: Investigate failures on macOS. All handles are released after GC. // (It seems to happen more consistently on .NET 6.) - [ConditionalFact(nameof(IsNotMacOS))] + [Fact(Skip = "Skipped on macOS", SkipUnless = nameof(IsNotMacOS))] public void MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed() { if (!TestEnvironment.RunsOnCI) @@ -77,10 +77,16 @@ public void MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed() static void RunTest() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() + { + TrimPeriodMilliseconds = 6_000, + }; UniformUnmanagedMemoryPool pool1 = new(128, 256, trimSettings1); Thread.Sleep(8_000); // Let some callbacks fire already - UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() + { + TrimPeriodMilliseconds = 3_000, + }; UniformUnmanagedMemoryPool pool2 = new(128, 256, trimSettings2); pool1.Return(pool1.Rent(64)); @@ -96,7 +102,8 @@ static void RunTest() Thread.Sleep(15_000); Assert.True( UnmanagedMemoryHandle.TotalOutstandingHandles <= 64, - $"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 64"); + $"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 64" + ); GC.KeepAlive(pool1); GC.KeepAlive(pool2); } @@ -104,13 +111,16 @@ static void RunTest() [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 4_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() + { + TrimPeriodMilliseconds = 4_000, + }; _ = new UniformUnmanagedMemoryPool(128, 256, trimSettings); } } } - public static readonly bool Is32BitProcess = !Environment.Is64BitProcess; + public static bool Is32BitProcess => !Environment.Is64BitProcess; private static readonly List PressureArrays = []; [Fact] @@ -129,11 +139,16 @@ static void RunTest() Assert.False(Environment.Is64BitProcess); const int oneMb = 1 << 20; - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { HighPressureThresholdRate = 0.2f }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() + { + HighPressureThresholdRate = 0.2f, + }; GCMemoryInfo memInfo = GC.GetGCMemoryInfo(); int highLoadThreshold = (int)(memInfo.HighMemoryLoadThresholdBytes / oneMb); - highLoadThreshold = (int)(trimSettings.HighPressureThresholdRate * highLoadThreshold); + highLoadThreshold = (int)( + trimSettings.HighPressureThresholdRate * highLoadThreshold + ); UniformUnmanagedMemoryPool pool = new(oneMb, 16, trimSettings); pool.Return(pool.Rent(16)); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs index ec79d91c3d..7e9e8294fc 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs @@ -5,7 +5,6 @@ using System.Runtime.InteropServices; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Memory.Internals; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Memory.Allocators; @@ -28,11 +27,13 @@ public CleanupUtil(UniformUnmanagedMemoryPool pool) public void Register(UnmanagedMemoryHandle handle) => this.handlesToDestroy.Add(handle); - public void Register(IEnumerable handles) => this.handlesToDestroy.AddRange(handles); + public void Register(IEnumerable handles) => + this.handlesToDestroy.AddRange(handles); public void Register(IntPtr memoryPtr) => this.ptrsToDestroy.Add(memoryPtr); - public void Register(IEnumerable memoryPtrs) => this.ptrsToDestroy.AddRange(memoryPtrs); + public void Register(IEnumerable memoryPtrs) => + this.ptrsToDestroy.AddRange(memoryPtrs); public void Dispose() { @@ -94,7 +95,11 @@ static void RunTest() } } - private static void CheckBuffer(int length, UniformUnmanagedMemoryPool pool, UnmanagedMemoryHandle h) + private static void CheckBuffer( + int length, + UniformUnmanagedMemoryPool pool, + UnmanagedMemoryHandle h + ) { Assert.False(h.IsInvalid); Span span = GetSpan(h, pool.BufferLength); @@ -105,7 +110,8 @@ private static void CheckBuffer(int length, UniformUnmanagedMemoryPool pool, Unm Assert.True(span.SequenceEqual(expected)); } - private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new(h.Pointer, length); + private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => + new(h.Pointer, length); [Theory] [InlineData(1, 1)] @@ -210,7 +216,11 @@ public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() [InlineData(0, 6, 5)] [InlineData(5, 1, 5)] [InlineData(4, 7, 10)] - public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attempt, int capacity) + public void Rent_MultiBuffer_OverCapacity_ReturnsNull( + int initialRent, + int attempt, + int capacity + ) { UniformUnmanagedMemoryPool pool = new(128, capacity); using CleanupUtil cleanup = new(pool); @@ -238,10 +248,10 @@ public void Rent_MultiBuff_BelowCapacity_Succeeds(int initialRent, int attempt, cleanup.Register(b1); } - public static readonly bool IsNotMacOS = !TestEnvironment.IsMacOS; + public static bool IsNotMacOS => !TestEnvironment.IsMacOS; // TODO: Investigate macOS failures - [ConditionalTheory(nameof(IsNotMacOS))] + [Theory(Skip = "Skipped on macOS", SkipUnless = nameof(IsNotMacOS))] [InlineData(false)] [InlineData(true)] public void RentReturnRelease_SubsequentRentReturnsDifferentHandles(bool multiple) @@ -261,7 +271,10 @@ static void RunTest(string multipleInner) pool.Release(); // Do some unmanaged allocations to make sure new pool buffers are different: - IntPtr[] dummy = Enumerable.Range(0, 100).Select(_ => Marshal.AllocHGlobal(16)).ToArray(); + IntPtr[] dummy = Enumerable + .Range(0, 100) + .Select(_ => Marshal.AllocHGlobal(16)) + .ToArray(); cleanup.Register(dummy); if (bool.Parse(multipleInner)) @@ -310,34 +323,38 @@ public void RentReturn_IsThreadSafe() using CleanupUtil cleanup = new(pool); Random rnd = new(0); - Parallel.For(0, Environment.ProcessorCount, (int i) => - { - List allHandles = new(); - int pauseAt = rnd.Next(100); - for (int j = 0; j < 100; j++) + Parallel.For( + 0, + Environment.ProcessorCount, + (int i) => { - UnmanagedMemoryHandle[] data = pool.Rent(2); + List allHandles = new(); + int pauseAt = rnd.Next(100); + for (int j = 0; j < 100; j++) + { + UnmanagedMemoryHandle[] data = pool.Rent(2); - GetSpan(data[0], pool.BufferLength).Fill((byte)i); - GetSpan(data[1], pool.BufferLength).Fill((byte)i); - allHandles.Add(data[0]); - allHandles.Add(data[1]); + GetSpan(data[0], pool.BufferLength).Fill((byte)i); + GetSpan(data[1], pool.BufferLength).Fill((byte)i); + allHandles.Add(data[0]); + allHandles.Add(data[1]); - if (j == pauseAt) - { - Thread.Sleep(15); + if (j == pauseAt) + { + Thread.Sleep(15); + } } - } - Span expected = new byte[8]; - expected.Fill((byte)i); + Span expected = new byte[8]; + expected.Fill((byte)i); - foreach (UnmanagedMemoryHandle h in allHandles) - { - Assert.True(expected.SequenceEqual(GetSpan(h, pool.BufferLength))); - pool.Return(new[] { h }); + foreach (UnmanagedMemoryHandle h in allHandles) + { + Assert.True(expected.SequenceEqual(GetSpan(h, pool.BufferLength))); + pool.Return(new[] { h }); + } } - }); + ); } [Theory] diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index b4593d4d09..887b266856 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -584,7 +584,7 @@ static void RunTest() } } - [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] + [Fact(Skip = "Requires 64-bit process", SkipType = typeof(Environment), SkipUnless = nameof(Environment.Is64BitProcess))] public void MemoryAllocator_Create_SetHighLimit() { RemoteExecutor.Invoke(RunTest).Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index d7d6741baf..7c6319db51 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -11,329 +11,329 @@ public class ExifValuesTests { public static TheoryData ByteTags => new() { - { ExifTag.FaxProfile }, - { ExifTag.ModeNumber }, - { ExifTag.GPSAltitudeRef } + { (ExifTag)ExifTag.FaxProfile }, + { (ExifTag)ExifTag.ModeNumber }, + { (ExifTag)ExifTag.GPSAltitudeRef } }; public static TheoryData ByteArrayTags => new() { - { ExifTag.ClipPath }, - { ExifTag.VersionYear }, - { ExifTag.XMP }, - { ExifTag.CFAPattern2 }, - { ExifTag.TIFFEPStandardID }, - { ExifTag.GPSVersionID }, + { (ExifTag)ExifTag.ClipPath }, + { (ExifTag)ExifTag.VersionYear }, + { (ExifTag)ExifTag.XMP }, + { (ExifTag)ExifTag.CFAPattern2 }, + { (ExifTag)ExifTag.TIFFEPStandardID }, + { (ExifTag)ExifTag.GPSVersionID }, }; public static TheoryData DoubleArrayTags => new() { - { ExifTag.PixelScale }, - { ExifTag.IntergraphMatrix }, - { ExifTag.ModelTiePoint }, - { ExifTag.ModelTransform } + { (ExifTag)ExifTag.PixelScale }, + { (ExifTag)ExifTag.IntergraphMatrix }, + { (ExifTag)ExifTag.ModelTiePoint }, + { (ExifTag)ExifTag.ModelTransform } }; public static TheoryData LongTags => new() { - { ExifTag.SubfileType }, - { ExifTag.SubIFDOffset }, - { ExifTag.GPSIFDOffset }, - { ExifTag.T4Options }, - { ExifTag.T6Options }, - { ExifTag.XClipPathUnits }, - { ExifTag.YClipPathUnits }, - { ExifTag.ProfileType }, - { ExifTag.CodingMethods }, - { ExifTag.T82ptions }, - { ExifTag.JPEGInterchangeFormat }, - { ExifTag.JPEGInterchangeFormatLength }, - { ExifTag.MDFileTag }, - { ExifTag.StandardOutputSensitivity }, - { ExifTag.RecommendedExposureIndex }, - { ExifTag.ISOSpeed }, - { ExifTag.ISOSpeedLatitudeyyy }, - { ExifTag.ISOSpeedLatitudezzz }, - { ExifTag.FaxRecvParams }, - { ExifTag.FaxRecvTime }, - { ExifTag.ImageNumber }, + { (ExifTag)ExifTag.SubfileType }, + { (ExifTag)ExifTag.SubIFDOffset }, + { (ExifTag)ExifTag.GPSIFDOffset }, + { (ExifTag)ExifTag.T4Options }, + { (ExifTag)ExifTag.T6Options }, + { (ExifTag)ExifTag.XClipPathUnits }, + { (ExifTag)ExifTag.YClipPathUnits }, + { (ExifTag)ExifTag.ProfileType }, + { (ExifTag)ExifTag.CodingMethods }, + { (ExifTag)ExifTag.T82ptions }, + { (ExifTag)ExifTag.JPEGInterchangeFormat }, + { (ExifTag)ExifTag.JPEGInterchangeFormatLength }, + { (ExifTag)ExifTag.MDFileTag }, + { (ExifTag)ExifTag.StandardOutputSensitivity }, + { (ExifTag)ExifTag.RecommendedExposureIndex }, + { (ExifTag)ExifTag.ISOSpeed }, + { (ExifTag)ExifTag.ISOSpeedLatitudeyyy }, + { (ExifTag)ExifTag.ISOSpeedLatitudezzz }, + { (ExifTag)ExifTag.FaxRecvParams }, + { (ExifTag)ExifTag.FaxRecvTime }, + { (ExifTag)ExifTag.ImageNumber }, }; public static TheoryData LongArrayTags => new() { - { ExifTag.FreeOffsets }, - { ExifTag.FreeByteCounts }, - { ExifTag.ColorResponseUnit }, - { ExifTag.SMinSampleValue }, - { ExifTag.SMaxSampleValue }, - { ExifTag.JPEGQTables }, - { ExifTag.JPEGDCTables }, - { ExifTag.JPEGACTables }, - { ExifTag.StripRowCounts }, - { ExifTag.IntergraphRegisters } + { (ExifTag)ExifTag.FreeOffsets }, + { (ExifTag)ExifTag.FreeByteCounts }, + { (ExifTag)ExifTag.ColorResponseUnit }, + { (ExifTag)ExifTag.SMinSampleValue }, + { (ExifTag)ExifTag.SMaxSampleValue }, + { (ExifTag)ExifTag.JPEGQTables }, + { (ExifTag)ExifTag.JPEGDCTables }, + { (ExifTag)ExifTag.JPEGACTables }, + { (ExifTag)ExifTag.StripRowCounts }, + { (ExifTag)ExifTag.IntergraphRegisters } }; public static TheoryData NumberTags => new() { - { ExifTag.ImageWidth }, - { ExifTag.ImageLength }, - { ExifTag.TileWidth }, - { ExifTag.TileLength }, - { ExifTag.BadFaxLines }, - { ExifTag.ConsecutiveBadFaxLines }, - { ExifTag.PixelXDimension }, - { ExifTag.PixelYDimension } + { (ExifTag)ExifTag.ImageWidth }, + { (ExifTag)ExifTag.ImageLength }, + { (ExifTag)ExifTag.TileWidth }, + { (ExifTag)ExifTag.TileLength }, + { (ExifTag)ExifTag.BadFaxLines }, + { (ExifTag)ExifTag.ConsecutiveBadFaxLines }, + { (ExifTag)ExifTag.PixelXDimension }, + { (ExifTag)ExifTag.PixelYDimension } }; public static TheoryData NumberArrayTags => new() { - { ExifTag.StripOffsets }, - { ExifTag.StripByteCounts }, - { ExifTag.TileByteCounts }, - { ExifTag.TileOffsets }, - { ExifTag.ImageLayer } + { (ExifTag)ExifTag.StripOffsets }, + { (ExifTag)ExifTag.StripByteCounts }, + { (ExifTag)ExifTag.TileByteCounts }, + { (ExifTag)ExifTag.TileOffsets }, + { (ExifTag)ExifTag.ImageLayer } }; public static TheoryData RationalTags => new() { - { ExifTag.XPosition }, - { ExifTag.YPosition }, - { ExifTag.XResolution }, - { ExifTag.YResolution }, - { ExifTag.BatteryLevel }, - { ExifTag.ExposureTime }, - { ExifTag.FNumber }, - { ExifTag.MDScalePixel }, - { ExifTag.CompressedBitsPerPixel }, - { ExifTag.ApertureValue }, - { ExifTag.MaxApertureValue }, - { ExifTag.SubjectDistance }, - { ExifTag.FocalLength }, - { ExifTag.FlashEnergy2 }, - { ExifTag.FocalPlaneXResolution2 }, - { ExifTag.FocalPlaneYResolution2 }, - { ExifTag.ExposureIndex2 }, - { ExifTag.Humidity }, - { ExifTag.Pressure }, - { ExifTag.Acceleration }, - { ExifTag.FlashEnergy }, - { ExifTag.FocalPlaneXResolution }, - { ExifTag.FocalPlaneYResolution }, - { ExifTag.ExposureIndex }, - { ExifTag.DigitalZoomRatio }, - { ExifTag.GPSAltitude }, - { ExifTag.GPSDOP }, - { ExifTag.GPSSpeed }, - { ExifTag.GPSTrack }, - { ExifTag.GPSImgDirection }, - { ExifTag.GPSDestBearing }, - { ExifTag.GPSDestDistance }, - { ExifTag.GPSHPositioningError }, + { (ExifTag)ExifTag.XPosition }, + { (ExifTag)ExifTag.YPosition }, + { (ExifTag)ExifTag.XResolution }, + { (ExifTag)ExifTag.YResolution }, + { (ExifTag)ExifTag.BatteryLevel }, + { (ExifTag)ExifTag.ExposureTime }, + { (ExifTag)ExifTag.FNumber }, + { (ExifTag)ExifTag.MDScalePixel }, + { (ExifTag)ExifTag.CompressedBitsPerPixel }, + { (ExifTag)ExifTag.ApertureValue }, + { (ExifTag)ExifTag.MaxApertureValue }, + { (ExifTag)ExifTag.SubjectDistance }, + { (ExifTag)ExifTag.FocalLength }, + { (ExifTag)ExifTag.FlashEnergy2 }, + { (ExifTag)ExifTag.FocalPlaneXResolution2 }, + { (ExifTag)ExifTag.FocalPlaneYResolution2 }, + { (ExifTag)ExifTag.ExposureIndex2 }, + { (ExifTag)ExifTag.Humidity }, + { (ExifTag)ExifTag.Pressure }, + { (ExifTag)ExifTag.Acceleration }, + { (ExifTag)ExifTag.FlashEnergy }, + { (ExifTag)ExifTag.FocalPlaneXResolution }, + { (ExifTag)ExifTag.FocalPlaneYResolution }, + { (ExifTag)ExifTag.ExposureIndex }, + { (ExifTag)ExifTag.DigitalZoomRatio }, + { (ExifTag)ExifTag.GPSAltitude }, + { (ExifTag)ExifTag.GPSDOP }, + { (ExifTag)ExifTag.GPSSpeed }, + { (ExifTag)ExifTag.GPSTrack }, + { (ExifTag)ExifTag.GPSImgDirection }, + { (ExifTag)ExifTag.GPSDestBearing }, + { (ExifTag)ExifTag.GPSDestDistance }, + { (ExifTag)ExifTag.GPSHPositioningError }, }; public static TheoryData RationalArrayTags => new() { - { ExifTag.WhitePoint }, - { ExifTag.PrimaryChromaticities }, - { ExifTag.YCbCrCoefficients }, - { ExifTag.ReferenceBlackWhite }, - { ExifTag.GPSLatitude }, - { ExifTag.GPSLongitude }, - { ExifTag.GPSTimestamp }, - { ExifTag.GPSDestLatitude }, - { ExifTag.GPSDestLongitude }, - { ExifTag.LensSpecification } + { (ExifTag)ExifTag.WhitePoint }, + { (ExifTag)ExifTag.PrimaryChromaticities }, + { (ExifTag)ExifTag.YCbCrCoefficients }, + { (ExifTag)ExifTag.ReferenceBlackWhite }, + { (ExifTag)ExifTag.GPSLatitude }, + { (ExifTag)ExifTag.GPSLongitude }, + { (ExifTag)ExifTag.GPSTimestamp }, + { (ExifTag)ExifTag.GPSDestLatitude }, + { (ExifTag)ExifTag.GPSDestLongitude }, + { (ExifTag)ExifTag.LensSpecification } }; public static TheoryData ShortTags => new() { - { ExifTag.OldSubfileType }, - { ExifTag.Compression }, - { ExifTag.PhotometricInterpretation }, - { ExifTag.Thresholding }, - { ExifTag.CellWidth }, - { ExifTag.CellLength }, - { ExifTag.FillOrder }, - { ExifTag.Orientation }, - { ExifTag.SamplesPerPixel }, - { ExifTag.PlanarConfiguration }, - { ExifTag.Predictor }, - { ExifTag.GrayResponseUnit }, - { ExifTag.ResolutionUnit }, - { ExifTag.CleanFaxData }, - { ExifTag.InkSet }, - { ExifTag.NumberOfInks }, - { ExifTag.DotRange }, - { ExifTag.Indexed }, - { ExifTag.OPIProxy }, - { ExifTag.JPEGProc }, - { ExifTag.JPEGRestartInterval }, - { ExifTag.YCbCrPositioning }, - { ExifTag.Rating }, - { ExifTag.RatingPercent }, - { ExifTag.ExposureProgram }, - { ExifTag.Interlace }, - { ExifTag.SelfTimerMode }, - { ExifTag.SensitivityType }, - { ExifTag.MeteringMode }, - { ExifTag.LightSource }, - { ExifTag.FocalPlaneResolutionUnit2 }, - { ExifTag.SensingMethod2 }, - { ExifTag.Flash }, - { ExifTag.ColorSpace }, - { ExifTag.FocalPlaneResolutionUnit }, - { ExifTag.SensingMethod }, - { ExifTag.CustomRendered }, - { ExifTag.ExposureMode }, - { ExifTag.WhiteBalance }, - { ExifTag.FocalLengthIn35mmFilm }, - { ExifTag.SceneCaptureType }, - { ExifTag.GainControl }, - { ExifTag.Contrast }, - { ExifTag.Saturation }, - { ExifTag.Sharpness }, - { ExifTag.SubjectDistanceRange }, - { ExifTag.GPSDifferential } + { (ExifTag)ExifTag.OldSubfileType }, + { (ExifTag)ExifTag.Compression }, + { (ExifTag)ExifTag.PhotometricInterpretation }, + { (ExifTag)ExifTag.Thresholding }, + { (ExifTag)ExifTag.CellWidth }, + { (ExifTag)ExifTag.CellLength }, + { (ExifTag)ExifTag.FillOrder }, + { (ExifTag)ExifTag.Orientation }, + { (ExifTag)ExifTag.SamplesPerPixel }, + { (ExifTag)ExifTag.PlanarConfiguration }, + { (ExifTag)ExifTag.Predictor }, + { (ExifTag)ExifTag.GrayResponseUnit }, + { (ExifTag)ExifTag.ResolutionUnit }, + { (ExifTag)ExifTag.CleanFaxData }, + { (ExifTag)ExifTag.InkSet }, + { (ExifTag)ExifTag.NumberOfInks }, + { (ExifTag)ExifTag.DotRange }, + { (ExifTag)ExifTag.Indexed }, + { (ExifTag)ExifTag.OPIProxy }, + { (ExifTag)ExifTag.JPEGProc }, + { (ExifTag)ExifTag.JPEGRestartInterval }, + { (ExifTag)ExifTag.YCbCrPositioning }, + { (ExifTag)ExifTag.Rating }, + { (ExifTag)ExifTag.RatingPercent }, + { (ExifTag)ExifTag.ExposureProgram }, + { (ExifTag)ExifTag.Interlace }, + { (ExifTag)ExifTag.SelfTimerMode }, + { (ExifTag)ExifTag.SensitivityType }, + { (ExifTag)ExifTag.MeteringMode }, + { (ExifTag)ExifTag.LightSource }, + { (ExifTag)ExifTag.FocalPlaneResolutionUnit2 }, + { (ExifTag)ExifTag.SensingMethod2 }, + { (ExifTag)ExifTag.Flash }, + { (ExifTag)ExifTag.ColorSpace }, + { (ExifTag)ExifTag.FocalPlaneResolutionUnit }, + { (ExifTag)ExifTag.SensingMethod }, + { (ExifTag)ExifTag.CustomRendered }, + { (ExifTag)ExifTag.ExposureMode }, + { (ExifTag)ExifTag.WhiteBalance }, + { (ExifTag)ExifTag.FocalLengthIn35mmFilm }, + { (ExifTag)ExifTag.SceneCaptureType }, + { (ExifTag)ExifTag.GainControl }, + { (ExifTag)ExifTag.Contrast }, + { (ExifTag)ExifTag.Saturation }, + { (ExifTag)ExifTag.Sharpness }, + { (ExifTag)ExifTag.SubjectDistanceRange }, + { (ExifTag)ExifTag.GPSDifferential } }; public static TheoryData ShortArrayTags => new() { - { ExifTag.BitsPerSample }, - { ExifTag.MinSampleValue }, - { ExifTag.MaxSampleValue }, - { ExifTag.GrayResponseCurve }, - { ExifTag.ColorMap }, - { ExifTag.ExtraSamples }, - { ExifTag.PageNumber }, - { ExifTag.TransferFunction }, - { ExifTag.HalftoneHints }, - { ExifTag.SampleFormat }, - { ExifTag.TransferRange }, - { ExifTag.DefaultImageColor }, - { ExifTag.JPEGLosslessPredictors }, - { ExifTag.JPEGPointTransforms }, - { ExifTag.YCbCrSubsampling }, - { ExifTag.CFARepeatPatternDim }, - { ExifTag.IntergraphPacketData }, - { ExifTag.ISOSpeedRatings }, - { ExifTag.SubjectArea }, - { ExifTag.SubjectLocation } + { (ExifTag)ExifTag.BitsPerSample }, + { (ExifTag)ExifTag.MinSampleValue }, + { (ExifTag)ExifTag.MaxSampleValue }, + { (ExifTag)ExifTag.GrayResponseCurve }, + { (ExifTag)ExifTag.ColorMap }, + { (ExifTag)ExifTag.ExtraSamples }, + { (ExifTag)ExifTag.PageNumber }, + { (ExifTag)ExifTag.TransferFunction }, + { (ExifTag)ExifTag.HalftoneHints }, + { (ExifTag)ExifTag.SampleFormat }, + { (ExifTag)ExifTag.TransferRange }, + { (ExifTag)ExifTag.DefaultImageColor }, + { (ExifTag)ExifTag.JPEGLosslessPredictors }, + { (ExifTag)ExifTag.JPEGPointTransforms }, + { (ExifTag)ExifTag.YCbCrSubsampling }, + { (ExifTag)ExifTag.CFARepeatPatternDim }, + { (ExifTag)ExifTag.IntergraphPacketData }, + { (ExifTag)ExifTag.ISOSpeedRatings }, + { (ExifTag)ExifTag.SubjectArea }, + { (ExifTag)ExifTag.SubjectLocation } }; public static TheoryData SignedRationalTags => new() { - { ExifTag.ShutterSpeedValue }, - { ExifTag.BrightnessValue }, - { ExifTag.ExposureBiasValue }, - { ExifTag.AmbientTemperature }, - { ExifTag.WaterDepth }, - { ExifTag.CameraElevationAngle } + { (ExifTag)ExifTag.ShutterSpeedValue }, + { (ExifTag)ExifTag.BrightnessValue }, + { (ExifTag)ExifTag.ExposureBiasValue }, + { (ExifTag)ExifTag.AmbientTemperature }, + { (ExifTag)ExifTag.WaterDepth }, + { (ExifTag)ExifTag.CameraElevationAngle } }; public static TheoryData SignedRationalArrayTags => new() { - { ExifTag.Decode } + { (ExifTag)ExifTag.Decode } }; public static TheoryData SignedShortArrayTags => new() { - { ExifTag.TimeZoneOffset } + { (ExifTag)ExifTag.TimeZoneOffset } }; public static TheoryData StringTags => new() { - { ExifTag.ImageDescription }, - { ExifTag.Make }, - { ExifTag.Model }, - { ExifTag.Software }, - { ExifTag.DateTime }, - { ExifTag.Artist }, - { ExifTag.HostComputer }, - { ExifTag.Copyright }, - { ExifTag.DocumentName }, - { ExifTag.PageName }, - { ExifTag.InkNames }, - { ExifTag.TargetPrinter }, - { ExifTag.ImageID }, - { ExifTag.MDLabName }, - { ExifTag.MDSampleInfo }, - { ExifTag.MDPrepDate }, - { ExifTag.MDPrepTime }, - { ExifTag.MDFileUnits }, - { ExifTag.SEMInfo }, - { ExifTag.SpectralSensitivity }, - { ExifTag.DateTimeOriginal }, - { ExifTag.DateTimeDigitized }, - { ExifTag.SubsecTime }, - { ExifTag.SubsecTimeOriginal }, - { ExifTag.SubsecTimeDigitized }, - { ExifTag.RelatedSoundFile }, - { ExifTag.FaxSubaddress }, - { ExifTag.OffsetTime }, - { ExifTag.OffsetTimeOriginal }, - { ExifTag.OffsetTimeDigitized }, - { ExifTag.SecurityClassification }, - { ExifTag.ImageHistory }, - { ExifTag.ImageUniqueID }, - { ExifTag.OwnerName }, - { ExifTag.SerialNumber }, - { ExifTag.LensMake }, - { ExifTag.LensModel }, - { ExifTag.LensSerialNumber }, - { ExifTag.GDALMetadata }, - { ExifTag.GDALNoData }, - { ExifTag.GPSLatitudeRef }, - { ExifTag.GPSLongitudeRef }, - { ExifTag.GPSSatellites }, - { ExifTag.GPSStatus }, - { ExifTag.GPSMeasureMode }, - { ExifTag.GPSSpeedRef }, - { ExifTag.GPSTrackRef }, - { ExifTag.GPSImgDirectionRef }, - { ExifTag.GPSMapDatum }, - { ExifTag.GPSDestLatitudeRef }, - { ExifTag.GPSDestLongitudeRef }, - { ExifTag.GPSDestBearingRef }, - { ExifTag.GPSDestDistanceRef }, - { ExifTag.GPSDateStamp }, + { (ExifTag)ExifTag.ImageDescription }, + { (ExifTag)ExifTag.Make }, + { (ExifTag)ExifTag.Model }, + { (ExifTag)ExifTag.Software }, + { (ExifTag)ExifTag.DateTime }, + { (ExifTag)ExifTag.Artist }, + { (ExifTag)ExifTag.HostComputer }, + { (ExifTag)ExifTag.Copyright }, + { (ExifTag)ExifTag.DocumentName }, + { (ExifTag)ExifTag.PageName }, + { (ExifTag)ExifTag.InkNames }, + { (ExifTag)ExifTag.TargetPrinter }, + { (ExifTag)ExifTag.ImageID }, + { (ExifTag)ExifTag.MDLabName }, + { (ExifTag)ExifTag.MDSampleInfo }, + { (ExifTag)ExifTag.MDPrepDate }, + { (ExifTag)ExifTag.MDPrepTime }, + { (ExifTag)ExifTag.MDFileUnits }, + { (ExifTag)ExifTag.SEMInfo }, + { (ExifTag)ExifTag.SpectralSensitivity }, + { (ExifTag)ExifTag.DateTimeOriginal }, + { (ExifTag)ExifTag.DateTimeDigitized }, + { (ExifTag)ExifTag.SubsecTime }, + { (ExifTag)ExifTag.SubsecTimeOriginal }, + { (ExifTag)ExifTag.SubsecTimeDigitized }, + { (ExifTag)ExifTag.RelatedSoundFile }, + { (ExifTag)ExifTag.FaxSubaddress }, + { (ExifTag)ExifTag.OffsetTime }, + { (ExifTag)ExifTag.OffsetTimeOriginal }, + { (ExifTag)ExifTag.OffsetTimeDigitized }, + { (ExifTag)ExifTag.SecurityClassification }, + { (ExifTag)ExifTag.ImageHistory }, + { (ExifTag)ExifTag.ImageUniqueID }, + { (ExifTag)ExifTag.OwnerName }, + { (ExifTag)ExifTag.SerialNumber }, + { (ExifTag)ExifTag.LensMake }, + { (ExifTag)ExifTag.LensModel }, + { (ExifTag)ExifTag.LensSerialNumber }, + { (ExifTag)ExifTag.GDALMetadata }, + { (ExifTag)ExifTag.GDALNoData }, + { (ExifTag)ExifTag.GPSLatitudeRef }, + { (ExifTag)ExifTag.GPSLongitudeRef }, + { (ExifTag)ExifTag.GPSSatellites }, + { (ExifTag)ExifTag.GPSStatus }, + { (ExifTag)ExifTag.GPSMeasureMode }, + { (ExifTag)ExifTag.GPSSpeedRef }, + { (ExifTag)ExifTag.GPSTrackRef }, + { (ExifTag)ExifTag.GPSImgDirectionRef }, + { (ExifTag)ExifTag.GPSMapDatum }, + { (ExifTag)ExifTag.GPSDestLatitudeRef }, + { (ExifTag)ExifTag.GPSDestLongitudeRef }, + { (ExifTag)ExifTag.GPSDestBearingRef }, + { (ExifTag)ExifTag.GPSDestDistanceRef }, + { (ExifTag)ExifTag.GPSDateStamp }, }; public static TheoryData UndefinedTags => new() { - { ExifTag.FileSource }, - { ExifTag.SceneType } + { (ExifTag)ExifTag.FileSource }, + { (ExifTag)ExifTag.SceneType } }; public static TheoryData UndefinedArrayTags => new() { - { ExifTag.JPEGTables }, - { ExifTag.OECF }, - { ExifTag.ExifVersion }, - { ExifTag.ComponentsConfiguration }, - { ExifTag.MakerNote }, - { ExifTag.FlashpixVersion }, - { ExifTag.SpatialFrequencyResponse }, - { ExifTag.SpatialFrequencyResponse2 }, - { ExifTag.Noise }, - { ExifTag.CFAPattern }, - { ExifTag.DeviceSettingDescription }, - { ExifTag.ImageSourceData }, + { (ExifTag)ExifTag.JPEGTables }, + { (ExifTag)ExifTag.OECF }, + { (ExifTag)ExifTag.ExifVersion }, + { (ExifTag)ExifTag.ComponentsConfiguration }, + { (ExifTag)ExifTag.MakerNote }, + { (ExifTag)ExifTag.FlashpixVersion }, + { (ExifTag)ExifTag.SpatialFrequencyResponse }, + { (ExifTag)ExifTag.SpatialFrequencyResponse2 }, + { (ExifTag)ExifTag.Noise }, + { (ExifTag)ExifTag.CFAPattern }, + { (ExifTag)ExifTag.DeviceSettingDescription }, + { (ExifTag)ExifTag.ImageSourceData }, }; public static TheoryData EncodedStringTags => new() { - { ExifTag.UserComment }, - { ExifTag.GPSProcessingMethod }, - { ExifTag.GPSAreaInformation } + { (ExifTag)ExifTag.UserComment }, + { (ExifTag)ExifTag.GPSProcessingMethod }, + { (ExifTag)ExifTag.GPSAreaInformation } }; public static TheoryData Ucs2StringTags => new() { - { ExifTag.XPTitle }, - { ExifTag.XPComment }, - { ExifTag.XPAuthor }, - { ExifTag.XPKeywords }, - { ExifTag.XPSubject }, + { (ExifTag)ExifTag.XPTitle }, + { (ExifTag)ExifTag.XPComment }, + { (ExifTag)ExifTag.XPAuthor }, + { (ExifTag)ExifTag.XPKeywords }, + { (ExifTag)ExifTag.XPSubject }, }; [Theory] diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index 1ca865ef41..d5c7760617 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats; public class L8Tests { public static readonly TheoryData LuminanceData - = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 }; + = new() { (byte)0, (byte)1, (byte)2, (byte)3, (byte)5, (byte)13, (byte)31, (byte)71, (byte)73, (byte)79, (byte)83, (byte)109, (byte)127, (byte)128, (byte)131, (byte)199, (byte)250, (byte)251, (byte)254, (byte)255 }; [Theory] [InlineData(0)] diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index f6cbfc4426..735c4f9159 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats; public class La16Tests { public static readonly TheoryData LuminanceData - = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 }; + = new() { (byte)0, (byte)1, (byte)2, (byte)3, (byte)5, (byte)13, (byte)31, (byte)71, (byte)73, (byte)79, (byte)83, (byte)109, (byte)127, (byte)128, (byte)131, (byte)199, (byte)250, (byte)251, (byte)254, (byte)255 }; [Theory] [InlineData(0, 0)] diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs index b372829270..e91f96b8e4 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs @@ -5,7 +5,6 @@ using SixLabors.ImageSharp.PixelFormats; using Xunit; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 32b62fc03d..b701d4d0ac 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -10,7 +10,6 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Common; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; @@ -315,35 +314,35 @@ public void ToVector4(int count) public static readonly TheoryData Generic_To_Data = new() { - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), - new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), + (object)new TestPixel(), }; [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index 3d4c239c93..b440d56eb4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Processing.Processors.Convolution; using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 25acd3aa67..3c2e5e0d50 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -43,8 +43,8 @@ public static readonly TheoryData OrderedDitherers public static readonly TheoryData DefaultInstanceDitherers = new() { - default(ErrorDither), - default(OrderedDither) + (IDither)default(ErrorDither), + (IDither)default(OrderedDither) }; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs index 00e09d83b0..b2073f8de5 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs @@ -74,79 +74,79 @@ public static readonly TheoryData Quantizers = new() { // Known uses error diffusion by default. - KnownQuantizers.Hexadecatree, - KnownQuantizers.WebSafe, - KnownQuantizers.Werner, - KnownQuantizers.Wu, - new HexadecatreeQuantizer(NoDitherOptions), - new WebSafePaletteQuantizer(NoDitherOptions), - new WernerPaletteQuantizer(NoDitherOptions), - new WuQuantizer(NoDitherOptions), - new HexadecatreeQuantizer(OrderedDitherOptions), - new WebSafePaletteQuantizer(OrderedDitherOptions), - new WernerPaletteQuantizer(OrderedDitherOptions), - new WuQuantizer(OrderedDitherOptions) + (IQuantizer)KnownQuantizers.Hexadecatree, + (IQuantizer)KnownQuantizers.WebSafe, + (IQuantizer)KnownQuantizers.Werner, + (IQuantizer)KnownQuantizers.Wu, + (IQuantizer)new HexadecatreeQuantizer(NoDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(NoDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(NoDitherOptions), + (IQuantizer)new WuQuantizer(NoDitherOptions), + (IQuantizer)new HexadecatreeQuantizer(OrderedDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(OrderedDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(OrderedDitherOptions), + (IQuantizer)new WuQuantizer(OrderedDitherOptions) }; public static readonly TheoryData DitherScaleQuantizers = new() { - new HexadecatreeQuantizer(Diffuser0_ScaleDitherOptions), - new WebSafePaletteQuantizer(Diffuser0_ScaleDitherOptions), - new WernerPaletteQuantizer(Diffuser0_ScaleDitherOptions), - new WuQuantizer(Diffuser0_ScaleDitherOptions), - - new HexadecatreeQuantizer(Diffuser0_25_ScaleDitherOptions), - new WebSafePaletteQuantizer(Diffuser0_25_ScaleDitherOptions), - new WernerPaletteQuantizer(Diffuser0_25_ScaleDitherOptions), - new WuQuantizer(Diffuser0_25_ScaleDitherOptions), - - new HexadecatreeQuantizer(Diffuser0_5_ScaleDitherOptions), - new WebSafePaletteQuantizer(Diffuser0_5_ScaleDitherOptions), - new WernerPaletteQuantizer(Diffuser0_5_ScaleDitherOptions), - new WuQuantizer(Diffuser0_5_ScaleDitherOptions), - - new HexadecatreeQuantizer(Diffuser0_75_ScaleDitherOptions), - new WebSafePaletteQuantizer(Diffuser0_75_ScaleDitherOptions), - new WernerPaletteQuantizer(Diffuser0_75_ScaleDitherOptions), - new WuQuantizer(Diffuser0_75_ScaleDitherOptions), - - new HexadecatreeQuantizer(DiffuserDitherOptions), - new WebSafePaletteQuantizer(DiffuserDitherOptions), - new WernerPaletteQuantizer(DiffuserDitherOptions), - new WuQuantizer(DiffuserDitherOptions), - - new HexadecatreeQuantizer(Ordered0_ScaleDitherOptions), - new WebSafePaletteQuantizer(Ordered0_ScaleDitherOptions), - new WernerPaletteQuantizer(Ordered0_ScaleDitherOptions), - new WuQuantizer(Ordered0_ScaleDitherOptions), - - new HexadecatreeQuantizer(Ordered0_25_ScaleDitherOptions), - new WebSafePaletteQuantizer(Ordered0_25_ScaleDitherOptions), - new WernerPaletteQuantizer(Ordered0_25_ScaleDitherOptions), - new WuQuantizer(Ordered0_25_ScaleDitherOptions), - - new HexadecatreeQuantizer(Ordered0_5_ScaleDitherOptions), - new WebSafePaletteQuantizer(Ordered0_5_ScaleDitherOptions), - new WernerPaletteQuantizer(Ordered0_5_ScaleDitherOptions), - new WuQuantizer(Ordered0_5_ScaleDitherOptions), - - new HexadecatreeQuantizer(Ordered0_75_ScaleDitherOptions), - new WebSafePaletteQuantizer(Ordered0_75_ScaleDitherOptions), - new WernerPaletteQuantizer(Ordered0_75_ScaleDitherOptions), - new WuQuantizer(Ordered0_75_ScaleDitherOptions), - - new HexadecatreeQuantizer(OrderedDitherOptions), - new WebSafePaletteQuantizer(OrderedDitherOptions), - new WernerPaletteQuantizer(OrderedDitherOptions), - new WuQuantizer(OrderedDitherOptions), + (IQuantizer)new HexadecatreeQuantizer(Diffuser0_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Diffuser0_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Diffuser0_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Diffuser0_25_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_25_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Diffuser0_25_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Diffuser0_25_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Diffuser0_5_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_5_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Diffuser0_5_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Diffuser0_5_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Diffuser0_75_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_75_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Diffuser0_75_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Diffuser0_75_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(DiffuserDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(DiffuserDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(DiffuserDitherOptions), + (IQuantizer)new WuQuantizer(DiffuserDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Ordered0_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Ordered0_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Ordered0_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Ordered0_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Ordered0_25_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Ordered0_25_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Ordered0_25_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Ordered0_25_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Ordered0_5_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Ordered0_5_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Ordered0_5_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Ordered0_5_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(Ordered0_75_ScaleDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(Ordered0_75_ScaleDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(Ordered0_75_ScaleDitherOptions), + (IQuantizer)new WuQuantizer(Ordered0_75_ScaleDitherOptions), + + (IQuantizer)new HexadecatreeQuantizer(OrderedDitherOptions), + (IQuantizer)new WebSafePaletteQuantizer(OrderedDitherOptions), + (IQuantizer)new WernerPaletteQuantizer(OrderedDitherOptions), + (IQuantizer)new WuQuantizer(OrderedDitherOptions), }; public static readonly TheoryData DefaultInstanceDitherers = new() { - default(ErrorDither), - default(OrderedDither) + (IDither)default(ErrorDither), + (IDither)default(OrderedDither) }; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index 941d78c436..2697505c20 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -7,7 +7,6 @@ using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Processing.Transforms; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs index c65f136d66..86b1903bbb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs @@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index 5f9a8055ff..7e85efee49 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -4,7 +4,6 @@ using System.Text; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Transforms; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index 5eee7313d9..fe93263b9c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -15,7 +15,7 @@ public class RotateTests public static readonly TheoryData RotateAngles = new() { - 50, -50, 170, -170 + 50f, -50f, 170f, -170f }; public static readonly TheoryData RotateEnumValues diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index 209dd361ec..e3a5922b1b 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Processing; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks; diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs index bab11b0f9d..145d0e58d5 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs @@ -3,7 +3,6 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index 7191f3ba74..3089c5f028 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -3,6 +3,7 @@ using System.Reflection; using Xunit.Sdk; +using Xunit.v3; namespace SixLabors.ImageSharp.Tests; @@ -42,11 +43,22 @@ protected ImageDataAttributeBase(string memberName, PixelTypes pixelTypes, objec /// public Type MemberType { get; set; } + /// + public override bool SupportsDiscoveryEnumeration() => true; + + /// + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) + { + IEnumerable rows = this.GetDataRows(testMethod); + IReadOnlyCollection result = rows.Select(row => ConvertDataRow(row)).ToList(); + return new ValueTask>(result); + } + /// Returns the data to be used to test the theory. /// The method that is being tested /// One or more sets of theory data. Each invocation of the test method /// is represented by a single object array. - public override IEnumerable GetData(MethodInfo testMethod) + private IEnumerable GetDataRows(MethodInfo testMethod) { IEnumerable addedRows = Enumerable.Empty().ToArray(); if (!string.IsNullOrWhiteSpace(this.MemberName)) @@ -59,11 +71,14 @@ public override IEnumerable GetData(MethodInfo testMethod) object obj = accessor(); if (obj is IEnumerable memberItems) { - addedRows = memberItems.Select(x => x as object[]); - if (addedRows.Any(x => x == null)) + // In xunit.v3, TheoryData yields ITheoryDataRow, not object[]. + // Call GetData() to unpack the row's values. + addedRows = memberItems.Select(x => { - addedRows = memberItems.Select(x => new[] { x }); - } + if (x is ITheoryDataRow row) return row.GetData(); + if (x is object[] arr) return arr; + return new[] { x }; + }); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs b/tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs index 216ed95b8b..a34b9f291d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs @@ -2,7 +2,7 @@ // Licensed under the Six Labors Split License. using System.ComponentModel; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities; @@ -13,8 +13,11 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities; /// internal class BasicSerializer : IXunitSerializationInfo { - private readonly Dictionary map = []; + // Stores (string representation, type) per key. + private readonly Dictionary map = []; + // Separator between key, type AQN and value in the dump format. + // ':' is safe because AssemblyQualifiedName and converter output don't contain it. public const char Separator = ':'; private string DumpToString(Type type) @@ -22,14 +25,14 @@ private string DumpToString(Type type) using MemoryStream ms = new(); using StreamWriter writer = new(ms); writer.WriteLine(type.FullName); - foreach (KeyValuePair kv in this.map) + foreach (KeyValuePair kv in this.map) { - writer.WriteLine($"{kv.Key}{Separator}{kv.Value}"); + // Format: key:TypeAssemblyQualifiedName:value + writer.WriteLine($"{kv.Key}{Separator}{kv.Value.t.AssemblyQualifiedName}{Separator}{kv.Value.str}"); } writer.Flush(); - byte[] data = ms.ToArray(); - return Convert.ToBase64String(data); + return Convert.ToBase64String(ms.ToArray()); } private Type LoadDump(string dump) @@ -41,8 +44,18 @@ private Type LoadDump(string dump) Type type = Type.GetType(reader.ReadLine()); for (string s = reader.ReadLine(); s != null; s = reader.ReadLine()) { - string[] kv = s.Split(Separator); - this.map[kv[0]] = kv[1]; + // Format: key:TypeAQN:value (3 parts max to preserve ':' inside value) + string[] parts = s.Split(Separator, 3); + if (parts.Length == 3) + { + Type valueType = Type.GetType(parts[1]) ?? typeof(string); + this.map[parts[0]] = (parts[2], valueType); + } + else if (parts.Length == 2) + { + // Legacy two-part format: key:value (no type info) + this.map[parts[0]] = (parts[1], typeof(string)); + } } return type; @@ -66,6 +79,7 @@ public static T Deserialize(string dump) return result; } + /// public void AddValue(string key, object value, Type type = null) { Guard.NotNull(key, nameof(key)); @@ -75,21 +89,19 @@ public void AddValue(string key, object value, Type type = null) } type ??= value.GetType(); - - this.map[key] = TypeDescriptor.GetConverter(type).ConvertToInvariantString(value); + this.map[key] = (TypeDescriptor.GetConverter(type).ConvertToInvariantString(value), type); } - public object GetValue(string key, Type type) + /// + public object GetValue(string key) { Guard.NotNull(key, nameof(key)); - if (!this.map.TryGetValue(key, out string str)) + if (!this.map.TryGetValue(key, out (string str, Type type) entry)) { - return type.IsValueType ? Activator.CreateInstance(type) : null; + return null; } - return TypeDescriptor.GetConverter(type).ConvertFromInvariantString(str); + return TypeDescriptor.GetConverter(entry.type).ConvertFromInvariantString(entry.str); } - - public T GetValue(string key) => (T)this.GetValue(key, typeof(T)); } diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index 4cd30fc571..bbe5f221a5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Globalization; using Microsoft.DotNet.RemoteExecutor; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs index 813ed505d8..cc3ebe9882 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs @@ -2,7 +2,7 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index c8c3e09c34..78f3748eb0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -2,8 +2,8 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.PixelFormats; +using Xunit.Sdk; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 3f6e78a348..6ff4ef5fe2 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -6,8 +6,8 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using Xunit.Sdk; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs index 6da5b75f0d..98c03b0f83 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs @@ -3,7 +3,7 @@ using System.Reflection; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index d78edf5bc3..c83d3eba8e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index ab624126b9..befe8ffd06 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -7,8 +7,8 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using Xunit.Sdk; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs index 405d048fc5..96526ffb6d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs @@ -4,7 +4,7 @@ using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index 81f16cf6b9..2fd71e2137 100644 --- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs +++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index d8b0ff7856..964b7c486e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs +++ b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs @@ -3,22 +3,16 @@ using BenchmarkDotNet.Environments; using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; -using Xunit.Sdk; +using Xunit.v3; -[assembly: Xunit.TestFramework(SixLaborsXunitTestFramework.Type, SixLaborsXunitTestFramework.Assembly)] +[assembly: Xunit.TestFramework(typeof(SixLaborsXunitTestFramework))] namespace SixLabors.ImageSharp.Tests.TestUtilities; public class SixLaborsXunitTestFramework : XunitTestFramework { - public const string Type = "SixLabors.ImageSharp.Tests.TestUtilities.SixLaborsXunitTestFramework"; - public const string Assembly = "SixLabors.ImageSharp.Tests"; - - public SixLaborsXunitTestFramework(IMessageSink messageSink) - : base(messageSink) + public SixLaborsXunitTestFramework() { - DiagnosticMessage message = new(HostEnvironmentInfo.GetInformation()); - messageSink.OnMessage(message); + Console.Error.WriteLine(HostEnvironmentInfo.GetInformation()); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 5eb5be0d9a..eafb2e781c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -15,11 +15,14 @@ public static partial class TestEnvironment private const string ActualOutputDirectoryRelativePath = @"tests\Images\ActualOutput"; - private const string ReferenceOutputDirectoryRelativePath = @"tests\Images\External\ReferenceOutput"; + private const string ReferenceOutputDirectoryRelativePath = + @"tests\Images\External\ReferenceOutput"; private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools"; - private static readonly Lazy SolutionDirectoryFullPathLazy = new(GetSolutionDirectoryFullPathImpl); + private static readonly Lazy SolutionDirectoryFullPathLazy = new( + GetSolutionDirectoryFullPathImpl + ); private static readonly Lazy NetCoreVersionLazy = new(GetNetCoreVersion); @@ -52,7 +55,9 @@ public static partial class TestEnvironment internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; - private static readonly FileInfo TestAssemblyFile = new(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); + private static readonly FileInfo TestAssemblyFile = new( + typeof(TestEnvironment).GetTypeInfo().Assembly.Location + ); private static string GetSolutionDirectoryFullPathImpl() { @@ -68,12 +73,15 @@ private static string GetSolutionDirectoryFullPathImpl() { throw new DirectoryNotFoundException( $"Unable to find ImageSharp solution directory from {TestAssemblyFile} because of {ex.GetType().Name}!", - ex); + ex + ); } if (directory == null) { - throw new DirectoryNotFoundException($"Unable to find ImageSharp solution directory from {TestAssemblyFile}!"); + throw new DirectoryNotFoundException( + $"Unable to find ImageSharp solution directory from {TestAssemblyFile}!" + ); } } @@ -82,7 +90,7 @@ private static string GetSolutionDirectoryFullPathImpl() private static string GetFullPath(string relativePath) => Path.Combine(SolutionDirectoryFullPath, relativePath) - .Replace('\\', Path.DirectorySeparatorChar); + .Replace('\\', Path.DirectorySeparatorChar); /// /// Gets the correct full path to the Input Images directory. @@ -92,17 +100,21 @@ private static string GetFullPath(string relativePath) => /// /// Gets the correct full path to the Actual Output directory. (To be written to by the test cases.) /// - internal static string ActualOutputDirectoryFullPath => GetFullPath(ActualOutputDirectoryRelativePath); + internal static string ActualOutputDirectoryFullPath => + GetFullPath(ActualOutputDirectoryRelativePath); /// /// Gets the correct full path to the Expected Output directory. (To compare the test results to.) /// - internal static string ReferenceOutputDirectoryFullPath => GetFullPath(ReferenceOutputDirectoryRelativePath); + internal static string ReferenceOutputDirectoryFullPath => + GetFullPath(ReferenceOutputDirectoryRelativePath); internal static string ToolsDirectoryFullPath => GetFullPath(ToolsDirectoryRelativePath); internal static string GetReferenceOutputFileName(string actualOutputFileName) => - actualOutputFileName.Replace("ActualOutput", @"External\ReferenceOutput").Replace('\\', Path.DirectorySeparatorChar); + actualOutputFileName + .Replace("ActualOutput", @"External\ReferenceOutput") + .Replace('\\', Path.DirectorySeparatorChar); internal static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); @@ -110,7 +122,7 @@ internal static string GetReferenceOutputFileName(string actualOutputFileName) = internal static bool IsMono => Type.GetType("Mono.Runtime") != null; // https://stackoverflow.com/a/721194 - internal static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); internal static bool Is64BitProcess => IntPtr.Size == 8; @@ -123,9 +135,7 @@ internal static string GetReferenceOutputFileName(string actualOutputFileName) = /// /// A dummy operation to enforce the execution of the static constructor. /// - internal static void EnsureSharedInitializersDone() - { - } + internal static void EnsureSharedInitializersDone() { } /// /// Creates the image output directory. @@ -164,8 +174,10 @@ private static void PrepareRemoteExecutor() return; } - string remoteExecutorConfigPath = - Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe.config"); + string remoteExecutorConfigPath = Path.Combine( + TestAssemblyFile.DirectoryName, + "Microsoft.DotNet.RemoteExecutor.exe.config" + ); if (File.Exists(remoteExecutorConfigPath)) { @@ -196,11 +208,15 @@ private static void EnsureRemoteExecutorIs32Bit() string windowsSdksDir = Path.Combine( Environment.GetEnvironmentVariable("PROGRAMFILES(x86)"), "Microsoft SDKs", - "Windows"); + "Windows" + ); FileInfo corFlagsFile = Find(new DirectoryInfo(windowsSdksDir), "CorFlags.exe"); - string remoteExecutorPath = Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe"); + string remoteExecutorPath = Path.Combine( + TestAssemblyFile.DirectoryName, + "Microsoft.DotNet.RemoteExecutor.exe" + ); string remoteExecutorTmpPath = $"{remoteExecutorPath}._tmp"; @@ -220,7 +236,7 @@ private static void EnsureRemoteExecutorIs32Bit() Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, - RedirectStandardError = true + RedirectStandardError = true, }; using Process proc = Process.Start(si); @@ -231,7 +247,8 @@ private static void EnsureRemoteExecutorIs32Bit() if (proc.ExitCode != 0) { throw new Exception( - $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}"); + $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}" + ); } File.Delete(remoteExecutorPath); @@ -265,7 +282,10 @@ static FileInfo Find(DirectoryInfo root, string name) private static Version GetNetCoreVersion() { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; - string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly.Location.Split( + ['/', '\\'], + StringSplitOptions.RemoveEmptyEntries + ); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index f0344e2b9c..a43786eaf0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -3,7 +3,7 @@ using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestType.cs b/tests/ImageSharp.Tests/TestUtilities/TestType.cs index 5b4f6a6024..d0ada64430 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestType.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestType.cs @@ -1,7 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using Xunit.Abstractions; + +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs index 350333965a..c4ad50437f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs @@ -2,7 +2,7 @@ // Licensed under the Six Labors Split License. using System.Numerics; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index 1b5b43f033..2f0e73f20c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs @@ -2,7 +2,7 @@ // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Tests.TestUtilities; -using Xunit.Abstractions; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests; @@ -18,16 +18,16 @@ internal class BaseObj : IXunitSerializable public virtual void Deserialize(IXunitSerializationInfo info) { - info.AddValue(nameof(this.Length), this.Length); - info.AddValue(nameof(this.Name), this.Name); - info.AddValue(nameof(this.Lives), this.Lives); + this.Length = info.GetValue(nameof(this.Length)); + this.Name = info.GetValue(nameof(this.Name)); + this.Lives = info.GetValue(nameof(this.Lives)); } public virtual void Serialize(IXunitSerializationInfo info) { - this.Length = info.GetValue(nameof(this.Length)); - this.Name = info.GetValue(nameof(this.Name)); - this.Lives = info.GetValue(nameof(this.Lives)); + info.AddValue(nameof(this.Length), this.Length); + info.AddValue(nameof(this.Name), this.Name); + info.AddValue(nameof(this.Lives), this.Lives); } } @@ -37,8 +37,8 @@ internal class DerivedObj : BaseObj public override void Deserialize(IXunitSerializationInfo info) { - this.Strength = info.GetValue(nameof(this.Strength)); base.Deserialize(info); + this.Strength = info.GetValue(nameof(this.Strength)); } public override void Serialize(IXunitSerializationInfo info) @@ -51,7 +51,13 @@ public override void Serialize(IXunitSerializationInfo info) [Fact] public void SerializeDeserialize_ShouldPreserveValues() { - DerivedObj obj = new() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; + DerivedObj obj = new() + { + Length = 123.1, + Name = "Lol123!", + Lives = 7, + Strength = 4.8, + }; string str = BasicSerializer.Serialize(obj); BaseObj mirrorBase = BasicSerializer.Deserialize(str); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index ee3d02670e..a38c3d06fc 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -4,8 +4,8 @@ using System.Numerics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; -using Xunit.Abstractions; using Aes = System.Runtime.Intrinsics.X86.Aes; +using Xunit.Sdk; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 349dd258eb..8d57ab58ef 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -5,7 +5,6 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs index b818e80b05..36b93b87bd 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs @@ -5,7 +5,6 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index a145e7365e..801d2e4812 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -4,7 +4,6 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 555041890a..9b20244c48 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -8,7 +8,6 @@ using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs index 36c078dc0e..4dea89993a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs @@ -2,22 +2,19 @@ // Licensed under the Six Labors Split License. using Microsoft.DotNet.RemoteExecutor; - using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests; public class TestEnvironmentTests { - public TestEnvironmentTests(ITestOutputHelper output) - => this.Output = output; + public TestEnvironmentTests(ITestOutputHelper output) => this.Output = output; private ITestOutputHelper Output { get; } @@ -28,21 +25,24 @@ private void CheckPath(string path) } [Fact] - public void SolutionDirectoryFullPath() - => this.CheckPath(TestEnvironment.SolutionDirectoryFullPath); + public void SolutionDirectoryFullPath() => + this.CheckPath(TestEnvironment.SolutionDirectoryFullPath); [Fact] - public void InputImagesDirectoryFullPath() - => this.CheckPath(TestEnvironment.InputImagesDirectoryFullPath); + public void InputImagesDirectoryFullPath() => + this.CheckPath(TestEnvironment.InputImagesDirectoryFullPath); [Fact] - public void ExpectedOutputDirectoryFullPath() - => this.CheckPath(TestEnvironment.ReferenceOutputDirectoryFullPath); + public void ExpectedOutputDirectoryFullPath() => + this.CheckPath(TestEnvironment.ReferenceOutputDirectoryFullPath); [Fact] public void GetReferenceOutputFileName() { - string actual = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, @"foo\bar\lol.jpeg"); + string actual = Path.Combine( + TestEnvironment.ActualOutputDirectoryFullPath, + @"foo\bar\lol.jpeg" + ); string expected = TestEnvironment.GetReferenceOutputFileName(actual); this.Output.WriteLine(expected); @@ -55,7 +55,10 @@ public void GetReferenceOutputFileName() [InlineData("lol/Baz.JPG", typeof(JpegEncoder))] [InlineData("lol/Baz.gif", typeof(GifEncoder))] [InlineData("lol/foobar.webp", typeof(WebpEncoder))] - public void GetReferenceEncoder_ReturnsCorrectEncoders_Windows(string fileName, Type expectedEncoderType) + public void GetReferenceEncoder_ReturnsCorrectEncoders_Windows( + string fileName, + Type expectedEncoderType + ) { if (!TestEnvironment.IsWindows) { @@ -72,7 +75,10 @@ public void GetReferenceEncoder_ReturnsCorrectEncoders_Windows(string fileName, [InlineData("lol/Baz.JPG", typeof(JpegDecoder))] [InlineData("lol/Baz.gif", typeof(GifDecoder))] [InlineData("lol/foobar.webp", typeof(WebpDecoder))] - public void GetReferenceDecoder_ReturnsCorrectDecoders_Windows(string fileName, Type expectedDecoderType) + public void GetReferenceDecoder_ReturnsCorrectDecoders_Windows( + string fileName, + Type expectedDecoderType + ) { if (!TestEnvironment.IsWindows) { @@ -89,7 +95,10 @@ public void GetReferenceDecoder_ReturnsCorrectDecoders_Windows(string fileName, [InlineData("lol/Baz.JPG", typeof(JpegEncoder))] [InlineData("lol/Baz.gif", typeof(GifEncoder))] [InlineData("lol/foobar.webp", typeof(WebpEncoder))] - public void GetReferenceEncoder_ReturnsCorrectEncoders_Linux(string fileName, Type expectedEncoderType) + public void GetReferenceEncoder_ReturnsCorrectEncoders_Linux( + string fileName, + Type expectedEncoderType + ) { if (!TestEnvironment.IsLinux) { @@ -106,7 +115,10 @@ public void GetReferenceEncoder_ReturnsCorrectEncoders_Linux(string fileName, Ty [InlineData("lol/Baz.JPG", typeof(JpegDecoder))] [InlineData("lol/Baz.gif", typeof(GifDecoder))] [InlineData("lol/foobar.webp", typeof(WebpDecoder))] - public void GetReferenceDecoder_ReturnsCorrectDecoders_Linux(string fileName, Type expectedDecoderType) + public void GetReferenceDecoder_ReturnsCorrectDecoders_Linux( + string fileName, + Type expectedDecoderType + ) { if (!TestEnvironment.IsLinux) { @@ -119,9 +131,13 @@ public void GetReferenceDecoder_ReturnsCorrectDecoders_Linux(string fileName, Ty // RemoteExecutor does not work with "dotnet xunit" used to run tests on 32 bit .NET Framework: // https://github.com/SixLabors/ImageSharp/blob/381dff8640b721a34b1227c970fcf6ad6c5e3e72/ci-test.ps1#L30 - public static bool IsNot32BitNetFramework = !TestEnvironment.IsFramework || TestEnvironment.Is64BitProcess; + public static bool IsNot32BitNetFramework => + !TestEnvironment.IsFramework || TestEnvironment.Is64BitProcess; - [ConditionalFact(nameof(IsNot32BitNetFramework))] + [Fact( + Skip = "Not supported on 32-bit .NET Framework", + SkipUnless = nameof(IsNot32BitNetFramework) + )] public void RemoteExecutor_FailingRemoteTestShouldFailLocalTest() { static void FailingCode() @@ -129,6 +145,8 @@ static void FailingCode() Assert.False(true); } - Assert.ThrowsAny(() => RemoteExecutor.Invoke(FailingCode).Dispose()); + Assert.ThrowsAny(() => + RemoteExecutor.Invoke(FailingCode).Dispose() + ); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 72ed27e8e8..f886a814ef 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -8,7 +8,6 @@ using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; -using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests; @@ -17,14 +16,14 @@ public class TestImageProviderTests { public static readonly TheoryData BasicData = new() { - TestImageProvider.Blank(10, 20), - TestImageProvider.Blank(10, 20), + (object)TestImageProvider.Blank(10, 20), + (object)TestImageProvider.Blank(10, 20), }; public static readonly TheoryData FileData = new() { - TestImageProvider.File(TestImages.Bmp.Car), - TestImageProvider.File(TestImages.Bmp.F) + (object)TestImageProvider.File(TestImages.Bmp.Car), + (object)TestImageProvider.File(TestImages.Bmp.F) }; public static string[] AllBmpFiles = [TestImages.Bmp.F, TestImages.Bmp.Bit8]; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 46fb7159e8..a1047b02cf 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -5,7 +5,6 @@ using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests; diff --git a/tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs b/tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs index eca6529009..07e05a7598 100644 --- a/tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs +++ b/tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs @@ -2,7 +2,7 @@ // Licensed under the Six Labors Split License. using System.Reflection; -using Xunit.Sdk; +using Xunit.v3; namespace SixLabors.ImageSharp.Tests; @@ -19,10 +19,10 @@ public ValidateDisposedMemoryAllocationsAttribute() public ValidateDisposedMemoryAllocationsAttribute(int expected) => this.expected = expected; - public override void Before(MethodInfo methodUnderTest) + public override void Before(MethodInfo methodUnderTest, IXunitTest test) => MemoryAllocatorValidator.MonitorAllocations(); - public override void After(MethodInfo methodUnderTest) + public override void After(MethodInfo methodUnderTest, IXunitTest test) { MemoryAllocatorValidator.ValidateAllocations(this.expected); MemoryAllocatorValidator.StopMonitoringAllocations();