diff --git a/.editorconfig b/.editorconfig index af1e5b44c..74a363eef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -161,6 +161,9 @@ csharp_style_deconstructed_variable_declaration = true:warning csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_implicit_object_creation_when_type_is_apparent = true:error +# ReSharper inspection severities +resharper_arrange_object_creation_when_type_evident_highlighting = error +resharper_arrange_object_creation_when_type_not_evident_highlighting = error # "Null" checking preferences csharp_style_throw_expression = true:warning csharp_style_conditional_delegate_call = true:warning diff --git a/shared-infrastructure b/shared-infrastructure index 5e13cde85..132a8232b 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 5e13cde851a3d6e95d0dfdde2a57071f1efda9c3 +Subproject commit 132a8232bd61471e9e9df727fb7a112800030327 diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs index a959faa3b..cbcd12aec 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs @@ -139,7 +139,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - var rows = new RowInterval(yMin, yMax); + RowInterval rows = new(yMin, yMax); // Skip the safety copy when invoking a potentially impure method on a readonly field Unsafe.AsRef(in this.operation).Invoke(in rows); @@ -185,7 +185,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - var rows = new RowInterval(yMin, yMax); + RowInterval rows = new(yMin, yMax); using IMemoryOwner buffer = this.allocator.Allocate(this.bufferLength); diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.cs b/src/ImageSharp/Advanced/ParallelRowIterator.cs index 1284a3a89..b878f9ec0 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.cs @@ -26,7 +26,7 @@ public static partial class ParallelRowIterator public static void IterateRows(Configuration configuration, Rectangle rectangle, in T operation) where T : struct, IRowOperation { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRows(rectangle, in parallelSettings, in operation); } @@ -65,8 +65,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation); Parallel.For( 0, @@ -88,7 +88,7 @@ public static partial class ParallelRowIterator where T : struct, IRowOperation where TBuffer : unmanaged { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRows(rectangle, in parallelSettings, in operation); } @@ -135,8 +135,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation); Parallel.For( 0, @@ -156,7 +156,7 @@ public static partial class ParallelRowIterator public static void IterateRowIntervals(Configuration configuration, Rectangle rectangle, in T operation) where T : struct, IRowIntervalOperation { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRowIntervals(rectangle, in parallelSettings, in operation); } @@ -186,14 +186,14 @@ public static partial class ParallelRowIterator // Avoid TPL overhead in this trivial case: if (numOfSteps == 1) { - var rows = new RowInterval(top, bottom); + RowInterval rows = new(top, bottom); Unsafe.AsRef(in operation).Invoke(in rows); return; } int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation); Parallel.For( 0, @@ -215,7 +215,7 @@ public static partial class ParallelRowIterator where T : struct, IRowIntervalOperation where TBuffer : unmanaged { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRowIntervals(rectangle, in parallelSettings, in operation); } @@ -250,7 +250,7 @@ public static partial class ParallelRowIterator // Avoid TPL overhead in this trivial case: if (numOfSteps == 1) { - var rows = new RowInterval(top, bottom); + RowInterval rows = new(top, bottom); using IMemoryOwner buffer = allocator.Allocate(bufferLength); Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span); @@ -259,8 +259,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation); Parallel.For( 0, diff --git a/src/ImageSharp/Color/Color.WebSafePalette.cs b/src/ImageSharp/Color/Color.WebSafePalette.cs index feb4a8659..b805d63f9 100644 --- a/src/ImageSharp/Color/Color.WebSafePalette.cs +++ b/src/ImageSharp/Color/Color.WebSafePalette.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp; /// public partial struct Color { - private static readonly Lazy WebSafePaletteLazy = new Lazy(CreateWebSafePalette, true); + private static readonly Lazy WebSafePaletteLazy = new(CreateWebSafePalette, true); /// /// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4. diff --git a/src/ImageSharp/Color/Color.WernerPalette.cs b/src/ImageSharp/Color/Color.WernerPalette.cs index 1058da654..6f0e3744f 100644 --- a/src/ImageSharp/Color/Color.WernerPalette.cs +++ b/src/ImageSharp/Color/Color.WernerPalette.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp; /// public partial struct Color { - private static readonly Lazy WernerPaletteLazy = new Lazy(CreateWernerPalette, true); + private static readonly Lazy WernerPaletteLazy = new(CreateWernerPalette, true); /// /// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821. diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 8f54680ec..1dfbf0a24 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -81,10 +81,10 @@ public readonly partial struct Color : IEquatable PixelTypeInfo info = TPixel.GetPixelTypeInfo(); if (info.ComponentInfo.HasValue && info.ComponentInfo.Value.GetMaximumComponentPrecision() <= (int)PixelComponentBitDepth.Bit32) { - return new(source.ToScaledVector4()); + return new Color(source.ToScaledVector4()); } - return new(source); + return new Color(source); } /// @@ -120,7 +120,7 @@ public readonly partial struct Color : IEquatable { for (int i = 0; i < destination.Length; i++) { - destination[i] = new(source[i]); + destination[i] = new Color(source[i]); } } } diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs index ca72dd745..ebe163102 100644 --- a/src/ImageSharp/ColorProfiles/CieLab.cs +++ b/src/ImageSharp/ColorProfiles/CieLab.cs @@ -182,7 +182,7 @@ public readonly struct CieLab : IProfileConnectingSpace Vector3 wxyz = new(whitePoint.X, whitePoint.Y, whitePoint.Z); Vector3 xyzr = new(xr, yr, zr); - return new(xyzr * wxyz); + return new CieXyz(xyzr * wxyz); } /// diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs index d0afec4ab..7072537a4 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs @@ -12,7 +12,7 @@ public class ColorProfileConverter /// Initializes a new instance of the class. /// public ColorProfileConverter() - : this(new()) + : this(new ColorConversionOptions()) { } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs index 3604642c9..01c66881a 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs @@ -58,7 +58,7 @@ internal class ColorTrcCalculator : IVector4Calculator // when data to PCS, upstream process provides scaled XYZ // but input to calculator is descaled XYZ // (see DemoMaxICC IccCmm.cpp : CIccXformMatrixTRC::Apply) - xyz = new(CieXyz.FromScaledVector4(xyz).AsVector3Unsafe(), 1); + xyz = new Vector4(CieXyz.FromScaledVector4(xyz).AsVector3Unsafe(), 1); return this.curveCalculator.Calculate(xyz); } } diff --git a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs index ec25d0e1c..25604001f 100644 --- a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs @@ -31,7 +31,7 @@ public static class VonKriesChromaticAdaptation if (from.Equals(to)) { - return new(source.X, source.Y, source.Z); + return new CieXyz(source.X, source.Y, source.Z); } Vector3 sourceColorLms = Vector3.Transform(source.AsVector3Unsafe(), matrix); diff --git a/src/ImageSharp/ColorProfiles/Y.cs b/src/ImageSharp/ColorProfiles/Y.cs index 83321a085..2be34fc31 100644 --- a/src/ImageSharp/ColorProfiles/Y.cs +++ b/src/ImageSharp/ColorProfiles/Y.cs @@ -92,7 +92,7 @@ public readonly struct Y : IColorProfile { Matrix4x4 m = options.YCbCrTransform.Forward; float offset = options.YCbCrTransform.Offset.X; - return new(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset); + return new Y(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset); } /// diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 5f91dcd99..ff28063f0 100644 --- a/src/ImageSharp/Common/Helpers/Numerics.cs +++ b/src/ImageSharp/Common/Helpers/Numerics.cs @@ -470,8 +470,8 @@ internal static class Numerics where T : unmanaged { ref T sRef = ref MemoryMarshal.GetReference(span); - var vmin = new Vector(min); - var vmax = new Vector(max); + Vector vmin = new(min); + Vector vmax = new(max); nint n = (nint)(uint)span.Length / Vector.Count; nint m = Modulo4(n); @@ -656,7 +656,7 @@ internal static class Numerics return Sse.Shuffle(value.AsVector128(), value.AsVector128(), ShuffleAlphaControl).AsVector4(); } - return new(value.W); + return new Vector4(value.W); } /// @@ -726,12 +726,12 @@ internal static class Numerics ref Vector128 vectors128Ref = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); ref Vector128 vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length); - var v128_341 = Vector128.Create(341); + Vector128 v128_341 = Vector128.Create(341); Vector128 v128_negativeZero = Vector128.Create(-0.0f).AsInt32(); Vector128 v128_one = Vector128.Create(1.0f).AsInt32(); - var v128_13rd = Vector128.Create(1 / 3f); - var v128_23rds = Vector128.Create(2 / 3f); + Vector128 v128_13rd = Vector128.Create(1 / 3f); + Vector128 v128_23rds = Vector128.Create(2 / 3f); while (Unsafe.IsAddressLessThan(ref vectors128Ref, ref vectors128End)) { diff --git a/src/ImageSharp/Common/Helpers/TolerantMath.cs b/src/ImageSharp/Common/Helpers/TolerantMath.cs index b4ed9ee2f..2c622d167 100644 --- a/src/ImageSharp/Common/Helpers/TolerantMath.cs +++ b/src/ImageSharp/Common/Helpers/TolerantMath.cs @@ -20,7 +20,7 @@ internal readonly struct TolerantMath /// It is a field so it can be passed as an 'in' parameter. /// Does not necessarily fit all use cases! /// - public static readonly TolerantMath Default = new TolerantMath(1e-8); + public static readonly TolerantMath Default = new(1e-8); public TolerantMath(double epsilon) { diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index 1d9f3bb85..c2b02dedd 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -122,7 +122,7 @@ public sealed class Configuration /// /// Gets or the that is currently in use. /// - public ImageFormatManager ImageFormatsManager { get; private set; } = new ImageFormatManager(); + public ImageFormatManager ImageFormatsManager { get; private set; } = new(); /// /// Gets or sets the that is currently in use. diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index da6556b36..d98f7bccb 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -25,7 +25,7 @@ public sealed class BmpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new BmpDecoderCore(new() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new BmpDecoderCore(new BmpDecoderOptions { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index b9b32dede..17c1f545b 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -220,7 +220,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadImageHeaders(stream, out _, out _); - return new ImageInfo(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata); + return new ImageInfo(new Size(this.infoHeader.Width, this.infoHeader.Height), this.metadata); } /// @@ -1270,7 +1270,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore byte g = (byte)((temp & greenMask) >> rightShiftGreenMask); byte b = (byte)((temp & blueMask) >> rightShiftBlueMask); byte a = alphaMask != 0 ? (byte)((temp & alphaMask) >> rightShiftAlphaMask) : byte.MaxValue; - pixelRow[x] = TPixel.FromRgba32(new(r, g, b, a)); + pixelRow[x] = TPixel.FromRgba32(new Rgba32(r, g, b, a)); } offset += 4; @@ -1457,7 +1457,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore this.bmpMetadata.InfoHeaderType = infoHeaderType; this.bmpMetadata.BitsPerPixel = (BmpBitsPerPixel)bitsPerPixel; - this.Dimensions = new(this.infoHeader.Width, this.infoHeader.Height); + this.Dimensions = new Size(this.infoHeader.Width, this.infoHeader.Height); } /// diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 46da46345..ccc620d6c 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -655,7 +655,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 16, Dither = this.quantizer.Options.Dither, @@ -712,7 +712,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 4, Dither = this.quantizer.Options.Dither, @@ -778,7 +778,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 2, Dither = this.quantizer.Options.Dither, diff --git a/src/ImageSharp/Formats/Bmp/BmpFormat.cs b/src/ImageSharp/Formats/Bmp/BmpFormat.cs index a67b06cb8..5dec4a674 100644 --- a/src/ImageSharp/Formats/Bmp/BmpFormat.cs +++ b/src/ImageSharp/Formats/Bmp/BmpFormat.cs @@ -15,7 +15,7 @@ public sealed class BmpFormat : IImageFormat /// /// Gets the shared instance. /// - public static BmpFormat Instance { get; } = new BmpFormat(); + public static BmpFormat Instance { get; } = new(); /// public string Name => "BMP"; diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs index 086025754..dbe8183b6 100644 --- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs @@ -148,7 +148,7 @@ public class CurFrameMetadata : IFormatFrameMetadata ? (byte)0 : (byte)ColorNumerics.GetColorCountForBitDepth((int)this.BmpBitsPerPixel); - return new() + return new IconDirEntry { Width = ClampEncodingDimension(this.EncodingWidth ?? size.Width), Height = ClampEncodingDimension(this.EncodingHeight ?? size.Height), diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index 8a365682a..2511cffdb 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats; /// public sealed class DecoderOptions { - private static readonly Lazy LazyOptions = new(() => new()); + private static readonly Lazy LazyOptions = new(() => new DecoderOptions()); private uint maxFrames = int.MaxValue; diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index f6e3643d5..ca28bc771 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -267,7 +267,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore } return new ImageInfo( - new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), + new Size(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), this.metadata, framesMetadata); } @@ -305,7 +305,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowInvalidImageContentException("Width or height should not be 0"); } - this.Dimensions = new(this.imageDescriptor.Width, this.imageDescriptor.Height); + this.Dimensions = new Size(this.imageDescriptor.Width, this.imageDescriptor.Height); } /// @@ -414,6 +414,11 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowInvalidImageContentException($"Gif comment length '{length}' exceeds max '{GifConstants.MaxCommentSubBlockLength}' of a comment data block"); } + if (length == -1) + { + GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading gif comment"); + } + if (this.skipMetadata) { stream.Seek(length, SeekOrigin.Current); @@ -592,7 +597,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (disposalMethod == FrameDisposalMode.RestoreToBackground) { - this.restoreArea = Rectangle.Intersect(image.Bounds, new(descriptor.Left, descriptor.Top, descriptor.Width, descriptor.Height)); + this.restoreArea = Rectangle.Intersect(image.Bounds, new Rectangle(descriptor.Left, descriptor.Top, descriptor.Width, descriptor.Height)); } if (colorTable.Length == 0) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 43af476f2..ffe318063 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -113,7 +113,7 @@ internal sealed class GifEncoderCore TransparentColorMode mode = this.transparentColorMode; // Create a new quantizer options instance augmenting the transparent color mode to match the encoder. - QuantizerOptions options = (this.encoder.Quantizer?.Options ?? new()).DeepClone(o => o.TransparentColorMode = mode); + QuantizerOptions options = (this.encoder.Quantizer?.Options ?? new QuantizerOptions()).DeepClone(o => o.TransparentColorMode = mode); if (globalQuantizer is null) { diff --git a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs index 1a0deb8ba..f58ee786f 100644 --- a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs @@ -94,7 +94,7 @@ public class GifFrameMetadata : IFormatFrameMetadata // If the color table is global and frame has no transparency. Consider it 'Source' also. blendSource |= this.ColorTableMode == FrameColorTableMode.Global && !this.HasTransparency; - return new() + return new FormatConnectingFrameMetadata { ColorTableMode = this.ColorTableMode, Duration = TimeSpan.FromMilliseconds(this.FrameDelay * 10), diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs index e8656775d..fb42d6043 100644 --- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs @@ -139,7 +139,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata ? (byte)0 : (byte)ColorNumerics.GetColorCountForBitDepth((int)this.BmpBitsPerPixel); - return new() + return new IconDirEntry { Width = ClampEncodingDimension(this.EncodingWidth ?? size.Width), Height = ClampEncodingDimension(this.EncodingHeight ?? size.Height), diff --git a/src/ImageSharp/Formats/Icon/IconDecoderCore.cs b/src/ImageSharp/Formats/Icon/IconDecoderCore.cs index caed2dd90..bc3258e6b 100644 --- a/src/ImageSharp/Formats/Icon/IconDecoderCore.cs +++ b/src/ImageSharp/Formats/Icon/IconDecoderCore.cs @@ -63,7 +63,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore // Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data // which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft. - this.Dimensions = new(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height)); + this.Dimensions = new Size(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height)); } ImageMetadata metadata = new(); @@ -208,7 +208,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore // Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data // which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft. - this.Dimensions = new(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height)); + this.Dimensions = new Size(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height)); } // Copy the format specific metadata to the image. @@ -222,7 +222,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore metadata.SetFormatMetadata(PngFormat.Instance, pngMetadata); } - return new(this.Dimensions, metadata, frames); + return new ImageInfo(this.Dimensions, metadata, frames); } protected abstract void SetFrameMetadata( @@ -276,20 +276,20 @@ internal abstract class IconDecoderCore : ImageDecoderCore height = Math.Max(height, entry.Height); } - this.Dimensions = new(width, height); + this.Dimensions = new Size(width, height); } private ImageDecoderCore GetDecoder(bool isPng) { if (isPng) { - return new PngDecoderCore(new() + return new PngDecoderCore(new PngDecoderOptions { GeneralOptions = this.Options, }); } - return new BmpDecoderCore(new() + return new BmpDecoderCore(new BmpDecoderOptions { GeneralOptions = this.Options, ProcessedAlphaMask = true, diff --git a/src/ImageSharp/Formats/Icon/IconEncoderCore.cs b/src/ImageSharp/Formats/Icon/IconEncoderCore.cs index 76b14832a..479cf9f1b 100644 --- a/src/ImageSharp/Formats/Icon/IconEncoderCore.cs +++ b/src/ImageSharp/Formats/Icon/IconEncoderCore.cs @@ -116,7 +116,7 @@ internal abstract class IconEncoderCore [MemberNotNull(nameof(entries))] private void InitHeader(Image image) { - this.fileHeader = new(this.iconFileType, (ushort)image.Frames.Count); + this.fileHeader = new IconDir(this.iconFileType, (ushort)image.Frames.Count); this.entries = this.iconFileType switch { IconFileType.ICO => @@ -155,14 +155,14 @@ internal abstract class IconEncoderCore count = 256; } - return new WuQuantizer(new() + return new WuQuantizer(new QuantizerOptions { MaxColors = count }); } // Don't dither if we have a palette. We want to preserve as much information as possible. - return new PaletteQuantizer(metadata.ColorTable.Value, new() { Dither = null }); + return new PaletteQuantizer(metadata.ColorTable.Value, new QuantizerOptions { Dither = null }); } internal sealed class EncodingFrameMetadata diff --git a/src/ImageSharp/Formats/ImageFormatManager.cs b/src/ImageSharp/Formats/ImageFormatManager.cs index b6b5f8779..ecf96855e 100644 --- a/src/ImageSharp/Formats/ImageFormatManager.cs +++ b/src/ImageSharp/Formats/ImageFormatManager.cs @@ -161,7 +161,7 @@ public class ImageFormatManager /// /// Removes all the registered image format detectors. /// - public void ClearImageFormatDetectors() => this.imageFormatDetectors = new(); + public void ClearImageFormatDetectors() => this.imageFormatDetectors = new ConcurrentBag(); /// /// Adds a new detector for detecting mime types. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 731ad0f76..d2c383132 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -140,7 +140,7 @@ internal partial struct Block8x8 /// public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new(); sb.Append('['); for (int i = 0; i < Size; i++) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index efc1dbd72..179f9aa28 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -57,19 +57,19 @@ internal partial struct Block8x8F ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); - var xyLeft = new Vector4(sLeft.X); + Vector4 xyLeft = new(sLeft.X); xyLeft.Z = sLeft.Y; xyLeft.W = sLeft.Y; - var zwLeft = new Vector4(sLeft.Z); + Vector4 zwLeft = new(sLeft.Z); zwLeft.Z = sLeft.W; zwLeft.W = sLeft.W; - var xyRight = new Vector4(sRight.X); + Vector4 xyRight = new(sRight.X); xyRight.Z = sRight.Y; xyRight.W = sRight.Y; - var zwRight = new Vector4(sRight.Z); + Vector4 zwRight = new(sRight.Z); zwRight.Z = sRight.W; zwRight.W = sRight.W; diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs index 495a20831..01bfc0875 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs @@ -128,7 +128,7 @@ internal abstract partial class JpegColorConverterBase ColorProfileConverter converter = new(); Span source = MemoryMarshal.Cast(packed); - // YccK is not a defined ICC color space — it's a JPEG-specific encoding used in Adobe-style CMYK JPEGs. + // YccK is not a defined ICC color space � it's a JPEG-specific encoding used in Adobe-style CMYK JPEGs. // ICC profiles expect colorimetric CMYK values, so we must first convert YccK to CMYK using a hardcoded inverse transform. // This transform assumes Rec.601 YCbCr coefficients and an inverted K channel. // @@ -144,7 +144,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(source, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs index 4fa18b88a..2b1c1dca3 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs @@ -91,7 +91,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(destination, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs index 8cd715eb3..3368e52bf 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs @@ -116,7 +116,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(source, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index c33a8a196..1b0a17704 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -241,7 +241,7 @@ internal class ComponentProcessor : IDisposable ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); nuint count = target.VectorCount(); - var multiplierVector = new Vector(multiplier); + Vector multiplierVector = new(multiplier); for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 90e16f6df..4815fce0c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -409,7 +409,7 @@ internal class HuffmanScanEncoder { this.FlushRemainingBytes(); this.WriteRestart(restarts % 8); - foreach (var component in frame.Components) + foreach (Component component in frame.Components) { component.DcPredictor = 0; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs index baaa7213a..b60ef68f1 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs @@ -46,7 +46,7 @@ internal class SpectralConverter : SpectralConverter, IDisposable // component processors from spectral to Rgb24 const int blockPixelWidth = 8; this.alignedPixelWidth = majorBlockWidth * blockPixelWidth; - var postProcessorBufferSize = new Size(this.alignedPixelWidth, this.pixelRowsPerStep); + Size postProcessorBufferSize = new(this.alignedPixelWidth, this.pixelRowsPerStep); this.componentProcessors = new ComponentProcessor[frame.Components.Length]; for (int i = 0; i < this.componentProcessors.Length; i++) { @@ -119,7 +119,7 @@ internal class SpectralConverter : SpectralConverter, IDisposable bLane.Slice(paddingStartIndex).Fill(bLane[paddingStartIndex - 1]); // Convert from rgb24 to target pixel type - var values = new JpegColorConverterBase.ComponentValues(this.componentProcessors, y); + JpegColorConverterBase.ComponentValues values = new(this.componentProcessors, y); this.colorConverter.ConvertFromRgb(values, rLane, gLane, bLane); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs index c7212fc2d..b5d01fa5c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs @@ -14,20 +14,20 @@ internal static class SizeExtensions /// Multiplies 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size MultiplyBy(this Size a, Size b) => new Size(a.Width * b.Width, a.Height * b.Height); + public static Size MultiplyBy(this Size a, Size b) => new(a.Width * b.Width, a.Height * b.Height); /// /// Divides 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size DivideBy(this Size a, Size b) => new Size(a.Width / b.Width, a.Height / b.Height); + public static Size DivideBy(this Size a, Size b) => new(a.Width / b.Width, a.Height / b.Height); /// /// Divide Width and Height as real numbers and return the Ceiling. /// public static Size DivideRoundUp(this Size originalSize, int divX, int divY) { - var sizeVect = (Vector2)(SizeF)originalSize; + Vector2 sizeVect = (Vector2)(SizeF)originalSize; sizeVect /= new Vector2(divX, divY); sizeVect.X = MathF.Ceiling(sizeVect.X); sizeVect.Y = MathF.Ceiling(sizeVect.Y); diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index 026c542dd..c013cdc9c 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs @@ -25,7 +25,7 @@ public sealed class JpegDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using JpegDecoderCore decoder = new(new() { GeneralOptions = options }); + using JpegDecoderCore decoder = new(new JpegDecoderOptions { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 0b2d3d67e..0ad78b903 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -222,7 +222,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.InitDerivedMetadataProperties(); Size pixelSize = this.Frame.PixelSize; - return new ImageInfo(new(pixelSize.Width, pixelSize.Height), this.Metadata); + return new ImageInfo(new Size(pixelSize.Width, pixelSize.Height), this.Metadata); } /// @@ -1243,7 +1243,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData } this.Frame = new JpegFrame(frameMarker, precision, frameWidth, frameHeight, componentCount); - this.Dimensions = new(frameWidth, frameHeight); + this.Dimensions = new Size(frameWidth, frameHeight); this.Metadata.GetJpegMetadata().Progressive = this.Frame.Progressive; remaining -= length; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs index 71f852a09..98b6dd30a 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs @@ -13,15 +13,15 @@ internal sealed unsafe partial class JpegEncoderCore { private static JpegFrameConfig[] CreateFrameConfigs() { - var defaultLuminanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); - var defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); - var defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); - var defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); + JpegHuffmanTableConfig defaultLuminanceHuffmanDC = new(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); + JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); + JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); + JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); - var defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); - var defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); + JpegQuantizationTableConfig defaultLuminanceQuantTable = new(0, Quantization.LuminanceTable); + JpegQuantizationTableConfig defaultChrominanceQuantTable = new(1, Quantization.ChrominanceTable); - var yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] + JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] { defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC, @@ -29,7 +29,7 @@ internal sealed unsafe partial class JpegEncoderCore defaultChrominanceHuffmanAC, }; - var yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[] + JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[] { defaultLuminanceQuantTable, defaultChrominanceQuantTable, @@ -38,77 +38,77 @@ internal sealed unsafe partial class JpegEncoderCore return new JpegFrameConfig[] { // YCbCr 4:4:4 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio444, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:2 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio422, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio420, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:1 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio411, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio410, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // Luminance - new JpegFrameConfig( + new( JpegColorSpace.Grayscale, JpegColorType.Luminance, new JpegComponentConfig[] { - new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -121,14 +121,14 @@ internal sealed unsafe partial class JpegEncoderCore }), // Rgb - new JpegFrameConfig( + new( JpegColorSpace.RGB, JpegColorType.Rgb, new JpegComponentConfig[] { - new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -144,15 +144,15 @@ internal sealed unsafe partial class JpegEncoderCore }, // Cmyk - new JpegFrameConfig( + new( JpegColorSpace.Cmyk, JpegColorType.Cmyk, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -168,15 +168,15 @@ internal sealed unsafe partial class JpegEncoderCore }, // YccK - new JpegFrameConfig( + new( JpegColorSpace.Ycck, JpegColorType.Ycck, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { diff --git a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs index a07be33fc..9d5a29981 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs @@ -15,7 +15,7 @@ public sealed class JpegFormat : IImageFormat /// /// Gets the shared instance. /// - public static JpegFormat Instance { get; } = new JpegFormat(); + public static JpegFormat Instance { get; } = new(); /// public string Name => "JPEG"; diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index 9d3dd3ea4..989eadda7 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -80,7 +80,7 @@ internal sealed class PbmDecoderCore : ImageDecoderCore { this.ProcessHeader(stream); return new ImageInfo( - new(this.pixelSize.Width, this.pixelSize.Height), + new Size(this.pixelSize.Width, this.pixelSize.Height), this.metadata); } diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index cfea0e602..df3995294 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -25,7 +25,7 @@ public sealed class PngDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new PngDecoderCore(new PngDecoderOptions() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new PngDecoderCore(new PngDecoderOptions { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 0971c3ecf..38f964d37 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -248,7 +248,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore break; case PngChunkType.Data: pngMetadata.AnimateRootFrame = currentFrameControl != null; - currentFrameControl ??= new((uint)this.header.Width, (uint)this.header.Height); + currentFrameControl ??= new FrameControl((uint)this.header.Width, (uint)this.header.Height); if (image is null) { this.InitializeImage(metadata, currentFrameControl.Value, out image); @@ -433,7 +433,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore } pngMetadata.AnimateRootFrame = currentFrameControl != null; - currentFrameControl ??= new((uint)this.header.Width, (uint)this.header.Height); + currentFrameControl ??= new FrameControl((uint)this.header.Width, (uint)this.header.Height); if (framesMetadata.Count == 0) { InitializeFrameMetadata(framesMetadata, currentFrameControl.Value); @@ -525,7 +525,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowInvalidHeader(); } - return new ImageInfo(new(this.header.Width, this.header.Height), metadata, framesMetadata); + return new ImageInfo(new Size(this.header.Width, this.header.Height), metadata, framesMetadata); } finally { @@ -1343,7 +1343,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore pngMetadata.InterlaceMethod = this.header.InterlaceMethod; this.pngColorType = this.header.ColorType; - this.Dimensions = new(this.header.Width, this.header.Height); + this.Dimensions = new Size(this.header.Width, this.header.Height); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs index a73db8777..e4aeded15 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Png; public sealed class PngDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the maximum memory in bytes that a zTXt, sPLT, iTXt, iCCP, or unknown chunk can occupy when decompressed. diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index e9b76522c..2b01affea 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -265,7 +265,7 @@ internal sealed class PngEncoderCore : IDisposable { // Use the previously derived global palette and a shared quantizer to // quantize the subsequent frames. This allows us to cache the color matching resolution. - paletteQuantizer ??= new( + paletteQuantizer ??= new PaletteQuantizer( this.configuration, this.quantizer!.Options, previousPalette); diff --git a/src/ImageSharp/Formats/Png/PngFormat.cs b/src/ImageSharp/Formats/Png/PngFormat.cs index e5852affa..e49b89631 100644 --- a/src/ImageSharp/Formats/Png/PngFormat.cs +++ b/src/ImageSharp/Formats/Png/PngFormat.cs @@ -15,7 +15,7 @@ public sealed class PngFormat : IImageFormat /// /// Gets the shared instance. /// - public static PngFormat Instance { get; } = new PngFormat(); + public static PngFormat Instance { get; } = new(); /// public string Name => "PNG"; diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index e337a8796..701b9af05 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -63,7 +63,7 @@ public class PngFrameMetadata : IFormatFrameMetadata public static PngFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectingFrameMetadata metadata) => new() { - FrameDelay = new(metadata.Duration.TotalMilliseconds / 1000), + FrameDelay = new Rational(metadata.Duration.TotalMilliseconds / 1000), DisposalMode = GetMode(metadata.DisposalMode), BlendMode = metadata.BlendMode, }; @@ -77,7 +77,7 @@ public class PngFrameMetadata : IFormatFrameMetadata delay = 0; } - return new() + return new FormatConnectingFrameMetadata { ColorTableMode = FrameColorTableMode.Global, Duration = TimeSpan.FromMilliseconds(delay * 1000), diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 011672db8..a7b730ec9 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -130,7 +130,7 @@ public class PngMetadata : IFormatMetadata 4 => PngBitDepth.Bit4, _ => (bpc <= 8) ? PngBitDepth.Bit8 : PngBitDepth.Bit16, }; - return new() + return new PngMetadata { ColorType = color, BitDepth = bitDepth, diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 820fc0b5c..33ba58f54 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -133,7 +133,7 @@ internal static class PngScanlineProcessor ushort l = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - Unsafe.Add(ref rowSpanRef, (uint)x) = TPixel.FromLa32(new(l, a)); + Unsafe.Add(ref rowSpanRef, (uint)x) = TPixel.FromLa32(new La32(l, a)); } } else @@ -143,7 +143,7 @@ internal static class PngScanlineProcessor { byte l = Unsafe.Add(ref scanlineSpanRef, offset2); byte a = Unsafe.Add(ref scanlineSpanRef, offset2 + bytesPerSample); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromLa16(new(l, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromLa16(new La16(l, a)); offset2 += bytesPerPixel; } } @@ -239,7 +239,7 @@ internal static class PngScanlineProcessor ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb48(new(r, g, b)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else if (pixelOffset == 0 && increment == 1) @@ -258,7 +258,7 @@ internal static class PngScanlineProcessor byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb24(new(r, g, b)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb24(new Rgb24(r, g, b)); } } @@ -339,7 +339,7 @@ internal static class PngScanlineProcessor ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new(r, g, b, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else if (pixelOffset == 0 && increment == 1) @@ -360,7 +360,7 @@ internal static class PngScanlineProcessor byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new(r, g, b, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Qoi/QoiFormat.cs b/src/ImageSharp/Formats/Qoi/QoiFormat.cs index ca2d7ae45..fbee2bc3f 100644 --- a/src/ImageSharp/Formats/Qoi/QoiFormat.cs +++ b/src/ImageSharp/Formats/Qoi/QoiFormat.cs @@ -15,7 +15,7 @@ public sealed class QoiFormat : IImageFormat /// /// Gets the shared instance. /// - public static QoiFormat Instance { get; } = new QoiFormat(); + public static QoiFormat Instance { get; } = new(); /// public string DefaultMimeType => "image/qoi"; diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index dc6b33422..ead157986 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -639,7 +639,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore { this.ReadFileHeader(stream); return new ImageInfo( - new(this.fileHeader.Width, this.fileHeader.Height), + new Size(this.fileHeader.Width, this.fileHeader.Height), this.metadata); } diff --git a/src/ImageSharp/Formats/Tga/TgaFormat.cs b/src/ImageSharp/Formats/Tga/TgaFormat.cs index e024dfc62..f5bf76fb4 100644 --- a/src/ImageSharp/Formats/Tga/TgaFormat.cs +++ b/src/ImageSharp/Formats/Tga/TgaFormat.cs @@ -11,7 +11,7 @@ public sealed class TgaFormat : IImageFormat /// /// Gets the shared instance. /// - public static TgaFormat Instance { get; } = new TgaFormat(); + public static TgaFormat Instance { get; } = new(); /// public string Name => "TGA"; diff --git a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs index ad76bc3fb..50d992030 100644 --- a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs +++ b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs @@ -34,7 +34,7 @@ public sealed class TgaImageFormatDetector : IImageFormatDetector } // The third byte is the image type. - var imageType = (TgaImageType)header[2]; + TgaImageType imageType = (TgaImageType)header[2]; if (!imageType.IsValid()) { return false; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs index 6881e3a7b..3debd373c 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs @@ -11,7 +11,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor { private readonly DeflateCompressionLevel compressionLevel; - private readonly MemoryStream memoryStream = new MemoryStream(); + private readonly MemoryStream memoryStream = new(); public DeflateCompressor(Stream output, MemoryAllocator allocator, int width, int bitsPerPixel, TiffPredictor predictor, DeflateCompressionLevel compressionLevel) : base(output, allocator, width, bitsPerPixel, predictor) @@ -29,7 +29,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor public override void CompressStrip(Span rows, int height) { this.memoryStream.Seek(0, SeekOrigin.Begin); - using (var stream = new ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) + using (ZlibDeflateStream stream = new(this.Allocator, this.memoryStream, this.compressionLevel)) { if (this.Predictor == TiffPredictor.Horizontal) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs index 1c0a47365..4229cfada 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs @@ -101,7 +101,7 @@ internal static class PackBitsWriter private static int FindRunLength(ReadOnlySpan rowSpan, int startPos, int maxRunLength) { - var startByte = rowSpan[startPos]; + byte startByte = rowSpan[startPos]; int count = 1; for (int i = startPos + 1; i < rowSpan.Length; i++) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs index 08faa539a..1ad69b2c8 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs @@ -29,8 +29,8 @@ internal class TiffJpegCompressor : TiffBaseCompressor int pixelCount = rows.Length / 3; int width = pixelCount / height; - using var memoryStream = new MemoryStream(); - var image = Image.LoadPixelData(rows, width, height); + using MemoryStream memoryStream = new(); + Image image = Image.LoadPixelData(rows, width, height); image.Save(memoryStream, new JpegEncoder() { ColorType = JpegColorType.Rgb diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs index 64e702f1b..4e176f28d 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs @@ -54,7 +54,7 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { long pos = stream.Position; - using (var deframeStream = new ZlibInflateStream( + using (ZlibInflateStream deframeStream = new( stream, () => { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index 5f18fc2d7..e6895d67c 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; /// public class LzwString { - private static readonly LzwString Empty = new LzwString(0, 0, 0, null); + private static readonly LzwString Empty = new(0, 0, 0, null); private readonly LzwString previous; private readonly byte value; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs index 240292718..f00c5aa81 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs @@ -48,7 +48,7 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var decoder = new TiffLzwDecoder(stream); + TiffLzwDecoder decoder = new(stream); decoder.DecodePixels(buffer); if (this.Predictor == TiffPredictor.Horizontal) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs index d2dbedc9c..ccdf9b0b7 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs @@ -41,7 +41,7 @@ internal sealed class ModifiedHuffmanTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount); + ModifiedHuffmanBitReader bitReader = new(stream, this.FillOrder, byteCount); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs index 6bdcad2b8..d9e49aa75 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs @@ -60,7 +60,7 @@ internal sealed class T4TiffCompression : TiffBaseDecompressor } bool eolPadding = this.faxCompressionOptions.HasFlag(FaxCompressionOptions.EolPadding); - var bitReader = new T4BitReader(stream, this.FillOrder, byteCount, eolPadding); + T4BitReader bitReader = new(stream, this.FillOrder, byteCount, eolPadding); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index c868fec62..2020dce47 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -57,9 +57,9 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor Span scanLine = scanLineBuffer.GetSpan()[..this.width]; Span referenceScanLineSpan = scanLineBuffer.GetSpan().Slice(this.width, this.width); - var bitReader = new T6BitReader(stream, this.FillOrder, byteCount); + T6BitReader bitReader = new(stream, this.FillOrder, byteCount); - var referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, this.width); + CcittReferenceScanline referenceScanLine = new(this.isWhiteZero, this.width); nint bitsWritten = 0; for (int y = 0; y < height; y++) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs index 76d0bb641..c0affc50a 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs @@ -32,7 +32,7 @@ internal class WebpTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - using WebpDecoderCore decoder = new(new WebpDecoderOptions() { GeneralOptions = this.options }); + using WebpDecoderCore decoder = new(new WebpDecoderOptions { GeneralOptions = this.options }); using Image image = decoder.Decode(this.options.Configuration, stream, cancellationToken); CopyImageBytesToBuffer(buffer, image.Frames.RootFrame.PixelBuffer); } diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs index 0bc2e7343..aa207e2b6 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; @@ -64,11 +65,11 @@ internal static class TiffDecompressorsFactory case TiffDecoderCompressionType.Jpeg: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); - return new JpegTiffCompression(new() { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, jpegTables, photometricInterpretation); + return new JpegTiffCompression(new JpegDecoderOptions { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, jpegTables, photometricInterpretation); case TiffDecoderCompressionType.OldJpeg: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); - return new OldJpegTiffCompression(new() { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, oldJpegStartOfImageMarker, photometricInterpretation); + return new OldJpegTiffCompression(new JpegDecoderOptions { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, oldJpegStartOfImageMarker, photometricInterpretation); case TiffDecoderCompressionType.Webp: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs index 2ef261811..d818aef1b 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs @@ -47,7 +47,7 @@ internal class BlackIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs index 1d33f1a24..41b2bde1b 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs @@ -25,14 +25,14 @@ internal class BlackIsZero4TiffColor : TiffBaseColorDecoder for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; - pixelRowSpan[x++] = TPixel.FromL8(new((byte)(((byteData & 0xF0) >> 4) * 17))); - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((byteData & 0x0F) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)(((byteData & 0xF0) >> 4) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((byteData & 0x0F) * 17))); } if (isOddWidth) { byte byteData = data[offset++]; - pixelRowSpan[left + width - 1] = TPixel.FromL8(new((byte)(((byteData & 0xF0) >> 4) * 17))); + pixelRowSpan[left + width - 1] = TPixel.FromL8(new L8((byte)(((byteData & 0xF0) >> 4) * 17))); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs index 709c2bf64..7428ef057 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -35,7 +36,7 @@ internal class BlackIsZeroTiffColor : TiffBaseColorDecoder { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = value / this.factor; - pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs index d6fc7c487..d23d1e290 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Numerics; using SixLabors.ImageSharp.ColorProfiles; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -34,7 +35,7 @@ internal class CieLabPlanarTiffColor : TiffBasePlanarColorDecoder(in lab); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1.0f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); offset++; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs index b0236022b..b10d27ccd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.ColorProfiles; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -30,7 +31,7 @@ internal class CieLabTiffColor : TiffBaseColorDecoder float l = (data[offset] & 0xFF) * 100f * Inv255; CieLab lab = new(l, (sbyte)data[offset + 1], (sbyte)data[offset + 2]); Rgb rgb = ColorProfileConverter.Convert(in lab); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1f)); offset += 3; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs index b0580ead3..2e22fcde0 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs @@ -47,7 +47,7 @@ internal class CmykTiffColor : TiffBaseColorDecoder { Cmyk cmyk = new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, data[offset + 3] * Inv255); Rgb rgb = ColorProfileConverter.Convert(in cmyk); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1.0f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); offset += 4; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs index 745e5846a..69113cf93 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -63,7 +64,7 @@ internal class PaletteTiffColor : TiffBaseColorDecoder float r = colorMap[rOffset + i] * InvMax; float g = colorMap[gOffset + i] * InvMax; float b = colorMap[bOffset + i] * InvMax; - palette[i] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + palette[i] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } return palette; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs index d8520e307..c1420b4f4 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs @@ -48,7 +48,7 @@ internal class Rgb161616TiffColor : TiffBaseColorDecoder ushort b = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs index f55d7225e..84efb9021 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs @@ -44,7 +44,7 @@ internal class Rgb16PlanarTiffColor : TiffBasePlanarColorDecoder offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else @@ -57,7 +57,7 @@ internal class Rgb16PlanarTiffColor : TiffBasePlanarColorDecoder offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs index 37605ef80..f9c17eb2f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -50,7 +51,7 @@ internal class RgbFloat323232TiffColor : TiffBaseColorDecoder float b = BitConverter.ToSingle(buffer); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } } else @@ -66,7 +67,7 @@ internal class RgbFloat323232TiffColor : TiffBaseColorDecoder float b = BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs index 844b08d3c..a013abfbd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -62,7 +63,7 @@ internal class RgbPlanarTiffColor : TiffBasePlanarColorDecoder float g = gBitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bBitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } rBitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs index e4965887d..9847f45b5 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs @@ -67,7 +67,7 @@ internal class Rgba16161616TiffColor : TiffBaseColorDecoder pixelRow[x] = hasAssociatedAlpha ? TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs index 3d36db17d..12357adc1 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs @@ -56,7 +56,7 @@ internal class Rgba16PlanarTiffColor : TiffBasePlanarColorDecoder(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else @@ -72,7 +72,7 @@ internal class Rgba16PlanarTiffColor : TiffBasePlanarColorDecoder(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs index 12f1b75b4..87a019641 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -55,7 +56,7 @@ internal class RgbaFloat32323232TiffColor : TiffBaseColorDecoder float a = BitConverter.ToSingle(buffer); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, a)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); } } else @@ -74,7 +75,7 @@ internal class RgbaFloat32323232TiffColor : TiffBaseColorDecoder float a = BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, a)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs index 6f1672e1b..d70873634 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs @@ -36,7 +36,7 @@ internal class WhiteIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = (ushort)(ushort.MaxValue - TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2))); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } else @@ -46,7 +46,7 @@ internal class WhiteIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = (ushort)(ushort.MaxValue - TiffUtilities.ConvertToUShortLittleEndian(data.Slice(offset, 2))); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs index 7d31f23ab..6986f25eb 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ internal class WhiteIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((15 - (byteData & 0x0F)) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((15 - (byteData & 0x0F)) * 17))); } if (isOddWidth) { byte byteData = data[offset++]; - pixelRowSpan[left + width - 1] = TPixel.FromL8(new((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); + pixelRowSpan[left + width - 1] = TPixel.FromL8(new L8((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs index 5429dbd3b..ae0dcb753 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs @@ -23,7 +23,7 @@ internal class WhiteIsZero8TiffColor : TiffBaseColorDecoder for (int x = 0; x < pixelRow.Length; x++) { byte intensity = (byte)(byte.MaxValue - data[offset++]); - pixelRow[x] = TPixel.FromL8(new(intensity)); + pixelRow[x] = TPixel.FromL8(new L8(intensity)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 0a1cf6ab9..d41749be6 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -107,7 +107,7 @@ internal class YCbCrConverter [MethodImpl(MethodImplOptions.AggressiveInlining)] public Rgba32 Convert(float y, float cb, float cr) { - var pixel = default(Rgba32); + Rgba32 pixel = default(Rgba32); pixel.R = RoundAndClampTo8Bit((cr * this.cr2R) + y); pixel.G = RoundAndClampTo8Bit((this.y2G * y) + (this.cr2G * cr) + (this.cb2G * cb)); pixel.B = RoundAndClampTo8Bit((cb * this.cb2B) + y); diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index e594ee812..fbff35297 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -228,7 +228,7 @@ internal class TiffDecoderCore : ImageDecoderCore ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new ImageInfo(new(width, height), metadata, framesMetadata); + return new ImageInfo(new Size(width, height), metadata, framesMetadata); } /// diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index 803b77fb0..eeb4afebf 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs @@ -16,7 +16,7 @@ internal class TiffEncoderEntriesCollector { private const string SoftwareValue = "ImageSharp"; - public List Entries { get; } = new List(); + public List Entries { get; } = new(); public void ProcessMetadata(Image image, bool skipMetadata) => new MetadataProcessor(this).Process(image, skipMetadata); diff --git a/src/ImageSharp/Formats/Tiff/TiffFormat.cs b/src/ImageSharp/Formats/Tiff/TiffFormat.cs index 76a06d013..eb052d1bf 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFormat.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFormat.cs @@ -17,7 +17,7 @@ public sealed class TiffFormat : IImageFormat /// /// Gets the shared instance. /// - public static TiffFormat Instance { get; } = new TiffFormat(); + public static TiffFormat Instance { get; } = new(); /// public string Name => "TIFF"; @@ -32,8 +32,8 @@ public sealed class TiffFormat : IImageFormat public IEnumerable FileExtensions => TiffConstants.FileExtensions; /// - public TiffMetadata CreateDefaultFormatMetadata() => new TiffMetadata(); + public TiffMetadata CreateDefaultFormatMetadata() => new(); /// - public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new TiffFrameMetadata(); + public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs index 8b5e04f27..e30765b1f 100644 --- a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs +++ b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs @@ -45,7 +45,7 @@ internal static class TiffUtilities return TPixel.FromRgba64(default); } - return TPixel.FromRgba64(new((ushort)(r / a), (ushort)(g / a), (ushort)(b / a), a)); + return TPixel.FromRgba64(new Rgba64((ushort)(r / a), (ushort)(g / a), (ushort)(b / a), a)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs index da6637363..ebf75efe8 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs @@ -44,7 +44,7 @@ internal sealed class TiffPaletteWriter : TiffBaseColorWriter this.colorPaletteBytes = this.colorPaletteSize * 2; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer( this.Configuration, - new QuantizerOptions() + new QuantizerOptions { MaxColors = this.maxColors }); diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index c7ce12fc7..accfea948 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -60,7 +60,7 @@ internal class AlphaDecoder : IDisposable if (this.Compressed) { - Vp8LBitReader bitReader = new Vp8LBitReader(data); + Vp8LBitReader bitReader = new(data); this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration); this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true); diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs index 505f54312..e9f50fb49 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs @@ -399,7 +399,7 @@ internal class Vp8BitWriter : BitWriterBase int mbSize = this.enc.Mbw * this.enc.Mbh; int expectedSize = (int)((uint)mbSize * 7 / 8); - Vp8BitWriter bitWriterPartZero = new Vp8BitWriter(expectedSize, this.enc); + Vp8BitWriter bitWriterPartZero = new(expectedSize, this.enc); // Partition #0 with header and partition sizes. uint size0 = bitWriterPartZero.GeneratePartition0(); @@ -545,7 +545,7 @@ internal class Vp8BitWriter : BitWriterBase // Writes the partition #0 modes (that is: all intra modes) private void CodeIntraModes() { - Vp8EncIterator it = new Vp8EncIterator(this.enc); + Vp8EncIterator it = new(this.enc); int predsWidth = this.enc.PredsWidth; do diff --git a/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs b/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs index 66662569c..7d22f7f2b 100644 --- a/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs +++ b/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs @@ -124,7 +124,7 @@ internal readonly struct WebpFrameData { Span buffer = stackalloc byte[4]; - return new( + return new WebpFrameData( dataSize: WebpChunkParsingUtils.ReadChunkSize(stream, buffer), x: WebpChunkParsingUtils.ReadUInt24LittleEndian(stream, buffer) * 2, y: WebpChunkParsingUtils.ReadUInt24LittleEndian(stream, buffer) * 2, diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 2e7dd722f..274d4426f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -149,9 +149,8 @@ internal static class BackwardReferenceEncoder } // Find the cacheBits giving the lowest entropy. - for (int idx = 0; idx < refs.Refs.Count; idx++) + foreach (PixOrCopy v in refs) { - PixOrCopy v = refs.Refs[idx]; if (v.IsLiteral()) { uint pix = bgra[pos++]; @@ -387,7 +386,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - backwardRefs.Refs.Clear(); + backwardRefs.Clear(); for (int ix = 0; ix < chosenPathSize; ix++) { int len = chosenPath[ix]; @@ -479,7 +478,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - refs.Refs.Clear(); + refs.Clear(); for (int i = 0; i < pixCount;) { // Alternative #1: Code the pixels starting at 'i' using backward reference. @@ -734,7 +733,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - refs.Refs.Clear(); + refs.Clear(); // Add first pixel as literal. AddSingleLiteral(bgra[0], useColorCache, colorCache, refs); @@ -779,10 +778,9 @@ internal static class BackwardReferenceEncoder private static void BackwardRefsWithLocalCache(ReadOnlySpan bgra, int cacheBits, Vp8LBackwardRefs refs) { int pixelIndex = 0; - ColorCache colorCache = new ColorCache(cacheBits); - for (int idx = 0; idx < refs.Refs.Count; idx++) + ColorCache colorCache = new(cacheBits); + foreach (ref PixOrCopy v in refs) { - PixOrCopy v = refs.Refs[idx]; if (v.IsLiteral()) { uint bgraLiteral = v.BgraOrDistance; @@ -790,9 +788,7 @@ internal static class BackwardReferenceEncoder if (ix >= 0) { // Color cache contains bgraLiteral - v.Mode = PixOrCopyMode.CacheIdx; - v.BgraOrDistance = (uint)ix; - v.Len = 1; + v = PixOrCopy.CreateCacheIdx(ix); } else { @@ -814,14 +810,13 @@ internal static class BackwardReferenceEncoder private static void BackwardReferences2DLocality(int xSize, Vp8LBackwardRefs refs) { - using List.Enumerator c = refs.Refs.GetEnumerator(); - while (c.MoveNext()) + foreach (ref PixOrCopy v in refs) { - if (c.Current.IsCopy()) + if (v.IsCopy()) { - int dist = (int)c.Current.BgraOrDistance; + int dist = (int)v.BgraOrDistance; int transformedDist = DistanceToPlaneCode(xSize, dist); - c.Current.BgraOrDistance = (uint)transformedDist; + v = PixOrCopy.CreateCopy((uint)transformedDist, v.Len); } } } diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs index 63ce9dbec..4ab9d7b94 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs @@ -17,7 +17,7 @@ internal sealed class CostManager : IDisposable private const int FreeIntervalsStartCount = 25; - private readonly Stack freeIntervals = new Stack(FreeIntervalsStartCount); + private readonly Stack freeIntervals = new(FreeIntervalsStartCount); public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner distArray, int pixCount, CostModel costModel) { @@ -49,7 +49,7 @@ internal sealed class CostManager : IDisposable } // Fill in the cache intervals. - var cur = new CostCacheInterval() + CostCacheInterval cur = new() { Start = 0, End = 1, @@ -62,7 +62,7 @@ internal sealed class CostManager : IDisposable double costVal = this.CostCache[i]; if (costVal != cur.Cost) { - cur = new CostCacheInterval() + cur = new CostCacheInterval { Start = i, Cost = costVal @@ -258,7 +258,7 @@ internal sealed class CostManager : IDisposable } else { - intervalNew = new CostInterval() { Cost = cost, Start = start, End = end, Index = position }; + intervalNew = new CostInterval { Cost = cost, Start = start, End = end, Index = position }; } this.PositionOrphanInterval(intervalNew, intervalIn); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs index beebc48ab..c6131bc2a 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs @@ -40,9 +40,9 @@ internal class CostModel using OwnedVp8LHistogram histogram = OwnedVp8LHistogram.Create(this.memoryAllocator, cacheBits); // The following code is similar to HistogramCreate but converts the distance to plane code. - for (int i = 0; i < backwardRefs.Refs.Count; i++) + foreach (PixOrCopy v in backwardRefs) { - histogram.AddSinglePixOrCopy(backwardRefs.Refs[i], true, xSize); + histogram.AddSinglePixOrCopy(in v, true, xSize); } ConvertPopulationCountTableToBitEstimates(histogram.NumCodes(), histogram.Literal, this.Literal); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs index 7488f03ca..58394c212 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs @@ -7,5 +7,5 @@ internal class CrunchConfig { public EntropyIx EntropyIdx { get; set; } - public List SubConfigs { get; } = new List(); + public List SubConfigs { get; } = new(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index 3a96362cf..e0d854bb0 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -109,12 +109,11 @@ internal static class HistogramEncoder { int x = 0, y = 0; int histoXSize = LosslessUtils.SubSampleSize(xSize, histoBits); - using List.Enumerator backwardRefsEnumerator = backwardRefs.Refs.GetEnumerator(); - while (backwardRefsEnumerator.MoveNext()) + + foreach (PixOrCopy v in backwardRefs) { - PixOrCopy v = backwardRefsEnumerator.Current; int ix = ((y >> histoBits) * histoXSize) + (x >> histoBits); - histograms[ix].AddSinglePixOrCopy(v, false); + histograms[ix].AddSinglePixOrCopy(in v, false); x += v.Len; while (x >= xSize) { @@ -217,7 +216,7 @@ internal static class HistogramEncoder clusterMappings[idx] = (ushort)idx; } - List indicesToRemove = new(); + List indicesToRemove = []; Vp8LStreaks stats = new(); Vp8LBitEntropy bitsEntropy = new(); for (int idx = 0; idx < histograms.Count; idx++) @@ -345,7 +344,7 @@ internal static class HistogramEncoder // Priority list of histogram pairs. Its size impacts the quality of the compression and the speed: // the smaller the faster but the worse for the compression. - List histoPriorityList = new(); + List histoPriorityList = []; const int maxSize = 9; // Fill the initial mapping. @@ -465,7 +464,7 @@ internal static class HistogramEncoder } } - HistoListUpdateHead(histoPriorityList, p); + HistoListUpdateHead(histoPriorityList, p, j); j++; } @@ -480,7 +479,7 @@ internal static class HistogramEncoder int histoSize = histograms.Count(h => h != null); // Priority list of histogram pairs. - List histoPriorityList = new(); + List histoPriorityList = []; int maxSize = histoSize * histoSize; Vp8LStreaks stats = new(); Vp8LBitEntropy bitsEntropy = new(); @@ -525,7 +524,7 @@ internal static class HistogramEncoder } else { - HistoListUpdateHead(histoPriorityList, p); + HistoListUpdateHead(histoPriorityList, p, i); i++; } } @@ -647,7 +646,7 @@ internal static class HistogramEncoder histoList.Add(pair); - HistoListUpdateHead(histoList, pair); + HistoListUpdateHead(histoList, pair, histoList.Count - 1); return pair.CostDiff; } @@ -674,13 +673,11 @@ internal static class HistogramEncoder /// /// Check whether a pair in the list should be updated as head or not. /// - private static void HistoListUpdateHead(List histoList, HistogramPair pair) + private static void HistoListUpdateHead(List histoList, HistogramPair pair, int idx) { if (pair.CostDiff < histoList[0].CostDiff) { - // Replace the best pair. - int oldIdx = histoList.IndexOf(pair); - histoList[oldIdx] = histoList[0]; + histoList[idx] = histoList[0]; histoList[0] = pair; } } diff --git a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs index d6b10ada5..bb8ce18aa 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs @@ -6,37 +6,24 @@ using System.Diagnostics; namespace SixLabors.ImageSharp.Formats.Webp.Lossless; [DebuggerDisplay("Mode: {Mode}, Len: {Len}, BgraOrDistance: {BgraOrDistance}")] -internal sealed class PixOrCopy +internal readonly struct PixOrCopy { - public PixOrCopyMode Mode { get; set; } - - public ushort Len { get; set; } - - public uint BgraOrDistance { get; set; } - - public static PixOrCopy CreateCacheIdx(int idx) => - new PixOrCopy - { - Mode = PixOrCopyMode.CacheIdx, - BgraOrDistance = (uint)idx, - Len = 1 - }; - - public static PixOrCopy CreateLiteral(uint bgra) => - new PixOrCopy - { - Mode = PixOrCopyMode.Literal, - BgraOrDistance = bgra, - Len = 1 - }; - - public static PixOrCopy CreateCopy(uint distance, ushort len) => - new PixOrCopy + public readonly PixOrCopyMode Mode; + public readonly ushort Len; + public readonly uint BgraOrDistance; + + private PixOrCopy(PixOrCopyMode mode, ushort len, uint bgraOrDistance) { - Mode = PixOrCopyMode.Copy, - BgraOrDistance = distance, - Len = len - }; + this.Mode = mode; + this.Len = len; + this.BgraOrDistance = bgraOrDistance; + } + + public static PixOrCopy CreateCacheIdx(int idx) => new(PixOrCopyMode.CacheIdx, 1, (uint)idx); + + public static PixOrCopy CreateLiteral(uint bgra) => new(PixOrCopyMode.Literal, 1, bgra); + + public static PixOrCopy CreateCopy(uint distance, ushort len) => new(PixOrCopyMode.Copy, len, distance); public int Literal(int component) => (int)(this.BgraOrDistance >> (component * 8)) & 0xFF; diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 736070a1c..19dc08fc5 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -122,8 +122,8 @@ internal static unsafe class PredictorEncoder int tileYSize = LosslessUtils.SubSampleSize(height, bits); int[] accumulatedRedHisto = new int[256]; int[] accumulatedBlueHisto = new int[256]; - var prevX = default(Vp8LMultipliers); - var prevY = default(Vp8LMultipliers); + Vp8LMultipliers prevX = default(Vp8LMultipliers); + Vp8LMultipliers prevY = default(Vp8LMultipliers); for (int tileY = 0; tileY < tileYSize; tileY++) { for (int tileX = 0; tileX < tileXSize; tileX++) @@ -856,7 +856,7 @@ internal static unsafe class PredictorEncoder int tileHeight = allYMax - tileYOffset; Span tileArgb = argb[((tileYOffset * xSize) + tileXOffset)..]; - var bestTx = default(Vp8LMultipliers); + Vp8LMultipliers bestTx = default(Vp8LMultipliers); GetBestGreenToRed(tileArgb, xSize, scratch, tileWidth, tileHeight, prevX, prevY, quality, accumulatedRedHisto, ref bestTx); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index ace9d6227..634fac5e8 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -1,21 +1,28 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Buffers; +using SixLabors.ImageSharp.Memory; + namespace SixLabors.ImageSharp.Formats.Webp.Lossless; -internal class Vp8LBackwardRefs +internal class Vp8LBackwardRefs : IDisposable { - public Vp8LBackwardRefs(int pixels) => this.Refs = new List(pixels); + private readonly IMemoryOwner refs; + private int count; + + public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels) + { + this.refs = memoryAllocator.Allocate(pixels); + this.count = 0; + } + + public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.count++] = pixOrCopy; - /// - /// Gets or sets the common block-size. - /// - public int BlockSize { get; set; } + public void Clear() => this.count = 0; - /// - /// Gets the backward references. - /// - public List Refs { get; } + public Span.Enumerator GetEnumerator() => this.refs.Slice(0, this.count).GetEnumerator(); - public void Add(PixOrCopy pixOrCopy) => this.Refs.Add(pixOrCopy); + /// + public void Dispose() => this.refs.Dispose(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index 1864e539c..b398554eb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -26,9 +26,9 @@ internal class Vp8LEncoder : IDisposable /// private ScratchBuffer scratch; // mutable struct, don't make readonly - private readonly int[][] histoArgb = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] histoArgb = [new int[256], new int[256], new int[256], new int[256]]; - private readonly int[][] bestHisto = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] bestHisto = [new int[256], new int[256], new int[256], new int[256]]; /// /// The to use for buffer allocations. @@ -45,11 +45,6 @@ internal class Vp8LEncoder : IDisposable /// private const int MaxRefsBlockPerImage = 16; - /// - /// Minimum block size for backward references. - /// - private const int MinBlockSize = 256; - /// /// A bit writer for writing lossless webp streams. /// @@ -136,14 +131,9 @@ internal class Vp8LEncoder : IDisposable this.Refs = new Vp8LBackwardRefs[3]; this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); - // We round the block size up, so we're guaranteed to have at most MaxRefsBlockPerImage blocks used: - int refsBlockSize = ((pixelCount - 1) / MaxRefsBlockPerImage) + 1; for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new Vp8LBackwardRefs(pixelCount) - { - BlockSize = refsBlockSize < MinBlockSize ? MinBlockSize : refsBlockSize - }; + this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount); } } @@ -151,10 +141,10 @@ internal class Vp8LEncoder : IDisposable // This sequence is tuned from that, but more weighted for lower symbol count, // and more spiking histograms. // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan StorageOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + private static ReadOnlySpan StorageOrder => [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Order => new byte[] { 1, 2, 0, 3 }; + private static ReadOnlySpan Order => [1, 2, 0, 3]; /// /// Gets the memory for the image data as packed bgra values. @@ -547,7 +537,7 @@ internal class Vp8LEncoder : IDisposable EntropyIx entropyIdx = this.AnalyzeEntropy(bgra, width, height, usePalette, this.PaletteSize, this.TransformBits, out redAndBlueAlwaysZero); bool doNotCache = false; - List crunchConfigs = new(); + List crunchConfigs = []; if (this.method == WebpEncodingMethod.BestQuality && this.quality == 100) { @@ -593,7 +583,7 @@ internal class Vp8LEncoder : IDisposable } } - return crunchConfigs.ToArray(); + return [.. crunchConfigs]; } private void EncodeImage(int width, int height, bool useCache, CrunchConfig config, int cacheBits, bool lowEffort) @@ -1068,9 +1058,8 @@ internal class Vp8LEncoder : IDisposable int histogramIx = histogramSymbols[0]; Span codes = huffmanCodes.AsSpan(5 * histogramIx); - for (int i = 0; i < backwardRefs.Refs.Count; i++) + foreach (PixOrCopy v in backwardRefs) { - PixOrCopy v = backwardRefs.Refs[i]; if (tileX != (x & tileMask) || tileY != (y & tileMask)) { tileX = x & tileMask; @@ -1265,13 +1254,13 @@ internal class Vp8LEncoder : IDisposable // non-zero red and blue values. If all are zero, we can later skip // the cross color optimization. byte[][] histoPairs = - { - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue }, - new[] { (byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred }, - new[] { (byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen }, - new[] { (byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen }, - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue } - }; + [ + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue], + [(byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred], + [(byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen], + [(byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen], + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue] + ]; Span redHisto = histo[(256 * histoPairs[(int)minEntropyIx][0])..]; Span blueHisto = histo[(256 * histoPairs[(int)minEntropyIx][1])..]; for (int i = 1; i < 256; i++) @@ -1325,7 +1314,7 @@ internal class Vp8LEncoder : IDisposable /// The number of palette entries. private static int GetColorPalette(ReadOnlySpan bgra, int width, int height, Span palette) { - HashSet colors = new(); + HashSet colors = []; for (int y = 0; y < height; y++) { ReadOnlySpan bgraRow = bgra.Slice(y * width, width); @@ -1904,9 +1893,9 @@ internal class Vp8LEncoder : IDisposable /// public void ClearRefs() { - foreach (Vp8LBackwardRefs t in this.Refs) + foreach (Vp8LBackwardRefs refs in this.Refs) { - t.Refs.Clear(); + refs.Clear(); } } @@ -1918,6 +1907,12 @@ internal class Vp8LEncoder : IDisposable this.BgraScratch?.Dispose(); this.Palette.Dispose(); this.TransformData?.Dispose(); + + foreach (Vp8LBackwardRefs refs in this.Refs) + { + refs.Dispose(); + } + this.HashChain.Dispose(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index f47397790..03bedfe67 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -138,9 +138,9 @@ internal abstract unsafe class Vp8LHistogram /// The backward references. public void StoreRefs(Vp8LBackwardRefs refs) { - for (int i = 0; i < refs.Refs.Count; i++) + foreach (PixOrCopy v in refs) { - this.AddSinglePixOrCopy(refs.Refs[i], false); + this.AddSinglePixOrCopy(in v, false); } } @@ -150,7 +150,7 @@ internal abstract unsafe class Vp8LHistogram /// The token to add. /// Indicates whether to use the distance modifier. /// xSize is only used when useDistanceModifier is true. - public void AddSinglePixOrCopy(PixOrCopy v, bool useDistanceModifier, int xSize = 0) + public void AddSinglePixOrCopy(in PixOrCopy v, bool useDistanceModifier, int xSize = 0) { if (v.IsLiteral()) { diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs index a46838ee6..817641393 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs @@ -49,9 +49,9 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable } } - public Vp8LHistogramSet(int capacity) => this.items = new(capacity); + public Vp8LHistogramSet(int capacity) => this.items = new List(capacity); - public Vp8LHistogramSet() => this.items = new(); + public Vp8LHistogramSet() => this.items = new List(); public int Count => this.items.Count; diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index e9eb1110b..ed1ed52ab 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -36,8 +36,8 @@ internal static unsafe class QuantEnc int tlambda = dqm.TLambda; Span src = it.YuvIn.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Vp8ModeScore rdCur = rdTmp; Vp8ModeScore rdBest = rd; int mode; @@ -107,7 +107,7 @@ internal static unsafe class QuantEnc Span bestBlocks = it.YuvOut2.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; int totalHeaderBits = 0; - var rdBest = new Vp8ModeScore(); + Vp8ModeScore rdBest = new(); if (maxI4HeaderBits == 0) { @@ -118,9 +118,9 @@ internal static unsafe class QuantEnc rdBest.H = 211; // '211' is the value of VP8BitCost(0, 145) rdBest.SetRdScore(dqm.LambdaMode); it.StartI4(); - var rdi4 = new Vp8ModeScore(); - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdi4 = new(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Span tmpLevels = stackalloc short[16]; do { @@ -220,9 +220,9 @@ internal static unsafe class QuantEnc Span tmpDst = it.YuvOut2.AsSpan(Vp8EncIterator.UOffEnc); Span dst0 = it.YuvOut.AsSpan(Vp8EncIterator.UOffEnc); Span dst = dst0; - var rdBest = new Vp8ModeScore(); - var rdUv = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdBest = new(); + Vp8ModeScore rdUv = new(); + Vp8Residual res = new(); int mode; rd.ModeUv = -1; @@ -628,7 +628,7 @@ internal static unsafe class QuantEnc Vector128 out8 = Sse2.PackSignedSaturate(out08.AsInt32(), out12.AsInt32()); // if (coeff > 2047) coeff = 2047 - var maxCoeff2047 = Vector128.Create((short)MaxLevel); + Vector128 maxCoeff2047 = Vector128.Create((short)MaxLevel); out0 = Sse2.Min(out0, maxCoeff2047); out8 = Sse2.Min(out8, maxCoeff2047); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index 52c7e9703..a7c96edb7 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -396,7 +396,7 @@ internal class Vp8EncIterator this.MakeLuma16Preds(); for (mode = 0; mode < maxMode; mode++) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(YOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8I16ModeOffsets[mode]), 0, 16); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) @@ -414,7 +414,7 @@ internal class Vp8EncIterator { Span modes = stackalloc byte[16]; const int maxMode = MaxIntra4Mode; - Vp8Histogram totalHisto = new Vp8Histogram(); + Vp8Histogram totalHisto = new(); int curHisto = 0; this.StartI4(); do @@ -467,7 +467,7 @@ internal class Vp8EncIterator this.MakeChroma8Preds(); for (mode = 0; mode < maxMode; ++mode) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(UOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8UvModeOffsets[mode]), 16, 16 + 4 + 4); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 65d5b65e8..f14df853c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -150,7 +150,7 @@ internal sealed class WebpLossyDecoder { int offset = yMulWidth + x; Bgr24 bgr = pixelsBgr[offset]; - decodedPixelRow[x] = TPixel.FromBgra32(new(bgr.R, bgr.G, bgr.B, alphaSpan[offset])); + decodedPixelRow[x] = TPixel.FromBgra32(new Bgra32(bgr.R, bgr.G, bgr.B, alphaSpan[offset])); } } } diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 4ccaf6503..8df159dbf 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -118,7 +118,7 @@ internal static class WebpChunkParsingUtils Vp8BitReader bitReader = new(stream, remaining, memoryAllocator, partitionLength) { Remaining = remaining }; - return new() + return new WebpImageInfo { Width = width, Height = height, @@ -176,7 +176,7 @@ internal static class WebpChunkParsingUtils WebpThrowHelper.ThrowNotSupportedException($"Unexpected version number {version} found in VP8L header"); } - return new() + return new WebpImageInfo { Width = width, Height = height, @@ -239,7 +239,7 @@ internal static class WebpChunkParsingUtils uint height = ReadUInt24LittleEndian(stream, buffer) + 1; // Read all the chunks in the order they occur. - return new() + return new WebpImageInfo { Width = width, Height = height, diff --git a/src/ImageSharp/Formats/Webp/WebpDecoder.cs b/src/ImageSharp/Formats/Webp/WebpDecoder.cs index dfbf4ef0e..48d725b26 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoder.cs @@ -17,7 +17,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder /// /// Gets the shared instance. /// - public static WebpDecoder Instance { get; } = new WebpDecoder(); + public static WebpDecoder Instance { get; } = new(); /// protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -25,7 +25,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(new WebpDecoderOptions() { GeneralOptions = options }); + using WebpDecoderCore decoder = new(new WebpDecoderOptions { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } @@ -35,7 +35,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(options); + using WebpDecoderCore decoder = new(options); Image image = decoder.Decode(options.GeneralOptions.Configuration, stream, cancellationToken); ScaleToTargetSize(options.GeneralOptions, image); @@ -52,5 +52,5 @@ public sealed class WebpDecoder : SpecializedImageDecoder => this.Decode(options, stream, cancellationToken); /// - protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new WebpDecoderOptions { GeneralOptions = options }; + protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new() { GeneralOptions = options }; } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs index 8840805b1..6fb15acbb 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Webp; public sealed class WebpDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the flag to decide how to handle the background color Animation Chunk. diff --git a/src/ImageSharp/Formats/Webp/WebpFormat.cs b/src/ImageSharp/Formats/Webp/WebpFormat.cs index 1764182c5..9853ce7d7 100644 --- a/src/ImageSharp/Formats/Webp/WebpFormat.cs +++ b/src/ImageSharp/Formats/Webp/WebpFormat.cs @@ -15,7 +15,7 @@ public sealed class WebpFormat : IImageFormat /// /// Gets the shared instance. /// - public static WebpFormat Instance { get; } = new WebpFormat(); + public static WebpFormat Instance { get; } = new(); /// public string Name => "WEBP"; @@ -30,8 +30,8 @@ public sealed class WebpFormat : IImageFormat public IEnumerable FileExtensions => WebpConstants.FileExtensions; /// - public WebpMetadata CreateDefaultFormatMetadata() => new WebpMetadata(); + public WebpMetadata CreateDefaultFormatMetadata() => new(); /// - public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new WebpFrameMetadata(); + public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index 51721c53e..9461acaf7 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -89,7 +89,7 @@ public class WebpMetadata : IFormatMetadata break; } - return new() + return new WebpMetadata { BitsPerPixel = bitsPerPixel, ColorType = color, diff --git a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs index 4220b3df7..9412062cc 100644 --- a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs +++ b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs @@ -18,7 +18,7 @@ public static class GraphicOptionsDefaultsExtensions /// The passed in to allow chaining. public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, Action optionsBuilder) { - var cloned = context.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = context.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); context.Properties[typeof(GraphicsOptions)] = cloned; return context; @@ -31,7 +31,7 @@ public static class GraphicOptionsDefaultsExtensions /// The default options to use. public static void SetGraphicsOptions(this Configuration configuration, Action optionsBuilder) { - var cloned = configuration.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = configuration.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); configuration.Properties[typeof(GraphicsOptions)] = cloned; } @@ -65,7 +65,7 @@ public static class GraphicOptionsDefaultsExtensions /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this IImageProcessingContext context) { - if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (context.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } @@ -82,12 +82,12 @@ public static class GraphicOptionsDefaultsExtensions /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this Configuration configuration) { - if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } - var configOptions = new GraphicsOptions(); + GraphicsOptions configOptions = new(); // capture the fallback so the same instance will always be returned in case its mutated configuration.Properties[typeof(GraphicsOptions)] = configOptions; diff --git a/src/ImageSharp/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs index 4ac8585c3..dc3d17902 100644 --- a/src/ImageSharp/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -84,5 +84,5 @@ public class GraphicsOptions : IDeepCloneable public PixelAlphaCompositionMode AlphaCompositionMode { get; set; } = PixelAlphaCompositionMode.SrcOver; /// - public GraphicsOptions DeepClone() => new GraphicsOptions(this); + public GraphicsOptions DeepClone() => new(this); } diff --git a/src/ImageSharp/IO/ChunkedMemoryStream.cs b/src/ImageSharp/IO/ChunkedMemoryStream.cs index a5a401144..d62a64c23 100644 --- a/src/ImageSharp/IO/ChunkedMemoryStream.cs +++ b/src/ImageSharp/IO/ChunkedMemoryStream.cs @@ -27,7 +27,7 @@ internal sealed class ChunkedMemoryStream : Stream /// /// The memory allocator. public ChunkedMemoryStream(MemoryAllocator allocator) - => this.memoryChunkBuffer = new(allocator); + => this.memoryChunkBuffer = new MemoryChunkBuffer(allocator); /// public override bool CanRead => !this.isDisposed; diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 61f4c0ea9..003a0349a 100644 --- a/src/ImageSharp/ImageFrame.LoadPixelData.cs +++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs @@ -40,7 +40,7 @@ public partial class ImageFrame int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); - var image = new ImageFrame(configuration, width, height); + ImageFrame image = new(configuration, width, height); data = data[..count]; data.CopyTo(image.PixelBuffer.FastMemoryGroup); diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs index 686292bc7..3d4b63fad 100644 --- a/src/ImageSharp/ImageFrame.cs +++ b/src/ImageSharp/ImageFrame.cs @@ -25,7 +25,7 @@ public abstract partial class ImageFrame : IConfigurationProvider, IDisposable protected ImageFrame(Configuration configuration, int width, int height, ImageFrameMetadata metadata) { this.Configuration = configuration; - this.Size = new(width, height); + this.Size = new Size(width, height); this.Metadata = metadata; } diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 7ec791838..dff8f577f 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -77,7 +77,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The images metadata. internal Image(Configuration configuration, int width, int height, ImageMetadata? metadata) - : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) + : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new ImageMetadata(), width, height) => this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); /// @@ -128,7 +128,7 @@ public sealed class Image : Image int height, TPixel backgroundColor, ImageMetadata? metadata) - : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) + : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new ImageMetadata(), width, height) => this.frames = new ImageFrameCollection(this, width, height, backgroundColor); /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs index 24bf52b1f..e3b73204d 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs @@ -11,7 +11,7 @@ internal partial class UniformUnmanagedMemoryPool bool clear) where T : struct { - var buffer = new UnmanagedBuffer(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); + UnmanagedBuffer buffer = new(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); if (clear) { buffer.Clear(); diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs index aa8bcd385..5e15e46e9 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -337,6 +337,6 @@ internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedEx public bool Enabled => this.Rate > 0; - public static TrimSettings Default => new TrimSettings(); + public static TrimSettings Default => new(); } } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs index de0964726..854b40e0c 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs @@ -35,7 +35,7 @@ internal sealed unsafe class UnmanagedBuffer : MemoryManager, IRefCounted { DebugGuard.NotDisposed(this.disposed == 1, this.GetType().Name); DebugGuard.NotDisposed(this.lifetimeGuard.IsDisposed, this.lifetimeGuard.GetType().Name); - return new(this.Pointer, this.lengthInElements); + return new Span(this.Pointer, this.lengthInElements); } /// diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 621073a3d..10defe6cd 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -96,7 +96,7 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato if (lengthInBytes <= (ulong)this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer(length); + SharedArrayPoolBuffer buffer = new(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); @@ -127,7 +127,7 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato { if (totalLengthInBytes <= this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer((int)totalLengthInElements); + SharedArrayPoolBuffer buffer = new((int)totalLengthInElements); return MemoryGroup.CreateContiguous(buffer, options.Has(AllocationOptions.Clean)); } diff --git a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs index da202aa59..daf1a7992 100644 --- a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs @@ -20,7 +20,7 @@ internal class UnmanagedMemoryAllocator : MemoryAllocator public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) { - var buffer = UnmanagedBuffer.Allocate(length); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs index e2e933f3c..148b5f6bf 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs @@ -77,7 +77,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(target.Length, source.TotalLength, nameof(target)); - var cur = new MemoryGroupCursor(source); + MemoryGroupCursor cur = new(source); long position = 0; while (position < source.TotalLength) { @@ -100,7 +100,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(target, nameof(target)); Guard.MustBeGreaterThanOrEqualTo(target.TotalLength, source.Length, nameof(target)); - var cur = new MemoryGroupCursor(target); + MemoryGroupCursor cur = new(target); while (!source.IsEmpty) { @@ -126,8 +126,8 @@ internal static class MemoryGroupExtensions } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { @@ -162,8 +162,8 @@ internal static class MemoryGroupExtensions } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs index 9da0139e6..af896ee0e 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs @@ -66,14 +66,14 @@ internal abstract partial class MemoryGroup int sizeOfLastBuffer, AllocationOptions options) { - var result = new IMemoryOwner[pooledBuffers.Length]; + IMemoryOwner[] result = new IMemoryOwner[pooledBuffers.Length]; for (int i = 0; i < pooledBuffers.Length - 1; i++) { - var currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); + ObservedBuffer currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); result[i] = currentBuffer; } - var lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); + ObservedBuffer lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); result[result.Length - 1] = lastBuffer; return result; } @@ -193,7 +193,7 @@ internal abstract partial class MemoryGroup int lengthInElements, AllocationOptions options) { - var buffer = new ObservedBuffer(handle, lengthInElements); + ObservedBuffer buffer = new(handle, lengthInElements); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index 03c29a723..d08bf248b 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs @@ -97,7 +97,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable if (totalLengthInElements == 0) { - var buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; + IMemoryOwner[] buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; return new Owned(buffers0, 0, 0, true); } @@ -120,7 +120,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable bufferCount++; } - var buffers = new IMemoryOwner[bufferCount]; + IMemoryOwner[] buffers = new IMemoryOwner[bufferCount]; for (int i = 0; i < buffers.Length - 1; i++) { buffers[i] = allocator.Allocate(bufferLength, options); @@ -142,7 +142,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable } int length = buffer.Memory.Length; - var buffers = new IMemoryOwner[1] { buffer }; + IMemoryOwner[] buffers = new IMemoryOwner[1] { buffer }; return new Owned(buffers, length, length, true); } diff --git a/src/ImageSharp/Memory/RowInterval.cs b/src/ImageSharp/Memory/RowInterval.cs index 90a88d735..f27dc7441 100644 --- a/src/ImageSharp/Memory/RowInterval.cs +++ b/src/ImageSharp/Memory/RowInterval.cs @@ -79,7 +79,7 @@ public readonly struct RowInterval : IEquatable /// public override string ToString() => $"RowInterval [{this.Min}->{this.Max}]"; - internal RowInterval Slice(int start) => new RowInterval(this.Min + start, this.Max); + internal RowInterval Slice(int start) => new(this.Min + start, this.Max); - internal RowInterval Slice(int start, int length) => new RowInterval(this.Min + start, this.Min + start + length); + internal RowInterval Slice(int start, int length) => new(this.Min + start, this.Min + start + length); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs index 9ee2cf2f4..ff74ecd19 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the FaxProfile exif tag. /// - public static ExifTag FaxProfile { get; } = new ExifTag(ExifTagValue.FaxProfile); + public static ExifTag FaxProfile { get; } = new(ExifTagValue.FaxProfile); /// /// Gets the ModeNumber exif tag. /// - public static ExifTag ModeNumber { get; } = new ExifTag(ExifTagValue.ModeNumber); + public static ExifTag ModeNumber { get; } = new(ExifTagValue.ModeNumber); /// /// Gets the GPSAltitudeRef exif tag. /// - public static ExifTag GPSAltitudeRef { get; } = new ExifTag(ExifTagValue.GPSAltitudeRef); + public static ExifTag GPSAltitudeRef { get; } = new(ExifTagValue.GPSAltitudeRef); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs index 00a9056d3..64d8e1437 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs @@ -9,40 +9,40 @@ public abstract partial class ExifTag /// /// Gets the ClipPath exif tag. /// - public static ExifTag ClipPath => new ExifTag(ExifTagValue.ClipPath); + public static ExifTag ClipPath => new(ExifTagValue.ClipPath); /// /// Gets the VersionYear exif tag. /// - public static ExifTag VersionYear => new ExifTag(ExifTagValue.VersionYear); + public static ExifTag VersionYear => new(ExifTagValue.VersionYear); /// /// Gets the XMP exif tag. /// - public static ExifTag XMP => new ExifTag(ExifTagValue.XMP); + public static ExifTag XMP => new(ExifTagValue.XMP); /// /// Gets the IPTC exif tag. /// - public static ExifTag IPTC => new ExifTag(ExifTagValue.IPTC); + public static ExifTag IPTC => new(ExifTagValue.IPTC); /// /// Gets the IccProfile exif tag. /// - public static ExifTag IccProfile => new ExifTag(ExifTagValue.IccProfile); + public static ExifTag IccProfile => new(ExifTagValue.IccProfile); /// /// Gets the CFAPattern2 exif tag. /// - public static ExifTag CFAPattern2 => new ExifTag(ExifTagValue.CFAPattern2); + public static ExifTag CFAPattern2 => new(ExifTagValue.CFAPattern2); /// /// Gets the TIFFEPStandardID exif tag. /// - public static ExifTag TIFFEPStandardID => new ExifTag(ExifTagValue.TIFFEPStandardID); + public static ExifTag TIFFEPStandardID => new(ExifTagValue.TIFFEPStandardID); /// /// Gets the GPSVersionID exif tag. /// - public static ExifTag GPSVersionID => new ExifTag(ExifTagValue.GPSVersionID); + public static ExifTag GPSVersionID => new(ExifTagValue.GPSVersionID); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs index 91d0c97b3..fded12261 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs @@ -9,20 +9,20 @@ public abstract partial class ExifTag /// /// Gets the PixelScale exif tag. /// - public static ExifTag PixelScale { get; } = new ExifTag(ExifTagValue.PixelScale); + public static ExifTag PixelScale { get; } = new(ExifTagValue.PixelScale); /// /// Gets the IntergraphMatrix exif tag. /// - public static ExifTag IntergraphMatrix { get; } = new ExifTag(ExifTagValue.IntergraphMatrix); + public static ExifTag IntergraphMatrix { get; } = new(ExifTagValue.IntergraphMatrix); /// /// Gets the ModelTiePoint exif tag. /// - public static ExifTag ModelTiePoint { get; } = new ExifTag(ExifTagValue.ModelTiePoint); + public static ExifTag ModelTiePoint { get; } = new(ExifTagValue.ModelTiePoint); /// /// Gets the ModelTransform exif tag. /// - public static ExifTag ModelTransform { get; } = new ExifTag(ExifTagValue.ModelTransform); + public static ExifTag ModelTransform { get; } = new(ExifTagValue.ModelTransform); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs index 4b53ba636..4cac0d0ca 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the UserComment exif tag. /// - public static ExifTag UserComment { get; } = new ExifTag(ExifTagValue.UserComment); + public static ExifTag UserComment { get; } = new(ExifTagValue.UserComment); /// /// Gets the GPSProcessingMethod exif tag. /// - public static ExifTag GPSProcessingMethod { get; } = new ExifTag(ExifTagValue.GPSProcessingMethod); + public static ExifTag GPSProcessingMethod { get; } = new(ExifTagValue.GPSProcessingMethod); /// /// Gets the GPSAreaInformation exif tag. /// - public static ExifTag GPSAreaInformation { get; } = new ExifTag(ExifTagValue.GPSAreaInformation); + public static ExifTag GPSAreaInformation { get; } = new(ExifTagValue.GPSAreaInformation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs index f6c7c8ea7..5f9dfb4cd 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs @@ -9,105 +9,105 @@ public abstract partial class ExifTag /// /// Gets the SubfileType exif tag. /// - public static ExifTag SubfileType { get; } = new ExifTag(ExifTagValue.SubfileType); + public static ExifTag SubfileType { get; } = new(ExifTagValue.SubfileType); /// /// Gets the SubIFDOffset exif tag. /// - public static ExifTag SubIFDOffset { get; } = new ExifTag(ExifTagValue.SubIFDOffset); + public static ExifTag SubIFDOffset { get; } = new(ExifTagValue.SubIFDOffset); /// /// Gets the GPSIFDOffset exif tag. /// - public static ExifTag GPSIFDOffset { get; } = new ExifTag(ExifTagValue.GPSIFDOffset); + public static ExifTag GPSIFDOffset { get; } = new(ExifTagValue.GPSIFDOffset); /// /// Gets the T4Options exif tag. /// - public static ExifTag T4Options { get; } = new ExifTag(ExifTagValue.T4Options); + public static ExifTag T4Options { get; } = new(ExifTagValue.T4Options); /// /// Gets the T6Options exif tag. /// - public static ExifTag T6Options { get; } = new ExifTag(ExifTagValue.T6Options); + public static ExifTag T6Options { get; } = new(ExifTagValue.T6Options); /// /// Gets the XClipPathUnits exif tag. /// - public static ExifTag XClipPathUnits { get; } = new ExifTag(ExifTagValue.XClipPathUnits); + public static ExifTag XClipPathUnits { get; } = new(ExifTagValue.XClipPathUnits); /// /// Gets the YClipPathUnits exif tag. /// - public static ExifTag YClipPathUnits { get; } = new ExifTag(ExifTagValue.YClipPathUnits); + public static ExifTag YClipPathUnits { get; } = new(ExifTagValue.YClipPathUnits); /// /// Gets the ProfileType exif tag. /// - public static ExifTag ProfileType { get; } = new ExifTag(ExifTagValue.ProfileType); + public static ExifTag ProfileType { get; } = new(ExifTagValue.ProfileType); /// /// Gets the CodingMethods exif tag. /// - public static ExifTag CodingMethods { get; } = new ExifTag(ExifTagValue.CodingMethods); + public static ExifTag CodingMethods { get; } = new(ExifTagValue.CodingMethods); /// /// Gets the T82ptions exif tag. /// - public static ExifTag T82ptions { get; } = new ExifTag(ExifTagValue.T82ptions); + public static ExifTag T82ptions { get; } = new(ExifTagValue.T82ptions); /// /// Gets the JPEGInterchangeFormat exif tag. /// - public static ExifTag JPEGInterchangeFormat { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormat); + public static ExifTag JPEGInterchangeFormat { get; } = new(ExifTagValue.JPEGInterchangeFormat); /// /// Gets the JPEGInterchangeFormatLength exif tag. /// - public static ExifTag JPEGInterchangeFormatLength { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormatLength); + public static ExifTag JPEGInterchangeFormatLength { get; } = new(ExifTagValue.JPEGInterchangeFormatLength); /// /// Gets the MDFileTag exif tag. /// - public static ExifTag MDFileTag { get; } = new ExifTag(ExifTagValue.MDFileTag); + public static ExifTag MDFileTag { get; } = new(ExifTagValue.MDFileTag); /// /// Gets the StandardOutputSensitivity exif tag. /// - public static ExifTag StandardOutputSensitivity { get; } = new ExifTag(ExifTagValue.StandardOutputSensitivity); + public static ExifTag StandardOutputSensitivity { get; } = new(ExifTagValue.StandardOutputSensitivity); /// /// Gets the RecommendedExposureIndex exif tag. /// - public static ExifTag RecommendedExposureIndex { get; } = new ExifTag(ExifTagValue.RecommendedExposureIndex); + public static ExifTag RecommendedExposureIndex { get; } = new(ExifTagValue.RecommendedExposureIndex); /// /// Gets the ISOSpeed exif tag. /// - public static ExifTag ISOSpeed { get; } = new ExifTag(ExifTagValue.ISOSpeed); + public static ExifTag ISOSpeed { get; } = new(ExifTagValue.ISOSpeed); /// /// Gets the ISOSpeedLatitudeyyy exif tag. /// - public static ExifTag ISOSpeedLatitudeyyy { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudeyyy); + public static ExifTag ISOSpeedLatitudeyyy { get; } = new(ExifTagValue.ISOSpeedLatitudeyyy); /// /// Gets the ISOSpeedLatitudezzz exif tag. /// - public static ExifTag ISOSpeedLatitudezzz { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudezzz); + public static ExifTag ISOSpeedLatitudezzz { get; } = new(ExifTagValue.ISOSpeedLatitudezzz); /// /// Gets the FaxRecvParams exif tag. /// - public static ExifTag FaxRecvParams { get; } = new ExifTag(ExifTagValue.FaxRecvParams); + public static ExifTag FaxRecvParams { get; } = new(ExifTagValue.FaxRecvParams); /// /// Gets the FaxRecvTime exif tag. /// - public static ExifTag FaxRecvTime { get; } = new ExifTag(ExifTagValue.FaxRecvTime); + public static ExifTag FaxRecvTime { get; } = new(ExifTagValue.FaxRecvTime); /// /// Gets the ImageNumber exif tag. /// - public static ExifTag ImageNumber { get; } = new ExifTag(ExifTagValue.ImageNumber); + public static ExifTag ImageNumber { get; } = new(ExifTagValue.ImageNumber); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs index 4767ca852..e6821651a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs @@ -9,55 +9,55 @@ public abstract partial class ExifTag /// /// Gets the FreeOffsets exif tag. /// - public static ExifTag FreeOffsets { get; } = new ExifTag(ExifTagValue.FreeOffsets); + public static ExifTag FreeOffsets { get; } = new(ExifTagValue.FreeOffsets); /// /// Gets the FreeByteCounts exif tag. /// - public static ExifTag FreeByteCounts { get; } = new ExifTag(ExifTagValue.FreeByteCounts); + public static ExifTag FreeByteCounts { get; } = new(ExifTagValue.FreeByteCounts); /// /// Gets the ColorResponseUnit exif tag. /// - public static ExifTag ColorResponseUnit { get; } = new ExifTag(ExifTagValue.ColorResponseUnit); + public static ExifTag ColorResponseUnit { get; } = new(ExifTagValue.ColorResponseUnit); /// /// Gets the SMinSampleValue exif tag. /// - public static ExifTag SMinSampleValue { get; } = new ExifTag(ExifTagValue.SMinSampleValue); + public static ExifTag SMinSampleValue { get; } = new(ExifTagValue.SMinSampleValue); /// /// Gets the SMaxSampleValue exif tag. /// - public static ExifTag SMaxSampleValue { get; } = new ExifTag(ExifTagValue.SMaxSampleValue); + public static ExifTag SMaxSampleValue { get; } = new(ExifTagValue.SMaxSampleValue); /// /// Gets the JPEGQTables exif tag. /// - public static ExifTag JPEGQTables { get; } = new ExifTag(ExifTagValue.JPEGQTables); + public static ExifTag JPEGQTables { get; } = new(ExifTagValue.JPEGQTables); /// /// Gets the JPEGDCTables exif tag. /// - public static ExifTag JPEGDCTables { get; } = new ExifTag(ExifTagValue.JPEGDCTables); + public static ExifTag JPEGDCTables { get; } = new(ExifTagValue.JPEGDCTables); /// /// Gets the JPEGACTables exif tag. /// - public static ExifTag JPEGACTables { get; } = new ExifTag(ExifTagValue.JPEGACTables); + public static ExifTag JPEGACTables { get; } = new(ExifTagValue.JPEGACTables); /// /// Gets the StripRowCounts exif tag. /// - public static ExifTag StripRowCounts { get; } = new ExifTag(ExifTagValue.StripRowCounts); + public static ExifTag StripRowCounts { get; } = new(ExifTagValue.StripRowCounts); /// /// Gets the IntergraphRegisters exif tag. /// - public static ExifTag IntergraphRegisters { get; } = new ExifTag(ExifTagValue.IntergraphRegisters); + public static ExifTag IntergraphRegisters { get; } = new(ExifTagValue.IntergraphRegisters); /// /// Gets the offset to child IFDs exif tag. /// - public static ExifTag SubIFDs { get; } = new ExifTag(ExifTagValue.SubIFDs); + public static ExifTag SubIFDs { get; } = new(ExifTagValue.SubIFDs); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs index 2018e4cea..e023beeb7 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs @@ -9,45 +9,45 @@ public abstract partial class ExifTag /// /// Gets the ImageWidth exif tag. /// - public static ExifTag ImageWidth { get; } = new ExifTag(ExifTagValue.ImageWidth); + public static ExifTag ImageWidth { get; } = new(ExifTagValue.ImageWidth); /// /// Gets the ImageLength exif tag. /// - public static ExifTag ImageLength { get; } = new ExifTag(ExifTagValue.ImageLength); + public static ExifTag ImageLength { get; } = new(ExifTagValue.ImageLength); /// /// Gets the RowsPerStrip exif tag. /// - public static ExifTag RowsPerStrip { get; } = new ExifTag(ExifTagValue.RowsPerStrip); + public static ExifTag RowsPerStrip { get; } = new(ExifTagValue.RowsPerStrip); /// /// Gets the TileWidth exif tag. /// - public static ExifTag TileWidth { get; } = new ExifTag(ExifTagValue.TileWidth); + public static ExifTag TileWidth { get; } = new(ExifTagValue.TileWidth); /// /// Gets the TileLength exif tag. /// - public static ExifTag TileLength { get; } = new ExifTag(ExifTagValue.TileLength); + public static ExifTag TileLength { get; } = new(ExifTagValue.TileLength); /// /// Gets the BadFaxLines exif tag. /// - public static ExifTag BadFaxLines { get; } = new ExifTag(ExifTagValue.BadFaxLines); + public static ExifTag BadFaxLines { get; } = new(ExifTagValue.BadFaxLines); /// /// Gets the ConsecutiveBadFaxLines exif tag. /// - public static ExifTag ConsecutiveBadFaxLines { get; } = new ExifTag(ExifTagValue.ConsecutiveBadFaxLines); + public static ExifTag ConsecutiveBadFaxLines { get; } = new(ExifTagValue.ConsecutiveBadFaxLines); /// /// Gets the PixelXDimension exif tag. /// - public static ExifTag PixelXDimension { get; } = new ExifTag(ExifTagValue.PixelXDimension); + public static ExifTag PixelXDimension { get; } = new(ExifTagValue.PixelXDimension); /// /// Gets the PixelYDimension exif tag. /// - public static ExifTag PixelYDimension { get; } = new ExifTag(ExifTagValue.PixelYDimension); + public static ExifTag PixelYDimension { get; } = new(ExifTagValue.PixelYDimension); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs index cd8968141..6a7438fc6 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the StripOffsets exif tag. /// - public static ExifTag StripOffsets { get; } = new ExifTag(ExifTagValue.StripOffsets); + public static ExifTag StripOffsets { get; } = new(ExifTagValue.StripOffsets); /// /// Gets the StripByteCounts exif tag. /// - public static ExifTag StripByteCounts { get; } = new ExifTag(ExifTagValue.StripByteCounts); + public static ExifTag StripByteCounts { get; } = new(ExifTagValue.StripByteCounts); /// /// Gets the TileByteCounts exif tag. /// - public static ExifTag TileByteCounts { get; } = new ExifTag(ExifTagValue.TileByteCounts); + public static ExifTag TileByteCounts { get; } = new(ExifTagValue.TileByteCounts); /// /// Gets the TileOffsets exif tag. /// - public static ExifTag TileOffsets { get; } = new ExifTag(ExifTagValue.TileOffsets); + public static ExifTag TileOffsets { get; } = new(ExifTagValue.TileOffsets); /// /// Gets the ImageLayer exif tag. /// - public static ExifTag ImageLayer { get; } = new ExifTag(ExifTagValue.ImageLayer); + public static ExifTag ImageLayer { get; } = new(ExifTagValue.ImageLayer); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs index e4fe13fe5..02526ac34 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs @@ -9,165 +9,165 @@ public abstract partial class ExifTag /// /// Gets the XPosition exif tag. /// - public static ExifTag XPosition { get; } = new ExifTag(ExifTagValue.XPosition); + public static ExifTag XPosition { get; } = new(ExifTagValue.XPosition); /// /// Gets the YPosition exif tag. /// - public static ExifTag YPosition { get; } = new ExifTag(ExifTagValue.YPosition); + public static ExifTag YPosition { get; } = new(ExifTagValue.YPosition); /// /// Gets the XResolution exif tag. /// - public static ExifTag XResolution { get; } = new ExifTag(ExifTagValue.XResolution); + public static ExifTag XResolution { get; } = new(ExifTagValue.XResolution); /// /// Gets the YResolution exif tag. /// - public static ExifTag YResolution { get; } = new ExifTag(ExifTagValue.YResolution); + public static ExifTag YResolution { get; } = new(ExifTagValue.YResolution); /// /// Gets the BatteryLevel exif tag. /// - public static ExifTag BatteryLevel { get; } = new ExifTag(ExifTagValue.BatteryLevel); + public static ExifTag BatteryLevel { get; } = new(ExifTagValue.BatteryLevel); /// /// Gets the ExposureTime exif tag. /// - public static ExifTag ExposureTime { get; } = new ExifTag(ExifTagValue.ExposureTime); + public static ExifTag ExposureTime { get; } = new(ExifTagValue.ExposureTime); /// /// Gets the FNumber exif tag. /// - public static ExifTag FNumber { get; } = new ExifTag(ExifTagValue.FNumber); + public static ExifTag FNumber { get; } = new(ExifTagValue.FNumber); /// /// Gets the MDScalePixel exif tag. /// - public static ExifTag MDScalePixel { get; } = new ExifTag(ExifTagValue.MDScalePixel); + public static ExifTag MDScalePixel { get; } = new(ExifTagValue.MDScalePixel); /// /// Gets the CompressedBitsPerPixel exif tag. /// - public static ExifTag CompressedBitsPerPixel { get; } = new ExifTag(ExifTagValue.CompressedBitsPerPixel); + public static ExifTag CompressedBitsPerPixel { get; } = new(ExifTagValue.CompressedBitsPerPixel); /// /// Gets the ApertureValue exif tag. /// - public static ExifTag ApertureValue { get; } = new ExifTag(ExifTagValue.ApertureValue); + public static ExifTag ApertureValue { get; } = new(ExifTagValue.ApertureValue); /// /// Gets the MaxApertureValue exif tag. /// - public static ExifTag MaxApertureValue { get; } = new ExifTag(ExifTagValue.MaxApertureValue); + public static ExifTag MaxApertureValue { get; } = new(ExifTagValue.MaxApertureValue); /// /// Gets the SubjectDistance exif tag. /// - public static ExifTag SubjectDistance { get; } = new ExifTag(ExifTagValue.SubjectDistance); + public static ExifTag SubjectDistance { get; } = new(ExifTagValue.SubjectDistance); /// /// Gets the FocalLength exif tag. /// - public static ExifTag FocalLength { get; } = new ExifTag(ExifTagValue.FocalLength); + public static ExifTag FocalLength { get; } = new(ExifTagValue.FocalLength); /// /// Gets the FlashEnergy2 exif tag. /// - public static ExifTag FlashEnergy2 { get; } = new ExifTag(ExifTagValue.FlashEnergy2); + public static ExifTag FlashEnergy2 { get; } = new(ExifTagValue.FlashEnergy2); /// /// Gets the FocalPlaneXResolution2 exif tag. /// - public static ExifTag FocalPlaneXResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution2); + public static ExifTag FocalPlaneXResolution2 { get; } = new(ExifTagValue.FocalPlaneXResolution2); /// /// Gets the FocalPlaneYResolution2 exif tag. /// - public static ExifTag FocalPlaneYResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution2); + public static ExifTag FocalPlaneYResolution2 { get; } = new(ExifTagValue.FocalPlaneYResolution2); /// /// Gets the ExposureIndex2 exif tag. /// - public static ExifTag ExposureIndex2 { get; } = new ExifTag(ExifTagValue.ExposureIndex2); + public static ExifTag ExposureIndex2 { get; } = new(ExifTagValue.ExposureIndex2); /// /// Gets the Humidity exif tag. /// - public static ExifTag Humidity { get; } = new ExifTag(ExifTagValue.Humidity); + public static ExifTag Humidity { get; } = new(ExifTagValue.Humidity); /// /// Gets the Pressure exif tag. /// - public static ExifTag Pressure { get; } = new ExifTag(ExifTagValue.Pressure); + public static ExifTag Pressure { get; } = new(ExifTagValue.Pressure); /// /// Gets the Acceleration exif tag. /// - public static ExifTag Acceleration { get; } = new ExifTag(ExifTagValue.Acceleration); + public static ExifTag Acceleration { get; } = new(ExifTagValue.Acceleration); /// /// Gets the FlashEnergy exif tag. /// - public static ExifTag FlashEnergy { get; } = new ExifTag(ExifTagValue.FlashEnergy); + public static ExifTag FlashEnergy { get; } = new(ExifTagValue.FlashEnergy); /// /// Gets the FocalPlaneXResolution exif tag. /// - public static ExifTag FocalPlaneXResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution); + public static ExifTag FocalPlaneXResolution { get; } = new(ExifTagValue.FocalPlaneXResolution); /// /// Gets the FocalPlaneYResolution exif tag. /// - public static ExifTag FocalPlaneYResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution); + public static ExifTag FocalPlaneYResolution { get; } = new(ExifTagValue.FocalPlaneYResolution); /// /// Gets the ExposureIndex exif tag. /// - public static ExifTag ExposureIndex { get; } = new ExifTag(ExifTagValue.ExposureIndex); + public static ExifTag ExposureIndex { get; } = new(ExifTagValue.ExposureIndex); /// /// Gets the DigitalZoomRatio exif tag. /// - public static ExifTag DigitalZoomRatio { get; } = new ExifTag(ExifTagValue.DigitalZoomRatio); + public static ExifTag DigitalZoomRatio { get; } = new(ExifTagValue.DigitalZoomRatio); /// /// Gets the GPSAltitude exif tag. /// - public static ExifTag GPSAltitude { get; } = new ExifTag(ExifTagValue.GPSAltitude); + public static ExifTag GPSAltitude { get; } = new(ExifTagValue.GPSAltitude); /// /// Gets the GPSDOP exif tag. /// - public static ExifTag GPSDOP { get; } = new ExifTag(ExifTagValue.GPSDOP); + public static ExifTag GPSDOP { get; } = new(ExifTagValue.GPSDOP); /// /// Gets the GPSSpeed exif tag. /// - public static ExifTag GPSSpeed { get; } = new ExifTag(ExifTagValue.GPSSpeed); + public static ExifTag GPSSpeed { get; } = new(ExifTagValue.GPSSpeed); /// /// Gets the GPSTrack exif tag. /// - public static ExifTag GPSTrack { get; } = new ExifTag(ExifTagValue.GPSTrack); + public static ExifTag GPSTrack { get; } = new(ExifTagValue.GPSTrack); /// /// Gets the GPSImgDirection exif tag. /// - public static ExifTag GPSImgDirection { get; } = new ExifTag(ExifTagValue.GPSImgDirection); + public static ExifTag GPSImgDirection { get; } = new(ExifTagValue.GPSImgDirection); /// /// Gets the GPSDestBearing exif tag. /// - public static ExifTag GPSDestBearing { get; } = new ExifTag(ExifTagValue.GPSDestBearing); + public static ExifTag GPSDestBearing { get; } = new(ExifTagValue.GPSDestBearing); /// /// Gets the GPSDestDistance exif tag. /// - public static ExifTag GPSDestDistance { get; } = new ExifTag(ExifTagValue.GPSDestDistance); + public static ExifTag GPSDestDistance { get; } = new(ExifTagValue.GPSDestDistance); /// /// Gets the GPSHPositioningError exif tag. /// - public static ExifTag GPSHPositioningError { get; } = new ExifTag(ExifTagValue.GPSHPositioningError); + public static ExifTag GPSHPositioningError { get; } = new(ExifTagValue.GPSHPositioningError); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs index 8b764c3f7..4ba140441 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs @@ -9,50 +9,50 @@ public abstract partial class ExifTag /// /// Gets the WhitePoint exif tag. /// - public static ExifTag WhitePoint { get; } = new ExifTag(ExifTagValue.WhitePoint); + public static ExifTag WhitePoint { get; } = new(ExifTagValue.WhitePoint); /// /// Gets the PrimaryChromaticities exif tag. /// - public static ExifTag PrimaryChromaticities { get; } = new ExifTag(ExifTagValue.PrimaryChromaticities); + public static ExifTag PrimaryChromaticities { get; } = new(ExifTagValue.PrimaryChromaticities); /// /// Gets the YCbCrCoefficients exif tag. /// - public static ExifTag YCbCrCoefficients { get; } = new ExifTag(ExifTagValue.YCbCrCoefficients); + public static ExifTag YCbCrCoefficients { get; } = new(ExifTagValue.YCbCrCoefficients); /// /// Gets the ReferenceBlackWhite exif tag. /// - public static ExifTag ReferenceBlackWhite { get; } = new ExifTag(ExifTagValue.ReferenceBlackWhite); + public static ExifTag ReferenceBlackWhite { get; } = new(ExifTagValue.ReferenceBlackWhite); /// /// Gets the GPSLatitude exif tag. /// - public static ExifTag GPSLatitude { get; } = new ExifTag(ExifTagValue.GPSLatitude); + public static ExifTag GPSLatitude { get; } = new(ExifTagValue.GPSLatitude); /// /// Gets the GPSLongitude exif tag. /// - public static ExifTag GPSLongitude { get; } = new ExifTag(ExifTagValue.GPSLongitude); + public static ExifTag GPSLongitude { get; } = new(ExifTagValue.GPSLongitude); /// /// Gets the GPSTimestamp exif tag. /// - public static ExifTag GPSTimestamp { get; } = new ExifTag(ExifTagValue.GPSTimestamp); + public static ExifTag GPSTimestamp { get; } = new(ExifTagValue.GPSTimestamp); /// /// Gets the GPSDestLatitude exif tag. /// - public static ExifTag GPSDestLatitude { get; } = new ExifTag(ExifTagValue.GPSDestLatitude); + public static ExifTag GPSDestLatitude { get; } = new(ExifTagValue.GPSDestLatitude); /// /// Gets the GPSDestLongitude exif tag. /// - public static ExifTag GPSDestLongitude { get; } = new ExifTag(ExifTagValue.GPSDestLongitude); + public static ExifTag GPSDestLongitude { get; } = new(ExifTagValue.GPSDestLongitude); /// /// Gets the LensSpecification exif tag. /// - public static ExifTag LensSpecification { get; } = new ExifTag(ExifTagValue.LensSpecification); + public static ExifTag LensSpecification { get; } = new(ExifTagValue.LensSpecification); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs index aeeda58bb..52972811e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs @@ -9,235 +9,235 @@ public abstract partial class ExifTag /// /// Gets the OldSubfileType exif tag. /// - public static ExifTag OldSubfileType { get; } = new ExifTag(ExifTagValue.OldSubfileType); + public static ExifTag OldSubfileType { get; } = new(ExifTagValue.OldSubfileType); /// /// Gets the Compression exif tag. /// - public static ExifTag Compression { get; } = new ExifTag(ExifTagValue.Compression); + public static ExifTag Compression { get; } = new(ExifTagValue.Compression); /// /// Gets the PhotometricInterpretation exif tag. /// - public static ExifTag PhotometricInterpretation { get; } = new ExifTag(ExifTagValue.PhotometricInterpretation); + public static ExifTag PhotometricInterpretation { get; } = new(ExifTagValue.PhotometricInterpretation); /// /// Gets the Thresholding exif tag. /// - public static ExifTag Thresholding { get; } = new ExifTag(ExifTagValue.Thresholding); + public static ExifTag Thresholding { get; } = new(ExifTagValue.Thresholding); /// /// Gets the CellWidth exif tag. /// - public static ExifTag CellWidth { get; } = new ExifTag(ExifTagValue.CellWidth); + public static ExifTag CellWidth { get; } = new(ExifTagValue.CellWidth); /// /// Gets the CellLength exif tag. /// - public static ExifTag CellLength { get; } = new ExifTag(ExifTagValue.CellLength); + public static ExifTag CellLength { get; } = new(ExifTagValue.CellLength); /// /// Gets the FillOrder exif tag. /// - public static ExifTag FillOrder { get; } = new ExifTag(ExifTagValue.FillOrder); + public static ExifTag FillOrder { get; } = new(ExifTagValue.FillOrder); /// /// Gets the Orientation exif tag. /// - public static ExifTag Orientation { get; } = new ExifTag(ExifTagValue.Orientation); + public static ExifTag Orientation { get; } = new(ExifTagValue.Orientation); /// /// Gets the SamplesPerPixel exif tag. /// - public static ExifTag SamplesPerPixel { get; } = new ExifTag(ExifTagValue.SamplesPerPixel); + public static ExifTag SamplesPerPixel { get; } = new(ExifTagValue.SamplesPerPixel); /// /// Gets the PlanarConfiguration exif tag. /// - public static ExifTag PlanarConfiguration { get; } = new ExifTag(ExifTagValue.PlanarConfiguration); + public static ExifTag PlanarConfiguration { get; } = new(ExifTagValue.PlanarConfiguration); /// /// Gets the Predictor exif tag. /// - public static ExifTag Predictor { get; } = new ExifTag(ExifTagValue.Predictor); + public static ExifTag Predictor { get; } = new(ExifTagValue.Predictor); /// /// Gets the GrayResponseUnit exif tag. /// - public static ExifTag GrayResponseUnit { get; } = new ExifTag(ExifTagValue.GrayResponseUnit); + public static ExifTag GrayResponseUnit { get; } = new(ExifTagValue.GrayResponseUnit); /// /// Gets the ResolutionUnit exif tag. /// - public static ExifTag ResolutionUnit { get; } = new ExifTag(ExifTagValue.ResolutionUnit); + public static ExifTag ResolutionUnit { get; } = new(ExifTagValue.ResolutionUnit); /// /// Gets the CleanFaxData exif tag. /// - public static ExifTag CleanFaxData { get; } = new ExifTag(ExifTagValue.CleanFaxData); + public static ExifTag CleanFaxData { get; } = new(ExifTagValue.CleanFaxData); /// /// Gets the InkSet exif tag. /// - public static ExifTag InkSet { get; } = new ExifTag(ExifTagValue.InkSet); + public static ExifTag InkSet { get; } = new(ExifTagValue.InkSet); /// /// Gets the NumberOfInks exif tag. /// - public static ExifTag NumberOfInks { get; } = new ExifTag(ExifTagValue.NumberOfInks); + public static ExifTag NumberOfInks { get; } = new(ExifTagValue.NumberOfInks); /// /// Gets the DotRange exif tag. /// - public static ExifTag DotRange { get; } = new ExifTag(ExifTagValue.DotRange); + public static ExifTag DotRange { get; } = new(ExifTagValue.DotRange); /// /// Gets the Indexed exif tag. /// - public static ExifTag Indexed { get; } = new ExifTag(ExifTagValue.Indexed); + public static ExifTag Indexed { get; } = new(ExifTagValue.Indexed); /// /// Gets the OPIProxy exif tag. /// - public static ExifTag OPIProxy { get; } = new ExifTag(ExifTagValue.OPIProxy); + public static ExifTag OPIProxy { get; } = new(ExifTagValue.OPIProxy); /// /// Gets the JPEGProc exif tag. /// - public static ExifTag JPEGProc { get; } = new ExifTag(ExifTagValue.JPEGProc); + public static ExifTag JPEGProc { get; } = new(ExifTagValue.JPEGProc); /// /// Gets the JPEGRestartInterval exif tag. /// - public static ExifTag JPEGRestartInterval { get; } = new ExifTag(ExifTagValue.JPEGRestartInterval); + public static ExifTag JPEGRestartInterval { get; } = new(ExifTagValue.JPEGRestartInterval); /// /// Gets the YCbCrPositioning exif tag. /// - public static ExifTag YCbCrPositioning { get; } = new ExifTag(ExifTagValue.YCbCrPositioning); + public static ExifTag YCbCrPositioning { get; } = new(ExifTagValue.YCbCrPositioning); /// /// Gets the Rating exif tag. /// - public static ExifTag Rating { get; } = new ExifTag(ExifTagValue.Rating); + public static ExifTag Rating { get; } = new(ExifTagValue.Rating); /// /// Gets the RatingPercent exif tag. /// - public static ExifTag RatingPercent { get; } = new ExifTag(ExifTagValue.RatingPercent); + public static ExifTag RatingPercent { get; } = new(ExifTagValue.RatingPercent); /// /// Gets the ExposureProgram exif tag. /// - public static ExifTag ExposureProgram { get; } = new ExifTag(ExifTagValue.ExposureProgram); + public static ExifTag ExposureProgram { get; } = new(ExifTagValue.ExposureProgram); /// /// Gets the Interlace exif tag. /// - public static ExifTag Interlace { get; } = new ExifTag(ExifTagValue.Interlace); + public static ExifTag Interlace { get; } = new(ExifTagValue.Interlace); /// /// Gets the SelfTimerMode exif tag. /// - public static ExifTag SelfTimerMode { get; } = new ExifTag(ExifTagValue.SelfTimerMode); + public static ExifTag SelfTimerMode { get; } = new(ExifTagValue.SelfTimerMode); /// /// Gets the SensitivityType exif tag. /// - public static ExifTag SensitivityType { get; } = new ExifTag(ExifTagValue.SensitivityType); + public static ExifTag SensitivityType { get; } = new(ExifTagValue.SensitivityType); /// /// Gets the MeteringMode exif tag. /// - public static ExifTag MeteringMode { get; } = new ExifTag(ExifTagValue.MeteringMode); + public static ExifTag MeteringMode { get; } = new(ExifTagValue.MeteringMode); /// /// Gets the LightSource exif tag. /// - public static ExifTag LightSource { get; } = new ExifTag(ExifTagValue.LightSource); + public static ExifTag LightSource { get; } = new(ExifTagValue.LightSource); /// /// Gets the FocalPlaneResolutionUnit2 exif tag. /// - public static ExifTag FocalPlaneResolutionUnit2 { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit2); + public static ExifTag FocalPlaneResolutionUnit2 { get; } = new(ExifTagValue.FocalPlaneResolutionUnit2); /// /// Gets the SensingMethod2 exif tag. /// - public static ExifTag SensingMethod2 { get; } = new ExifTag(ExifTagValue.SensingMethod2); + public static ExifTag SensingMethod2 { get; } = new(ExifTagValue.SensingMethod2); /// /// Gets the Flash exif tag. /// - public static ExifTag Flash { get; } = new ExifTag(ExifTagValue.Flash); + public static ExifTag Flash { get; } = new(ExifTagValue.Flash); /// /// Gets the ColorSpace exif tag. /// - public static ExifTag ColorSpace { get; } = new ExifTag(ExifTagValue.ColorSpace); + public static ExifTag ColorSpace { get; } = new(ExifTagValue.ColorSpace); /// /// Gets the FocalPlaneResolutionUnit exif tag. /// - public static ExifTag FocalPlaneResolutionUnit { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit); + public static ExifTag FocalPlaneResolutionUnit { get; } = new(ExifTagValue.FocalPlaneResolutionUnit); /// /// Gets the SensingMethod exif tag. /// - public static ExifTag SensingMethod { get; } = new ExifTag(ExifTagValue.SensingMethod); + public static ExifTag SensingMethod { get; } = new(ExifTagValue.SensingMethod); /// /// Gets the CustomRendered exif tag. /// - public static ExifTag CustomRendered { get; } = new ExifTag(ExifTagValue.CustomRendered); + public static ExifTag CustomRendered { get; } = new(ExifTagValue.CustomRendered); /// /// Gets the ExposureMode exif tag. /// - public static ExifTag ExposureMode { get; } = new ExifTag(ExifTagValue.ExposureMode); + public static ExifTag ExposureMode { get; } = new(ExifTagValue.ExposureMode); /// /// Gets the WhiteBalance exif tag. /// - public static ExifTag WhiteBalance { get; } = new ExifTag(ExifTagValue.WhiteBalance); + public static ExifTag WhiteBalance { get; } = new(ExifTagValue.WhiteBalance); /// /// Gets the FocalLengthIn35mmFilm exif tag. /// - public static ExifTag FocalLengthIn35mmFilm { get; } = new ExifTag(ExifTagValue.FocalLengthIn35mmFilm); + public static ExifTag FocalLengthIn35mmFilm { get; } = new(ExifTagValue.FocalLengthIn35mmFilm); /// /// Gets the SceneCaptureType exif tag. /// - public static ExifTag SceneCaptureType { get; } = new ExifTag(ExifTagValue.SceneCaptureType); + public static ExifTag SceneCaptureType { get; } = new(ExifTagValue.SceneCaptureType); /// /// Gets the GainControl exif tag. /// - public static ExifTag GainControl { get; } = new ExifTag(ExifTagValue.GainControl); + public static ExifTag GainControl { get; } = new(ExifTagValue.GainControl); /// /// Gets the Contrast exif tag. /// - public static ExifTag Contrast { get; } = new ExifTag(ExifTagValue.Contrast); + public static ExifTag Contrast { get; } = new(ExifTagValue.Contrast); /// /// Gets the Saturation exif tag. /// - public static ExifTag Saturation { get; } = new ExifTag(ExifTagValue.Saturation); + public static ExifTag Saturation { get; } = new(ExifTagValue.Saturation); /// /// Gets the Sharpness exif tag. /// - public static ExifTag Sharpness { get; } = new ExifTag(ExifTagValue.Sharpness); + public static ExifTag Sharpness { get; } = new(ExifTagValue.Sharpness); /// /// Gets the SubjectDistanceRange exif tag. /// - public static ExifTag SubjectDistanceRange { get; } = new ExifTag(ExifTagValue.SubjectDistanceRange); + public static ExifTag SubjectDistanceRange { get; } = new(ExifTagValue.SubjectDistanceRange); /// /// Gets the GPSDifferential exif tag. /// - public static ExifTag GPSDifferential { get; } = new ExifTag(ExifTagValue.GPSDifferential); + public static ExifTag GPSDifferential { get; } = new(ExifTagValue.GPSDifferential); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs index dc708c50f..55e65517f 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs @@ -9,100 +9,100 @@ public abstract partial class ExifTag /// /// Gets the BitsPerSample exif tag. /// - public static ExifTag BitsPerSample { get; } = new ExifTag(ExifTagValue.BitsPerSample); + public static ExifTag BitsPerSample { get; } = new(ExifTagValue.BitsPerSample); /// /// Gets the MinSampleValue exif tag. /// - public static ExifTag MinSampleValue { get; } = new ExifTag(ExifTagValue.MinSampleValue); + public static ExifTag MinSampleValue { get; } = new(ExifTagValue.MinSampleValue); /// /// Gets the MaxSampleValue exif tag. /// - public static ExifTag MaxSampleValue { get; } = new ExifTag(ExifTagValue.MaxSampleValue); + public static ExifTag MaxSampleValue { get; } = new(ExifTagValue.MaxSampleValue); /// /// Gets the GrayResponseCurve exif tag. /// - public static ExifTag GrayResponseCurve { get; } = new ExifTag(ExifTagValue.GrayResponseCurve); + public static ExifTag GrayResponseCurve { get; } = new(ExifTagValue.GrayResponseCurve); /// /// Gets the ColorMap exif tag. /// - public static ExifTag ColorMap { get; } = new ExifTag(ExifTagValue.ColorMap); + public static ExifTag ColorMap { get; } = new(ExifTagValue.ColorMap); /// /// Gets the ExtraSamples exif tag. /// - public static ExifTag ExtraSamples { get; } = new ExifTag(ExifTagValue.ExtraSamples); + public static ExifTag ExtraSamples { get; } = new(ExifTagValue.ExtraSamples); /// /// Gets the PageNumber exif tag. /// - public static ExifTag PageNumber { get; } = new ExifTag(ExifTagValue.PageNumber); + public static ExifTag PageNumber { get; } = new(ExifTagValue.PageNumber); /// /// Gets the TransferFunction exif tag. /// - public static ExifTag TransferFunction { get; } = new ExifTag(ExifTagValue.TransferFunction); + public static ExifTag TransferFunction { get; } = new(ExifTagValue.TransferFunction); /// /// Gets the HalftoneHints exif tag. /// - public static ExifTag HalftoneHints { get; } = new ExifTag(ExifTagValue.HalftoneHints); + public static ExifTag HalftoneHints { get; } = new(ExifTagValue.HalftoneHints); /// /// Gets the SampleFormat exif tag. /// - public static ExifTag SampleFormat { get; } = new ExifTag(ExifTagValue.SampleFormat); + public static ExifTag SampleFormat { get; } = new(ExifTagValue.SampleFormat); /// /// Gets the TransferRange exif tag. /// - public static ExifTag TransferRange { get; } = new ExifTag(ExifTagValue.TransferRange); + public static ExifTag TransferRange { get; } = new(ExifTagValue.TransferRange); /// /// Gets the DefaultImageColor exif tag. /// - public static ExifTag DefaultImageColor { get; } = new ExifTag(ExifTagValue.DefaultImageColor); + public static ExifTag DefaultImageColor { get; } = new(ExifTagValue.DefaultImageColor); /// /// Gets the JPEGLosslessPredictors exif tag. /// - public static ExifTag JPEGLosslessPredictors { get; } = new ExifTag(ExifTagValue.JPEGLosslessPredictors); + public static ExifTag JPEGLosslessPredictors { get; } = new(ExifTagValue.JPEGLosslessPredictors); /// /// Gets the JPEGPointTransforms exif tag. /// - public static ExifTag JPEGPointTransforms { get; } = new ExifTag(ExifTagValue.JPEGPointTransforms); + public static ExifTag JPEGPointTransforms { get; } = new(ExifTagValue.JPEGPointTransforms); /// /// Gets the YCbCrSubsampling exif tag. /// - public static ExifTag YCbCrSubsampling { get; } = new ExifTag(ExifTagValue.YCbCrSubsampling); + public static ExifTag YCbCrSubsampling { get; } = new(ExifTagValue.YCbCrSubsampling); /// /// Gets the CFARepeatPatternDim exif tag. /// - public static ExifTag CFARepeatPatternDim { get; } = new ExifTag(ExifTagValue.CFARepeatPatternDim); + public static ExifTag CFARepeatPatternDim { get; } = new(ExifTagValue.CFARepeatPatternDim); /// /// Gets the IntergraphPacketData exif tag. /// - public static ExifTag IntergraphPacketData { get; } = new ExifTag(ExifTagValue.IntergraphPacketData); + public static ExifTag IntergraphPacketData { get; } = new(ExifTagValue.IntergraphPacketData); /// /// Gets the ISOSpeedRatings exif tag. /// - public static ExifTag ISOSpeedRatings { get; } = new ExifTag(ExifTagValue.ISOSpeedRatings); + public static ExifTag ISOSpeedRatings { get; } = new(ExifTagValue.ISOSpeedRatings); /// /// Gets the SubjectArea exif tag. /// - public static ExifTag SubjectArea { get; } = new ExifTag(ExifTagValue.SubjectArea); + public static ExifTag SubjectArea { get; } = new(ExifTagValue.SubjectArea); /// /// Gets the SubjectLocation exif tag. /// - public static ExifTag SubjectLocation { get; } = new ExifTag(ExifTagValue.SubjectLocation); + public static ExifTag SubjectLocation { get; } = new(ExifTagValue.SubjectLocation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs index d645b5176..8fbbba217 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs @@ -9,30 +9,30 @@ public abstract partial class ExifTag /// /// Gets the ShutterSpeedValue exif tag. /// - public static ExifTag ShutterSpeedValue { get; } = new ExifTag(ExifTagValue.ShutterSpeedValue); + public static ExifTag ShutterSpeedValue { get; } = new(ExifTagValue.ShutterSpeedValue); /// /// Gets the BrightnessValue exif tag. /// - public static ExifTag BrightnessValue { get; } = new ExifTag(ExifTagValue.BrightnessValue); + public static ExifTag BrightnessValue { get; } = new(ExifTagValue.BrightnessValue); /// /// Gets the ExposureBiasValue exif tag. /// - public static ExifTag ExposureBiasValue { get; } = new ExifTag(ExifTagValue.ExposureBiasValue); + public static ExifTag ExposureBiasValue { get; } = new(ExifTagValue.ExposureBiasValue); /// /// Gets the AmbientTemperature exif tag. /// - public static ExifTag AmbientTemperature { get; } = new ExifTag(ExifTagValue.AmbientTemperature); + public static ExifTag AmbientTemperature { get; } = new(ExifTagValue.AmbientTemperature); /// /// Gets the WaterDepth exif tag. /// - public static ExifTag WaterDepth { get; } = new ExifTag(ExifTagValue.WaterDepth); + public static ExifTag WaterDepth { get; } = new(ExifTagValue.WaterDepth); /// /// Gets the CameraElevationAngle exif tag. /// - public static ExifTag CameraElevationAngle { get; } = new ExifTag(ExifTagValue.CameraElevationAngle); + public static ExifTag CameraElevationAngle { get; } = new(ExifTagValue.CameraElevationAngle); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs index ef1e8afea..a27108f8a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the Decode exif tag. /// - public static ExifTag Decode { get; } = new ExifTag(ExifTagValue.Decode); + public static ExifTag Decode { get; } = new(ExifTagValue.Decode); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs index d6a920514..086842698 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the TimeZoneOffset exif tag. /// - public static ExifTag TimeZoneOffset { get; } = new ExifTag(ExifTagValue.TimeZoneOffset); + public static ExifTag TimeZoneOffset { get; } = new(ExifTagValue.TimeZoneOffset); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs index 498dad3eb..688403a65 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs @@ -9,270 +9,270 @@ public abstract partial class ExifTag /// /// Gets the ImageDescription exif tag. /// - public static ExifTag ImageDescription { get; } = new ExifTag(ExifTagValue.ImageDescription); + public static ExifTag ImageDescription { get; } = new(ExifTagValue.ImageDescription); /// /// Gets the Make exif tag. /// - public static ExifTag Make { get; } = new ExifTag(ExifTagValue.Make); + public static ExifTag Make { get; } = new(ExifTagValue.Make); /// /// Gets the Model exif tag. /// - public static ExifTag Model { get; } = new ExifTag(ExifTagValue.Model); + public static ExifTag Model { get; } = new(ExifTagValue.Model); /// /// Gets the Software exif tag. /// - public static ExifTag Software { get; } = new ExifTag(ExifTagValue.Software); + public static ExifTag Software { get; } = new(ExifTagValue.Software); /// /// Gets the DateTime exif tag. /// - public static ExifTag DateTime { get; } = new ExifTag(ExifTagValue.DateTime); + public static ExifTag DateTime { get; } = new(ExifTagValue.DateTime); /// /// Gets the Artist exif tag. /// - public static ExifTag Artist { get; } = new ExifTag(ExifTagValue.Artist); + public static ExifTag Artist { get; } = new(ExifTagValue.Artist); /// /// Gets the HostComputer exif tag. /// - public static ExifTag HostComputer { get; } = new ExifTag(ExifTagValue.HostComputer); + public static ExifTag HostComputer { get; } = new(ExifTagValue.HostComputer); /// /// Gets the Copyright exif tag. /// - public static ExifTag Copyright { get; } = new ExifTag(ExifTagValue.Copyright); + public static ExifTag Copyright { get; } = new(ExifTagValue.Copyright); /// /// Gets the DocumentName exif tag. /// - public static ExifTag DocumentName { get; } = new ExifTag(ExifTagValue.DocumentName); + public static ExifTag DocumentName { get; } = new(ExifTagValue.DocumentName); /// /// Gets the PageName exif tag. /// - public static ExifTag PageName { get; } = new ExifTag(ExifTagValue.PageName); + public static ExifTag PageName { get; } = new(ExifTagValue.PageName); /// /// Gets the InkNames exif tag. /// - public static ExifTag InkNames { get; } = new ExifTag(ExifTagValue.InkNames); + public static ExifTag InkNames { get; } = new(ExifTagValue.InkNames); /// /// Gets the TargetPrinter exif tag. /// - public static ExifTag TargetPrinter { get; } = new ExifTag(ExifTagValue.TargetPrinter); + public static ExifTag TargetPrinter { get; } = new(ExifTagValue.TargetPrinter); /// /// Gets the ImageID exif tag. /// - public static ExifTag ImageID { get; } = new ExifTag(ExifTagValue.ImageID); + public static ExifTag ImageID { get; } = new(ExifTagValue.ImageID); /// /// Gets the MDLabName exif tag. /// - public static ExifTag MDLabName { get; } = new ExifTag(ExifTagValue.MDLabName); + public static ExifTag MDLabName { get; } = new(ExifTagValue.MDLabName); /// /// Gets the MDSampleInfo exif tag. /// - public static ExifTag MDSampleInfo { get; } = new ExifTag(ExifTagValue.MDSampleInfo); + public static ExifTag MDSampleInfo { get; } = new(ExifTagValue.MDSampleInfo); /// /// Gets the MDPrepDate exif tag. /// - public static ExifTag MDPrepDate { get; } = new ExifTag(ExifTagValue.MDPrepDate); + public static ExifTag MDPrepDate { get; } = new(ExifTagValue.MDPrepDate); /// /// Gets the MDPrepTime exif tag. /// - public static ExifTag MDPrepTime { get; } = new ExifTag(ExifTagValue.MDPrepTime); + public static ExifTag MDPrepTime { get; } = new(ExifTagValue.MDPrepTime); /// /// Gets the MDFileUnits exif tag. /// - public static ExifTag MDFileUnits { get; } = new ExifTag(ExifTagValue.MDFileUnits); + public static ExifTag MDFileUnits { get; } = new(ExifTagValue.MDFileUnits); /// /// Gets the SEMInfo exif tag. /// - public static ExifTag SEMInfo { get; } = new ExifTag(ExifTagValue.SEMInfo); + public static ExifTag SEMInfo { get; } = new(ExifTagValue.SEMInfo); /// /// Gets the SpectralSensitivity exif tag. /// - public static ExifTag SpectralSensitivity { get; } = new ExifTag(ExifTagValue.SpectralSensitivity); + public static ExifTag SpectralSensitivity { get; } = new(ExifTagValue.SpectralSensitivity); /// /// Gets the DateTimeOriginal exif tag. /// - public static ExifTag DateTimeOriginal { get; } = new ExifTag(ExifTagValue.DateTimeOriginal); + public static ExifTag DateTimeOriginal { get; } = new(ExifTagValue.DateTimeOriginal); /// /// Gets the DateTimeDigitized exif tag. /// - public static ExifTag DateTimeDigitized { get; } = new ExifTag(ExifTagValue.DateTimeDigitized); + public static ExifTag DateTimeDigitized { get; } = new(ExifTagValue.DateTimeDigitized); /// /// Gets the SubsecTime exif tag. /// - public static ExifTag SubsecTime { get; } = new ExifTag(ExifTagValue.SubsecTime); + public static ExifTag SubsecTime { get; } = new(ExifTagValue.SubsecTime); /// /// Gets the SubsecTimeOriginal exif tag. /// - public static ExifTag SubsecTimeOriginal { get; } = new ExifTag(ExifTagValue.SubsecTimeOriginal); + public static ExifTag SubsecTimeOriginal { get; } = new(ExifTagValue.SubsecTimeOriginal); /// /// Gets the SubsecTimeDigitized exif tag. /// - public static ExifTag SubsecTimeDigitized { get; } = new ExifTag(ExifTagValue.SubsecTimeDigitized); + public static ExifTag SubsecTimeDigitized { get; } = new(ExifTagValue.SubsecTimeDigitized); /// /// Gets the RelatedSoundFile exif tag. /// - public static ExifTag RelatedSoundFile { get; } = new ExifTag(ExifTagValue.RelatedSoundFile); + public static ExifTag RelatedSoundFile { get; } = new(ExifTagValue.RelatedSoundFile); /// /// Gets the FaxSubaddress exif tag. /// - public static ExifTag FaxSubaddress { get; } = new ExifTag(ExifTagValue.FaxSubaddress); + public static ExifTag FaxSubaddress { get; } = new(ExifTagValue.FaxSubaddress); /// /// Gets the OffsetTime exif tag. /// - public static ExifTag OffsetTime { get; } = new ExifTag(ExifTagValue.OffsetTime); + public static ExifTag OffsetTime { get; } = new(ExifTagValue.OffsetTime); /// /// Gets the OffsetTimeOriginal exif tag. /// - public static ExifTag OffsetTimeOriginal { get; } = new ExifTag(ExifTagValue.OffsetTimeOriginal); + public static ExifTag OffsetTimeOriginal { get; } = new(ExifTagValue.OffsetTimeOriginal); /// /// Gets the OffsetTimeDigitized exif tag. /// - public static ExifTag OffsetTimeDigitized { get; } = new ExifTag(ExifTagValue.OffsetTimeDigitized); + public static ExifTag OffsetTimeDigitized { get; } = new(ExifTagValue.OffsetTimeDigitized); /// /// Gets the SecurityClassification exif tag. /// - public static ExifTag SecurityClassification { get; } = new ExifTag(ExifTagValue.SecurityClassification); + public static ExifTag SecurityClassification { get; } = new(ExifTagValue.SecurityClassification); /// /// Gets the ImageHistory exif tag. /// - public static ExifTag ImageHistory { get; } = new ExifTag(ExifTagValue.ImageHistory); + public static ExifTag ImageHistory { get; } = new(ExifTagValue.ImageHistory); /// /// Gets the ImageUniqueID exif tag. /// - public static ExifTag ImageUniqueID { get; } = new ExifTag(ExifTagValue.ImageUniqueID); + public static ExifTag ImageUniqueID { get; } = new(ExifTagValue.ImageUniqueID); /// /// Gets the OwnerName exif tag. /// - public static ExifTag OwnerName { get; } = new ExifTag(ExifTagValue.OwnerName); + public static ExifTag OwnerName { get; } = new(ExifTagValue.OwnerName); /// /// Gets the SerialNumber exif tag. /// - public static ExifTag SerialNumber { get; } = new ExifTag(ExifTagValue.SerialNumber); + public static ExifTag SerialNumber { get; } = new(ExifTagValue.SerialNumber); /// /// Gets the LensMake exif tag. /// - public static ExifTag LensMake { get; } = new ExifTag(ExifTagValue.LensMake); + public static ExifTag LensMake { get; } = new(ExifTagValue.LensMake); /// /// Gets the LensModel exif tag. /// - public static ExifTag LensModel { get; } = new ExifTag(ExifTagValue.LensModel); + public static ExifTag LensModel { get; } = new(ExifTagValue.LensModel); /// /// Gets the LensSerialNumber exif tag. /// - public static ExifTag LensSerialNumber { get; } = new ExifTag(ExifTagValue.LensSerialNumber); + public static ExifTag LensSerialNumber { get; } = new(ExifTagValue.LensSerialNumber); /// /// Gets the GDALMetadata exif tag. /// - public static ExifTag GDALMetadata { get; } = new ExifTag(ExifTagValue.GDALMetadata); + public static ExifTag GDALMetadata { get; } = new(ExifTagValue.GDALMetadata); /// /// Gets the GDALNoData exif tag. /// - public static ExifTag GDALNoData { get; } = new ExifTag(ExifTagValue.GDALNoData); + public static ExifTag GDALNoData { get; } = new(ExifTagValue.GDALNoData); /// /// Gets the GPSLatitudeRef exif tag. /// - public static ExifTag GPSLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSLatitudeRef); + public static ExifTag GPSLatitudeRef { get; } = new(ExifTagValue.GPSLatitudeRef); /// /// Gets the GPSLongitudeRef exif tag. /// - public static ExifTag GPSLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSLongitudeRef); + public static ExifTag GPSLongitudeRef { get; } = new(ExifTagValue.GPSLongitudeRef); /// /// Gets the GPSSatellites exif tag. /// - public static ExifTag GPSSatellites { get; } = new ExifTag(ExifTagValue.GPSSatellites); + public static ExifTag GPSSatellites { get; } = new(ExifTagValue.GPSSatellites); /// /// Gets the GPSStatus exif tag. /// - public static ExifTag GPSStatus { get; } = new ExifTag(ExifTagValue.GPSStatus); + public static ExifTag GPSStatus { get; } = new(ExifTagValue.GPSStatus); /// /// Gets the GPSMeasureMode exif tag. /// - public static ExifTag GPSMeasureMode { get; } = new ExifTag(ExifTagValue.GPSMeasureMode); + public static ExifTag GPSMeasureMode { get; } = new(ExifTagValue.GPSMeasureMode); /// /// Gets the GPSSpeedRef exif tag. /// - public static ExifTag GPSSpeedRef { get; } = new ExifTag(ExifTagValue.GPSSpeedRef); + public static ExifTag GPSSpeedRef { get; } = new(ExifTagValue.GPSSpeedRef); /// /// Gets the GPSTrackRef exif tag. /// - public static ExifTag GPSTrackRef { get; } = new ExifTag(ExifTagValue.GPSTrackRef); + public static ExifTag GPSTrackRef { get; } = new(ExifTagValue.GPSTrackRef); /// /// Gets the GPSImgDirectionRef exif tag. /// - public static ExifTag GPSImgDirectionRef { get; } = new ExifTag(ExifTagValue.GPSImgDirectionRef); + public static ExifTag GPSImgDirectionRef { get; } = new(ExifTagValue.GPSImgDirectionRef); /// /// Gets the GPSMapDatum exif tag. /// - public static ExifTag GPSMapDatum { get; } = new ExifTag(ExifTagValue.GPSMapDatum); + public static ExifTag GPSMapDatum { get; } = new(ExifTagValue.GPSMapDatum); /// /// Gets the GPSDestLatitudeRef exif tag. /// - public static ExifTag GPSDestLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLatitudeRef); + public static ExifTag GPSDestLatitudeRef { get; } = new(ExifTagValue.GPSDestLatitudeRef); /// /// Gets the GPSDestLongitudeRef exif tag. /// - public static ExifTag GPSDestLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLongitudeRef); + public static ExifTag GPSDestLongitudeRef { get; } = new(ExifTagValue.GPSDestLongitudeRef); /// /// Gets the GPSDestBearingRef exif tag. /// - public static ExifTag GPSDestBearingRef { get; } = new ExifTag(ExifTagValue.GPSDestBearingRef); + public static ExifTag GPSDestBearingRef { get; } = new(ExifTagValue.GPSDestBearingRef); /// /// Gets the GPSDestDistanceRef exif tag. /// - public static ExifTag GPSDestDistanceRef { get; } = new ExifTag(ExifTagValue.GPSDestDistanceRef); + public static ExifTag GPSDestDistanceRef { get; } = new(ExifTagValue.GPSDestDistanceRef); /// /// Gets the GPSDateStamp exif tag. /// - public static ExifTag GPSDateStamp { get; } = new ExifTag(ExifTagValue.GPSDateStamp); + public static ExifTag GPSDateStamp { get; } = new(ExifTagValue.GPSDateStamp); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs index 65acc4bd7..e13b3b30e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the title tag used by Windows (encoded in UCS2). /// - public static ExifTag XPTitle => new ExifTag(ExifTagValue.XPTitle); + public static ExifTag XPTitle => new(ExifTagValue.XPTitle); /// /// Gets the comment tag used by Windows (encoded in UCS2). /// - public static ExifTag XPComment => new ExifTag(ExifTagValue.XPComment); + public static ExifTag XPComment => new(ExifTagValue.XPComment); /// /// Gets the author tag used by Windows (encoded in UCS2). /// - public static ExifTag XPAuthor => new ExifTag(ExifTagValue.XPAuthor); + public static ExifTag XPAuthor => new(ExifTagValue.XPAuthor); /// /// Gets the keywords tag used by Windows (encoded in UCS2). /// - public static ExifTag XPKeywords => new ExifTag(ExifTagValue.XPKeywords); + public static ExifTag XPKeywords => new(ExifTagValue.XPKeywords); /// /// Gets the subject tag used by Windows (encoded in UCS2). /// - public static ExifTag XPSubject => new ExifTag(ExifTagValue.XPSubject); + public static ExifTag XPSubject => new(ExifTagValue.XPSubject); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs index 417673b4a..e822c2a11 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs @@ -9,70 +9,70 @@ public abstract partial class ExifTag /// /// Gets the JPEGTables exif tag. /// - public static ExifTag JPEGTables { get; } = new ExifTag(ExifTagValue.JPEGTables); + public static ExifTag JPEGTables { get; } = new(ExifTagValue.JPEGTables); /// /// Gets the OECF exif tag. /// - public static ExifTag OECF { get; } = new ExifTag(ExifTagValue.OECF); + public static ExifTag OECF { get; } = new(ExifTagValue.OECF); /// /// Gets the ExifVersion exif tag. /// - public static ExifTag ExifVersion { get; } = new ExifTag(ExifTagValue.ExifVersion); + public static ExifTag ExifVersion { get; } = new(ExifTagValue.ExifVersion); /// /// Gets the ComponentsConfiguration exif tag. /// - public static ExifTag ComponentsConfiguration { get; } = new ExifTag(ExifTagValue.ComponentsConfiguration); + public static ExifTag ComponentsConfiguration { get; } = new(ExifTagValue.ComponentsConfiguration); /// /// Gets the MakerNote exif tag. /// - public static ExifTag MakerNote { get; } = new ExifTag(ExifTagValue.MakerNote); + public static ExifTag MakerNote { get; } = new(ExifTagValue.MakerNote); /// /// Gets the FlashpixVersion exif tag. /// - public static ExifTag FlashpixVersion { get; } = new ExifTag(ExifTagValue.FlashpixVersion); + public static ExifTag FlashpixVersion { get; } = new(ExifTagValue.FlashpixVersion); /// /// Gets the SpatialFrequencyResponse exif tag. /// - public static ExifTag SpatialFrequencyResponse { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse); + public static ExifTag SpatialFrequencyResponse { get; } = new(ExifTagValue.SpatialFrequencyResponse); /// /// Gets the SpatialFrequencyResponse2 exif tag. /// - public static ExifTag SpatialFrequencyResponse2 { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse2); + public static ExifTag SpatialFrequencyResponse2 { get; } = new(ExifTagValue.SpatialFrequencyResponse2); /// /// Gets the Noise exif tag. /// - public static ExifTag Noise { get; } = new ExifTag(ExifTagValue.Noise); + public static ExifTag Noise { get; } = new(ExifTagValue.Noise); /// /// Gets the CFAPattern exif tag. /// - public static ExifTag CFAPattern { get; } = new ExifTag(ExifTagValue.CFAPattern); + public static ExifTag CFAPattern { get; } = new(ExifTagValue.CFAPattern); /// /// Gets the DeviceSettingDescription exif tag. /// - public static ExifTag DeviceSettingDescription { get; } = new ExifTag(ExifTagValue.DeviceSettingDescription); + public static ExifTag DeviceSettingDescription { get; } = new(ExifTagValue.DeviceSettingDescription); /// /// Gets the ImageSourceData exif tag. /// - public static ExifTag ImageSourceData { get; } = new ExifTag(ExifTagValue.ImageSourceData); + public static ExifTag ImageSourceData { get; } = new(ExifTagValue.ImageSourceData); /// /// Gets the FileSource exif tag. /// - public static ExifTag FileSource { get; } = new ExifTag(ExifTagValue.FileSource); + public static ExifTag FileSource { get; } = new(ExifTagValue.FileSource); /// /// Gets the ImageDescription exif tag. /// - public static ExifTag SceneType { get; } = new ExifTag(ExifTagValue.SceneType); + public static ExifTag SceneType { get; } = new(ExifTagValue.SceneType); } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 3cf66c0c1..8663ebccc 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -18,13 +18,13 @@ internal sealed partial class IccDataReader { ushort segmentCount = this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved - var breakPoints = new float[segmentCount - 1]; + float[] breakPoints = new float[segmentCount - 1]; for (int i = 0; i < breakPoints.Length; i++) { breakPoints[i] = this.ReadSingle(); } - var segments = new IccCurveSegment[segmentCount]; + IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); @@ -40,20 +40,20 @@ internal sealed partial class IccDataReader /// The read curve public IccResponseCurve ReadResponseCurve(int channelCount) { - var type = (IccCurveMeasurementEncodings)this.ReadUInt32(); - var measurement = new uint[channelCount]; + IccCurveMeasurementEncodings type = (IccCurveMeasurementEncodings)this.ReadUInt32(); + uint[] measurement = new uint[channelCount]; for (int i = 0; i < channelCount; i++) { measurement[i] = this.ReadUInt32(); } - var xyzValues = new Vector3[channelCount]; + Vector3[] xyzValues = new Vector3[channelCount]; for (int i = 0; i < channelCount; i++) { xyzValues[i] = this.ReadXyzNumber(); } - var response = new IccResponseNumber[channelCount][]; + IccResponseNumber[][] response = new IccResponseNumber[channelCount][]; for (int i = 0; i < channelCount; i++) { response[i] = new IccResponseNumber[measurement[i]]; @@ -121,7 +121,7 @@ internal sealed partial class IccDataReader /// The read segment public IccCurveSegment ReadCurveSegment() { - var signature = (IccCurveSegmentSignature)this.ReadUInt32(); + IccCurveSegmentSignature signature = (IccCurveSegmentSignature)this.ReadUInt32(); this.AddIndex(4); // 4 bytes reserved switch (signature) @@ -141,7 +141,7 @@ internal sealed partial class IccDataReader /// The read segment public IccFormulaCurveElement ReadFormulaCurveElement() { - var type = (IccFormulaCurveType)this.ReadUInt16(); + IccFormulaCurveType type = (IccFormulaCurveType)this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved float gamma, a, b, c, d, e; gamma = d = e = 0; @@ -175,7 +175,7 @@ internal sealed partial class IccDataReader public IccSampledCurveElement ReadSampledCurveElement() { uint count = this.ReadUInt32(); - var entries = new float[count]; + float[] entries = new float[count]; for (int i = 0; i < count; i++) { entries[i] = this.ReadSingle(); @@ -191,7 +191,7 @@ internal sealed partial class IccDataReader /// The curve data private IccTagDataEntry[] ReadCurves(int count) { - var tdata = new IccTagDataEntry[count]; + IccTagDataEntry[] tdata = new IccTagDataEntry[count]; for (int i = 0; i < count; i++) { IccTypeSignature type = this.ReadTagDataEntryHeader(); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index f3ce6cd79..700e43f97 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -21,7 +21,7 @@ internal sealed partial class IccDataReader /// The read LUT. public IccLut ReadLut16(int count) { - var values = new ushort[count]; + ushort[] values = new ushort[count]; for (int i = 0; i < count; i++) { values[i] = this.ReadUInt16(); @@ -41,7 +41,7 @@ internal sealed partial class IccDataReader public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) { // Grid-points are always 16 bytes long but only 0-inChCount are used. - var gridPointCount = new byte[inChannelCount]; + byte[] gridPointCount = new byte[inChannelCount]; Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount); if (!isFloat) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index 5baa90404..98b269f0b 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -48,7 +48,7 @@ internal sealed partial class IccDataReader /// The read public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount) { - var curves = new IccOneDimensionalCurve[inChannelCount]; + IccOneDimensionalCurve[] curves = new IccOneDimensionalCurve[inChannelCount]; for (int i = 0; i < inChannelCount; i++) { curves[i] = this.ReadOneDimensionalCurve(); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index d5369e5fc..58b759555 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -104,7 +104,7 @@ internal sealed partial class IccDataReader { string name = this.ReadAsciiString(32); ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; - var deviceCoord = new ushort[deviceCoordCount]; + ushort[] deviceCoord = new ushort[deviceCoordCount]; for (int i = 0; i < deviceCoordCount; i++) { @@ -122,8 +122,8 @@ internal sealed partial class IccDataReader { uint manufacturer = this.ReadUInt32(); uint model = this.ReadUInt32(); - var attributes = (IccDeviceAttribute)this.ReadInt64(); - var technologyInfo = (IccProfileTag)this.ReadUInt32(); + IccDeviceAttribute attributes = (IccDeviceAttribute)this.ReadInt64(); + IccProfileTag technologyInfo = (IccProfileTag)this.ReadUInt32(); IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = ReadText(); IccMultiLocalizedUnicodeTagDataEntry modelInfo = ReadText(); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 7a526ef1a..99dc3ce3c 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs @@ -143,7 +143,7 @@ internal sealed partial class IccDataReader /// The read bytes public byte[] ReadBytes(int count) { - var bytes = new byte[count]; + byte[] bytes = new byte[count]; Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count); return bytes; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index c1b22e82b..88281452e 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -140,7 +140,7 @@ internal sealed partial class IccDataReader public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() { ushort channelCount = this.ReadUInt16(); - var colorant = (IccColorantEncoding)this.ReadUInt16(); + IccColorantEncoding colorant = (IccColorantEncoding)this.ReadUInt16(); if (Enum.IsDefined(colorant) && colorant != IccColorantEncoding.Unknown) { @@ -179,7 +179,7 @@ internal sealed partial class IccDataReader public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() { uint colorantCount = this.ReadUInt32(); - var cdata = new IccColorantTableEntry[colorantCount]; + IccColorantTableEntry[] cdata = new IccColorantTableEntry[colorantCount]; for (int i = 0; i < colorantCount; i++) { cdata[i] = this.ReadColorantTableEntry(); @@ -239,7 +239,7 @@ internal sealed partial class IccDataReader /// Reads a /// /// The read entry. - public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() => new IccDateTimeTagDataEntry(this.ReadDateTime()); + public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() => new(this.ReadDateTime()); /// /// Reads a @@ -258,7 +258,7 @@ internal sealed partial class IccDataReader ushort outTableCount = this.ReadUInt16(); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -270,7 +270,7 @@ internal sealed partial class IccDataReader IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut16(outTableCount); @@ -293,7 +293,7 @@ internal sealed partial class IccDataReader float[,] matrix = this.ReadMatrix(3, 3, false); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -305,7 +305,7 @@ internal sealed partial class IccDataReader IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut8(); @@ -453,9 +453,9 @@ internal sealed partial class IccDataReader uint recordCount = this.ReadUInt32(); this.ReadUInt32(); // Record size (always 12) - var text = new IccLocalizedString[recordCount]; + IccLocalizedString[] text = new IccLocalizedString[recordCount]; - var culture = new CultureInfo[recordCount]; + CultureInfo[] culture = new CultureInfo[recordCount]; uint[] length = new uint[recordCount]; uint[] offset = new uint[recordCount]; @@ -520,13 +520,13 @@ internal sealed partial class IccDataReader this.ReadUInt16(); uint elementCount = this.ReadUInt32(); - var positionTable = new IccPositionNumber[elementCount]; + IccPositionNumber[] positionTable = new IccPositionNumber[elementCount]; for (int i = 0; i < elementCount; i++) { positionTable[i] = this.ReadPositionNumber(); } - var elements = new IccMultiProcessElement[elementCount]; + IccMultiProcessElement[] elements = new IccMultiProcessElement[elementCount]; for (int i = 0; i < elementCount; i++) { this.currentIndex = (int)positionTable[i].Offset + start; @@ -548,7 +548,7 @@ internal sealed partial class IccDataReader string prefix = this.ReadAsciiString(32); string suffix = this.ReadAsciiString(32); - var colors = new IccNamedColor[colorCount]; + IccNamedColor[] colors = new IccNamedColor[colorCount]; for (int i = 0; i < colorCount; i++) { colors[i] = this.ReadNamedColor(coordCount); @@ -570,7 +570,7 @@ internal sealed partial class IccDataReader public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() { uint count = this.ReadUInt32(); - var description = new IccProfileDescription[count]; + IccProfileDescription[] description = new IccProfileDescription[count]; for (int i = 0; i < count; i++) { description[i] = this.ReadProfileDescription(); @@ -587,13 +587,13 @@ internal sealed partial class IccDataReader { int start = this.currentIndex - 8; // 8 is the tag header size uint count = this.ReadUInt32(); - var table = new IccPositionNumber[count]; + IccPositionNumber[] table = new IccPositionNumber[count]; for (int i = 0; i < count; i++) { table[i] = this.ReadPositionNumber(); } - var entries = new IccProfileSequenceIdentifier[count]; + IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count]; for (int i = 0; i < count; i++) { this.currentIndex = (int)(start + table[i].Offset); @@ -622,7 +622,7 @@ internal sealed partial class IccDataReader offset[i] = this.ReadUInt32(); } - var curves = new IccResponseCurve[measurementCount]; + IccResponseCurve[] curves = new IccResponseCurve[measurementCount]; for (int i = 0; i < measurementCount; i++) { this.currentIndex = (int)(start + offset[i]); @@ -760,7 +760,7 @@ internal sealed partial class IccDataReader public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) { uint count = (size - 8) / 12; - var arrayData = new Vector3[count]; + Vector3[] arrayData = new Vector3[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadXyzNumber(); @@ -839,9 +839,9 @@ internal sealed partial class IccDataReader /// The read entry. public IccScreeningTagDataEntry ReadScreeningTagDataEntry() { - var flags = (IccScreeningFlag)this.ReadInt32(); + IccScreeningFlag flags = (IccScreeningFlag)this.ReadInt32(); uint channelCount = this.ReadUInt32(); - var channels = new IccScreeningChannel[channelCount]; + IccScreeningChannel[] channels = new IccScreeningChannel[channelCount]; for (int i = 0; i < channels.Length; i++) { channels[i] = this.ReadScreeningChannel(); diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 78f7f6de0..7c5662e1f 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -124,7 +124,7 @@ public sealed class IptcValue : IDeepCloneable public int Length => this.data.Length; /// - public IptcValue DeepClone() => new IptcValue(this); + public IptcValue DeepClone() => new(this); /// /// Determines whether the specified object is equal to the current . @@ -191,7 +191,7 @@ public sealed class IptcValue : IDeepCloneable /// A array. public byte[] ToByteArray() { - var result = new byte[this.data.Length]; + byte[] result = new byte[this.data.Length]; this.data.CopyTo(result, 0); return result; } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs index 453a39228..1190d307a 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs @@ -231,7 +231,7 @@ public partial struct Abgr32 : IPixel, IPackedVector public static Abgr32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Abgr32(rgb, rgb, rgb); } /// @@ -243,7 +243,7 @@ public partial struct Abgr32 : IPixel, IPackedVector public static Abgr32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Abgr32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -320,6 +320,6 @@ public partial struct Abgr32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Abgr32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs index f8608ecc5..b74f5db71 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs @@ -224,7 +224,7 @@ public partial struct Argb32 : IPixel, IPackedVector public static Argb32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Argb32(rgb, rgb, rgb); } /// @@ -236,7 +236,7 @@ public partial struct Argb32 : IPixel, IPackedVector public static Argb32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Argb32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -296,6 +296,6 @@ public partial struct Argb32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Argb32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index a860edc56..944cdf7bf 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs @@ -110,7 +110,7 @@ public partial struct Bgr24 : IPixel source = Numerics.Clamp(source, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(source.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8)); + return new Bgr24(result.GetElement(0), result.GetElement(4), result.GetElement(8)); } /// @@ -142,7 +142,7 @@ public partial struct Bgr24 : IPixel public static Bgr24 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Bgr24(rgb, rgb, rgb); } /// @@ -154,7 +154,7 @@ public partial struct Bgr24 : IPixel public static Bgr24 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb); + return new Bgr24(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs index 0fe7e4cc2..903d9dc8c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs @@ -173,7 +173,7 @@ public partial struct Bgra32 : IPixel, IPackedVector public static Bgra32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Bgra32(rgb, rgb, rgb); } /// @@ -185,7 +185,7 @@ public partial struct Bgra32 : IPixel, IPackedVector public static Bgra32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Bgra32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -242,6 +242,6 @@ public partial struct Bgra32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Bgra32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 888d992d8..00deadb12 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -79,7 +79,7 @@ public partial struct HalfSingle : IPixel, IPackedVector float scaled = source.X; scaled *= 2F; scaled--; - return new() { PackedValue = HalfTypeHelper.Pack(scaled) }; + return new HalfSingle { PackedValue = HalfTypeHelper.Pack(scaled) }; } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs index 861a8480a..03d4dee89 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs @@ -63,7 +63,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2F; - return new(scaled, 0F, 1F); + return new Vector4(scaled, 0F, 1F); } /// @@ -71,7 +71,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector public readonly Vector4 ToVector4() { Vector2 vector = this.ToVector2(); - return new(vector.X, vector.Y, 0F, 1F); + return new Vector4(vector.X, vector.Y, 0F, 1F); } /// @@ -90,7 +90,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 2F; scaled -= Vector2.One; - return new() { PackedValue = Pack(scaled.X, scaled.Y) }; + return new HalfVector2 { PackedValue = Pack(scaled.X, scaled.Y) }; } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 64a22060c..c5893f770 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -52,7 +52,7 @@ public partial struct L16 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = ColorNumerics.From16BitTo8Bit(this.PackedValue); - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index cf8646cfa..008eed459 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -54,7 +54,7 @@ public partial struct L8 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = this.PackedValue; - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index 026d0c299..6c3fa7829 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -188,6 +188,6 @@ public partial struct La16 : IPixel, IPackedVector byte l = ColorNumerics.Get8BitBT709Luminance(result.GetElement(0), result.GetElement(4), result.GetElement(8)); byte a = result.GetElement(12); - return new(l, a); + return new La16(l, a); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 0ddcf16a1..c99f6fe60 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -78,7 +78,7 @@ public partial struct La32 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = ColorNumerics.From16BitTo8Bit(this.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(this.A)); + return new Rgba32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(this.A)); } /// @@ -117,7 +117,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -126,7 +126,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -143,7 +143,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -160,7 +160,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.From8BitTo16Bit(source.L); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -176,7 +176,7 @@ public partial struct La32 : IPixel, IPackedVector public static La32 FromRgb48(Rgb48 source) { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); - return new(l, ushort.MaxValue); + return new La32(l, ushort.MaxValue); } /// @@ -185,7 +185,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -210,6 +210,6 @@ public partial struct La32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One) * Max; ushort l = ColorNumerics.Get16BitBT709Luminance(vector.X, vector.Y, vector.Z); ushort a = (ushort)MathF.Round(vector.W); - return new(l, a); + return new La32(l, a); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index 9551d7242..da2ab2440 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -93,7 +93,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index a17868f6d..0942c3a76 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -95,7 +95,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 2f; scaled -= Vector2.One; - return new() { PackedValue = Pack(scaled) }; + return new NormalizedShort2 { PackedValue = Pack(scaled) }; } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index b03a54c58..190407296 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -121,7 +121,7 @@ public partial struct Rgb24 : IPixel source = Numerics.Clamp(source, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(source.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8)); + return new Rgb24(result.GetElement(0), result.GetElement(4), result.GetElement(8)); } /// @@ -153,7 +153,7 @@ public partial struct Rgb24 : IPixel public static Rgb24 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgb24(rgb, rgb, rgb); } /// @@ -165,7 +165,7 @@ public partial struct Rgb24 : IPixel public static Rgb24 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb); + return new Rgb24(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index e822d2abc..ed6f57abb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs @@ -100,7 +100,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One) * Max; - return new((ushort)MathF.Round(source.X), (ushort)MathF.Round(source.Y), (ushort)MathF.Round(source.Z)); + return new Rgb48((ushort)MathF.Round(source.X), (ushort)MathF.Round(source.Y), (ushort)MathF.Round(source.Z)); } /// @@ -132,7 +132,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromL8(L8 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgb48(rgb, rgb, rgb); } /// @@ -144,7 +144,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromLa16(La16 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.L); - return new(rgb, rgb, rgb); + return new Rgb48(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 507d6d70b..8980700c9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -328,7 +328,7 @@ public partial struct Rgba32 : IPixel, IPackedVector public static Rgba32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// @@ -340,7 +340,7 @@ public partial struct Rgba32 : IPixel, IPackedVector public static Rgba32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Rgba32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -407,7 +407,7 @@ public partial struct Rgba32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Rgba32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs index 27c4752e1..c73daaf86 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs @@ -245,7 +245,7 @@ public partial struct Rgba64 : IPixel, IPackedVector public static Rgba64 FromL8(L8 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.PackedValue); - return new(rgb, rgb, rgb, ushort.MaxValue); + return new Rgba64(rgb, rgb, rgb, ushort.MaxValue); } /// @@ -257,7 +257,7 @@ public partial struct Rgba64 : IPixel, IPackedVector public static Rgba64 FromLa16(La16 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From8BitTo16Bit(source.A)); + return new Rgba64(rgb, rgb, rgb, ColorNumerics.From8BitTo16Bit(source.A)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs index a27cffad8..3f9cab32f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs @@ -115,7 +115,7 @@ public partial struct RgbaVector : IPixel public static RgbaVector FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One); - return new(source.X, source.Y, source.Z, source.W); + return new RgbaVector(source.X, source.Y, source.Z, source.W); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 403d3fbea..39c853a5e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -98,7 +98,7 @@ public partial struct Short2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 65534F; scaled -= new Vector2(32767F); - return new() { PackedValue = Pack(scaled) }; + return new Short2 { PackedValue = Pack(scaled) }; } /// diff --git a/src/ImageSharp/Primitives/Complex64.cs b/src/ImageSharp/Primitives/Complex64.cs index 4baedd9ba..061e2bd80 100644 --- a/src/ImageSharp/Primitives/Complex64.cs +++ b/src/ImageSharp/Primitives/Complex64.cs @@ -42,7 +42,7 @@ internal readonly struct Complex64 : IEquatable /// The scalar to use to multiply the value. /// The result [MethodImpl(InliningOptions.ShortMethod)] - public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar); + public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar); /// /// Performs the multiplication operation between a instance and a . diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index 9849e0211..692507096 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -198,7 +198,7 @@ public readonly struct DenseMatrix : IEquatable> [MethodImpl(MethodImplOptions.AggressiveInlining)] public DenseMatrix Transpose() { - DenseMatrix result = new DenseMatrix(this.Rows, this.Columns); + DenseMatrix result = new(this.Rows, this.Columns); for (int y = 0; y < this.Rows; y++) { diff --git a/src/ImageSharp/Primitives/Number.cs b/src/ImageSharp/Primitives/Number.cs index fae67bbea..a996a94f4 100644 --- a/src/ImageSharp/Primitives/Number.cs +++ b/src/ImageSharp/Primitives/Number.cs @@ -47,19 +47,19 @@ public struct Number : IEquatable, IComparable /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(int value) => new Number(value); + public static implicit operator Number(int value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(uint value) => new Number(value); + public static implicit operator Number(uint value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(ushort value) => new Number((uint)value); + public static implicit operator Number(ushort value) => new((uint)value); /// /// Converts the specified to a . diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index d56ea825e..0f8e6518a 100644 --- a/src/ImageSharp/Primitives/SignedRational.cs +++ b/src/ImageSharp/Primitives/SignedRational.cs @@ -42,7 +42,7 @@ public readonly struct SignedRational : IEquatable { if (simplify) { - var rational = new LongRational(numerator, denominator).Simplify(); + LongRational rational = new LongRational(numerator, denominator).Simplify(); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -70,7 +70,7 @@ public readonly struct SignedRational : IEquatable /// Whether to use the best possible precision when parsing the value. public SignedRational(double value, bool bestPrecision) { - var rational = LongRational.FromDouble(value, bestPrecision); + LongRational rational = LongRational.FromDouble(value, bestPrecision); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -142,8 +142,8 @@ public readonly struct SignedRational : IEquatable /// public bool Equals(SignedRational other) { - var left = new LongRational(this.Numerator, this.Denominator); - var right = new LongRational(other.Numerator, other.Denominator); + LongRational left = new(this.Numerator, this.Denominator); + LongRational right = new(other.Numerator, other.Denominator); return left.Equals(right); } @@ -151,7 +151,7 @@ public readonly struct SignedRational : IEquatable /// public override int GetHashCode() { - var self = new LongRational(this.Numerator, this.Denominator); + LongRational self = new(this.Numerator, this.Denominator); return self.GetHashCode(); } @@ -182,7 +182,7 @@ public readonly struct SignedRational : IEquatable /// The public string ToString(IFormatProvider provider) { - var rational = new LongRational(this.Numerator, this.Denominator); + LongRational rational = new(this.Numerator, this.Denominator); return rational.ToString(provider); } } diff --git a/src/ImageSharp/Primitives/Size.cs b/src/ImageSharp/Primitives/Size.cs index 945b680da..0e65a8138 100644 --- a/src/ImageSharp/Primitives/Size.cs +++ b/src/ImageSharp/Primitives/Size.cs @@ -85,14 +85,14 @@ public struct Size : IEquatable /// /// The point. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator SizeF(Size size) => new SizeF(size.Width, size.Height); + public static implicit operator SizeF(Size size) => new(size.Width, size.Height); /// /// Converts the given into a . /// /// The size. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Point(Size size) => new Point(size.Width, size.Height); + public static explicit operator Point(Size size) => new(size.Width, size.Height); /// /// Computes the sum of adding two sizes. @@ -138,7 +138,7 @@ public struct Size : IEquatable /// Dividend of type . /// Divisor of type . /// Result of type . - public static Size operator /(Size left, int right) => new Size(unchecked(left.Width / right), unchecked(left.Height / right)); + public static Size operator /(Size left, int right) => new(unchecked(left.Width / right), unchecked(left.Height / right)); /// /// Multiplies by a producing . @@ -163,7 +163,7 @@ public struct Size : IEquatable /// Divisor of type . /// Result of type . public static SizeF operator /(Size left, float right) - => new SizeF(left.Width / right, left.Height / right); + => new(left.Width / right, left.Height / right); /// /// Compares two objects for equality. @@ -202,7 +202,7 @@ public struct Size : IEquatable /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Add(Size left, Size right) => new Size(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); + public static Size Add(Size left, Size right) => new(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); /// /// Contracts a by another . @@ -211,7 +211,7 @@ public struct Size : IEquatable /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); + public static Size Subtract(Size left, Size right) => new(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); /// /// Converts a to a by performing a ceiling operation on all the dimensions. @@ -219,7 +219,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Ceiling(SizeF size) => new Size(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); + public static Size Ceiling(SizeF size) => new(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); /// /// Converts a to a by performing a round operation on all the dimensions. @@ -227,7 +227,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); + public static Size Round(SizeF size) => new(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); /// /// Transforms a size by the given matrix. @@ -237,7 +237,7 @@ public struct Size : IEquatable /// A transformed size. public static SizeF Transform(Size size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); return new SizeF(v.X, v.Y); } @@ -248,7 +248,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height)); + public static Size Truncate(SizeF size) => new(unchecked((int)size.Width), unchecked((int)size.Height)); /// /// Deconstructs this size into two integers. @@ -281,7 +281,7 @@ public struct Size : IEquatable /// Multiplier of type . /// Product of type . private static Size Multiply(Size size, int multiplier) => - new Size(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); + new(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); /// /// Multiplies by a producing . @@ -290,5 +290,5 @@ public struct Size : IEquatable /// Multiplier of type . /// Product of type SizeF. private static SizeF Multiply(Size size, float multiplier) => - new SizeF(size.Width * multiplier, size.Height * multiplier); + new(size.Width * multiplier, size.Height * multiplier); } diff --git a/src/ImageSharp/Primitives/SizeF.cs b/src/ImageSharp/Primitives/SizeF.cs index 36cf9eb8e..81c749875 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -191,7 +191,7 @@ public struct SizeF : IEquatable /// A transformed size. public static SizeF Transform(SizeF size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); return new SizeF(v.X, v.Y); } diff --git a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs index b6db0172d..96b30d4f8 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs @@ -30,7 +30,7 @@ public static class PadExtensions public static IImageProcessingContext Pad(this IImageProcessingContext source, int width, int height, Color color) { Size size = source.GetCurrentSize(); - var options = new ResizeOptions + ResizeOptions options = new() { // Prevent downsizing. Size = new Size(Math.Max(width, size.Width), Math.Max(height, size.Height)), diff --git a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs index 01f296d09..4a09639f8 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs @@ -118,7 +118,7 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(width, height), Mode = ResizeMode.Manual, @@ -151,7 +151,7 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(width, height), Mode = ResizeMode.Manual, diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index b312287b5..fd512557d 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -20,7 +20,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatomaly (Color desensitivity) color blindness /// - public static ColorMatrix AchromatomalyFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatomalyFilter { get; } = new() { M11 = .618F, M12 = .163F, @@ -37,7 +37,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatopsia (Monochrome) color blindness. /// - public static ColorMatrix AchromatopsiaFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatopsiaFilter { get; } = new() { M11 = .299F, M12 = .299F, @@ -54,7 +54,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranomaly (Green-Weak) color blindness. /// - public static ColorMatrix DeuteranomalyFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranomalyFilter { get; } = new() { M11 = .8F, M12 = .258F, @@ -68,7 +68,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranopia (Green-Blind) color blindness. /// - public static ColorMatrix DeuteranopiaFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranopiaFilter { get; } = new() { M11 = .625F, M12 = .7F, @@ -82,7 +82,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanomaly (Red-Weak) color blindness. /// - public static ColorMatrix ProtanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanomalyFilter { get; } = new() { M11 = .817F, M12 = .333F, @@ -96,7 +96,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanopia (Red-Blind) color blindness. /// - public static ColorMatrix ProtanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanopiaFilter { get; } = new() { M11 = .567F, M12 = .558F, @@ -110,7 +110,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanomaly (Blue-Weak) color blindness. /// - public static ColorMatrix TritanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix TritanomalyFilter { get; } = new() { M11 = .967F, M21 = .33F, @@ -124,7 +124,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanopia (Blue-Blind) color blindness. /// - public static ColorMatrix TritanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix TritanopiaFilter { get; } = new() { M11 = .95F, M21 = .05F, @@ -138,7 +138,7 @@ public static class KnownFilterMatrices /// /// Gets an approximated black and white filter /// - public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix + public static ColorMatrix BlackWhiteFilter { get; } = new() { M11 = 1.5F, M12 = 1.5F, @@ -190,7 +190,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating an old Polaroid camera effect. /// - public static ColorMatrix PolaroidFilter { get; } = new ColorMatrix + public static ColorMatrix PolaroidFilter { get; } = new() { M11 = 1.538F, M12 = -.062F, diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index ff3b30e9c..727e8e96a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs @@ -68,7 +68,7 @@ internal class BoxBlurProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } @@ -80,7 +80,7 @@ internal class BoxBlurProcessor : ImageProcessor /// The . private static float[] CreateBoxKernel(int kernelSize) { - var kernel = new float[kernelSize]; + float[] kernel = new float[kernelSize]; kernel.AsSpan().Fill(1F / kernelSize); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index 2a4a1abf0..bccf19174 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -75,7 +75,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. @@ -141,7 +141,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index 5af436044..502c34402 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs @@ -55,7 +55,7 @@ internal class EdgeDetector2DProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2DProcessor( + using Convolution2DProcessor processor = new( this.Configuration, in this.kernelX, in this.kernelY, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs index 7efcbf3a6..b51ed1819 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs @@ -19,7 +19,7 @@ internal static class LaplacianKernelFactory Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); - var kernel = new DenseMatrix((int)length); + DenseMatrix kernel = new((int)length); kernel.Fill(-1); int mid = (int)(length / 2); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 565a5746d..ae4483f2e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -16,7 +16,7 @@ internal static class BokehBlurKernelDataProvider /// /// The mapping of initialized complex kernels and parameters, to speed up the initialization of new instances /// - private static readonly ConcurrentDictionary Cache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Cache = new(); /// /// Gets the kernel scales to adjust the component values in each kernel @@ -90,7 +90,7 @@ internal static class BokehBlurKernelDataProvider int componentsCount) { // Reuse the initialized values from the cache, if possible - var parameters = new BokehBlurParameters(radius, componentsCount); + BokehBlurParameters parameters = new(radius, componentsCount); if (!Cache.TryGetValue(parameters, out BokehBlurKernelData info)) { // Initialize the complex kernels and parameters with the current arguments @@ -130,7 +130,7 @@ internal static class BokehBlurKernelDataProvider int kernelSize, float kernelsScale) { - var kernels = new Complex64[kernelParameters.Length][]; + Complex64[][] kernels = new Complex64[kernelParameters.Length][]; ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) { @@ -156,7 +156,7 @@ internal static class BokehBlurKernelDataProvider float a, float b) { - var kernel = new Complex64[kernelSize]; + Complex64[] kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); int r = radius, n = -r; diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index d1f46c744..b0622cac5 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -32,7 +32,7 @@ public readonly partial struct OrderedDither : IDither, IEquatable((int)length); + DenseMatrix thresholdMatrix = new((int)length); float m2 = length * length; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs index 7f8b34724..ec82f01d7 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs @@ -29,7 +29,7 @@ internal static class OrderedDitherFactory while (length > bayerLength); // Create our Bayer matrix that matches the given exponent and dimensions - var matrix = new DenseMatrix((int)length); + DenseMatrix matrix = new((int)length); uint i = 0; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index d5499d586..d2a99ce92 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -112,7 +112,7 @@ internal class DrawImageProcessor : ImageProcessor } // Sanitize the dimensions so that we don't try and sample outside the image. - Rectangle backgroundRectangle = Rectangle.Intersect(new(left, top, width, height), this.SourceRectangle); + Rectangle backgroundRectangle = Rectangle.Intersect(new Rectangle(left, top, width, height), this.SourceRectangle); Configuration configuration = this.Configuration; DrawImageProcessor.RowOperation operation = @@ -127,7 +127,7 @@ internal class DrawImageProcessor : ImageProcessor ParallelRowIterator.IterateRows( configuration, - new(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), + new Rectangle(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 78085eaab..3d54836c5 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -145,7 +145,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = cdfData.RemapGreyValue(cdfX, cdfY, GetLuminance(pixel, luminanceLevels)); - pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index 93144653e..8ca4a86a2 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -383,7 +383,7 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor : His // Map the current pixel to the new equalized value. int luminance = GetLuminance(this.source[x, y], this.processor.LuminanceLevels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / numberOfPixelsMinusCdfMin; - this.targetPixels[x, y] = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W)); + this.targetPixels[x, y] = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W)); // Remove top most row from the histogram, mirroring rows which exceeds the borders. if (this.useFastPath) diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index 606789af9..e830cc55f 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -150,7 +150,7 @@ internal class AutoLevelProcessor : HistogramEqualizationProcessor.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs index 0a8690ba7..3584f2954 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs @@ -56,7 +56,7 @@ internal readonly struct GrayscaleLevelsRowOperation : IRowOperation : TransformProcessor /// protected override Size GetDestinationSize() => new(this.cropRectangle.Width, this.cropRectangle.Height); + /// protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix; /// diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index b7afea449..d25d4f474 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -477,7 +477,7 @@ internal static class TransformUtils { float scaleX = 1F / new Vector2(matrix.M11, matrix.M21).Length(); // sqrt(M11^2 + M21^2) float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) - offsetSize = new(scaleX, scaleY); + offsetSize = new SizeF(scaleX, scaleY); } // Subtract the offset size to translate to the pixel space. diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 72b6bb72e..4ea0a92f1 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs @@ -185,15 +185,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector2(sLeft.X); - var yLeft = new Vector2(sLeft.Y); - var zLeft = new Vector2(sLeft.Z); - var wLeft = new Vector2(sLeft.W); + Vector2 xLeft = new(sLeft.X); + Vector2 yLeft = new(sLeft.Y); + Vector2 zLeft = new(sLeft.Z); + Vector2 wLeft = new(sLeft.W); - var xRight = new Vector2(sRight.X); - var yRight = new Vector2(sRight.Y); - var zRight = new Vector2(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector2 xRight = new(sRight.X); + Vector2 yRight = new(sRight.Y); + Vector2 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); dTopLeft = xLeft; Unsafe.Add(ref dTopLeft, 1) = yLeft; @@ -245,15 +245,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector4(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector4 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -303,15 +303,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -362,25 +362,25 @@ public class Block8x8F_CopyTo2x2 ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)(offset + destStride))); - var xyLeft = new Vector4(sLeft.X) + Vector4 xyLeft = new(sLeft.X) { Z = sLeft.Y, W = sLeft.Y }; - var zwLeft = new Vector4(sLeft.Z) + Vector4 zwLeft = new(sLeft.Z) { Z = sLeft.W, W = sLeft.W }; - var xyRight = new Vector4(sRight.X) + Vector4 xyRight = new(sRight.X) { Z = sRight.Y, W = sRight.Y }; - var zwRight = new Vector4(sRight.Z) + Vector4 zwRight = new(sRight.Z) { Z = sRight.W, W = sRight.W diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs index efc347586..45c6f63b9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs @@ -19,8 +19,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations; public unsafe class Block8x8F_DivideRound { private const int ExecutionCount = 5; // Added this to reduce the effect of copying the blocks - private static readonly Vector4 MinusOne = new Vector4(-1); - private static readonly Vector4 Half = new Vector4(0.5f); + private static readonly Vector4 MinusOne = new(-1); + private static readonly Vector4 Half = new(0.5f); private Block8x8F inputDividend; private Block8x8F inputDivisor; @@ -140,7 +140,7 @@ public unsafe class Block8x8F_DivideRound [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 DivideRound(Vector4 dividend, Vector4 divisor) { - var sign = Vector4.Min(dividend, Vector4.One); + Vector4 sign = Vector4.Min(dividend, Vector4.One); sign = Vector4.Max(sign, MinusOne); return (dividend / divisor) + (sign * Half); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs index 722b09587..3c03f3e05 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs @@ -20,7 +20,7 @@ public class Block8x8F_MultiplyInPlaceBlock private static Block8x8F Create8x8FloatData() { - var result = new float[64]; + float[] result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs index 8964667b7..436aa9bcd 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs @@ -38,11 +38,11 @@ public abstract class ColorConversionBenchmark float minVal = 0f, float maxVal = 255f) { - var rnd = new Random(42); - var buffers = new Buffer2D[componentCount]; + Random rnd = new(42); + Buffer2D[] buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { - var values = new float[inputBufferLength]; + float[] values = new float[inputBufferLength]; for (int j = 0; j < inputBufferLength; j++) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs index 91ee82136..e7b66576d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.IO; @@ -38,7 +39,7 @@ public class DecodeJpegParseStreamOnly { using MemoryStream memoryStream = new(this.jpegBytes); using BufferedReadStream bufferedStream = new(Configuration.Default, memoryStream); - JpegDecoderOptions options = new() { GeneralOptions = new() { SkipMetadata = true } }; + JpegDecoderOptions options = new() { GeneralOptions = new DecoderOptions { SkipMetadata = true } }; using JpegDecoderCore decoder = new(options); NoopSpectralConverter spectralConverter = new(); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 257e44cc4..9a4ee3967 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -49,7 +49,7 @@ public class DecodeJpeg_ImageSpecific public Size ImageSharp() { using MemoryStream memoryStream = new(this.jpegBytes); - using Image image = Image.Load(new DecoderOptions() { SkipMetadata = true }, memoryStream); + using Image image = Image.Load(new DecoderOptions { SkipMetadata = true }, memoryStream); return new Size(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs index 30023feca..64a8092c6 100644 --- a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs +++ b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General; public class Adler32Benchmark { private byte[] data; - private readonly SharpAdler32 adler = new SharpAdler32(); + private readonly SharpAdler32 adler = new(); [Params(1024, 2048, 4096)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index d47fcb687..b61ba27ff 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs @@ -12,7 +12,7 @@ public class ClampSpan public void Setup() { - var r = new Random(); + Random r = new(); for (int i = 0; i < A.Length; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index a42c6c253..226dcc777 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -209,7 +209,7 @@ public unsafe class PixelConversion_PackFromRgbPlanes Vector256 vcontrol = SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32().AsInt32(); - var va = Vector256.Create(1F); + Vector256 va = Vector256.Create(1F); for (nuint i = 0; i < count; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index f4fb9e420..232d8b3e2 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -252,8 +252,8 @@ public class PixelConversion_Rgba32_To_Bgra32 private static void BitopsSimdImpl(ref Octet s, ref Octet d) { Vector sVec = Unsafe.As, Vector>(ref s); - var aMask = new Vector(0xFF00FF00); - var bMask = new Vector(0x00FF00FF); + Vector aMask = new(0xFF00FF00); + Vector bMask = new(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs index 21bef5a15..8698f8223 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs @@ -103,6 +103,6 @@ public struct TestArgb : ITestPixel vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new TestArgb(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs index 1499fb7d3..751cd68b4 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs @@ -79,6 +79,6 @@ public struct TestRgba : ITestPixel vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new TestRgba(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 2cd6a5a52..5919137bf 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -12,10 +12,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General; /// public class Vector4Constants { - private static readonly Vector4 A = new Vector4(1.2f); - private static readonly Vector4 B = new Vector4(3.4f); - private static readonly Vector4 C = new Vector4(5.6f); - private static readonly Vector4 D = new Vector4(7.8f); + private static readonly Vector4 A = new(1.2f); + private static readonly Vector4 B = new(3.4f); + private static readonly Vector4 C = new(5.6f); + private static readonly Vector4 D = new(7.8f); private Random random; @@ -39,8 +39,8 @@ public class Vector4Constants Vector4 x = (p * A / B) + (p * C / D); Vector4 y = (p / A * B) + (p / C * D); - var z = Vector4.Min(p, A); - var w = Vector4.Max(p, B); + Vector4 z = Vector4.Min(p, A); + Vector4 w = Vector4.Max(p, B); return x + y + z + w; } @@ -51,8 +51,8 @@ public class Vector4Constants Vector4 x = (p * new Vector4(1.2f) / new Vector4(2.3f)) + (p * new Vector4(4.5f) / new Vector4(6.7f)); Vector4 y = (p / new Vector4(1.2f) * new Vector4(2.3f)) + (p / new Vector4(4.5f) * new Vector4(6.7f)); - var z = Vector4.Min(p, new Vector4(1.2f)); - var w = Vector4.Max(p, new Vector4(2.3f)); + Vector4 z = Vector4.Min(p, new Vector4(1.2f)); + Vector4 w = Vector4.Max(p, new Vector4(2.3f)); return x + y + z + w; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs index 4d8d9b1ed..2f9b02b59 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -43,11 +43,11 @@ public class BitwiseOrUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = Vector.BitwiseOr(a, v); a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs index 1b2c56ab9..fd243638b 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs @@ -43,11 +43,11 @@ public class DivFloat [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs index d102164e2..0d2923b61 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs @@ -44,11 +44,11 @@ public class DivUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs index 5277897bb..61ff9466e 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs @@ -57,7 +57,7 @@ public class DivInt16 : SIMDBenchmarkBase.Divide { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index a2eb8d417..801b0e161 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -43,11 +43,11 @@ public class MulFloat [Benchmark] public void SimdMultiplyByVector() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } @@ -60,7 +60,7 @@ public class MulFloat for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs index a234970a5..db64486ad 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -43,11 +43,11 @@ public class MulUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs index 7e890cb92..d9542bc3f 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs @@ -40,7 +40,7 @@ public class MulInt16 : SIMDBenchmarkBase.Multiply { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs index 29b90accc..f99b141b4 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs @@ -12,14 +12,14 @@ public class Premultiply [Benchmark(Baseline = true)] public Vector4 PremultiplyByVal() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); return Vector4Utils.Premultiply(input); } [Benchmark] public Vector4 PremultiplyByRef() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRef(ref input); return input; } @@ -27,7 +27,7 @@ public class Premultiply [Benchmark] public Vector4 PremultiplyRefWithPropertyAssign() { - var input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRefWithPropertyAssign(ref input); return input; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs index 7d626d785..557d8ff38 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -53,8 +53,8 @@ public class ReinterpretUInt32AsFloat { for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); - var b = Vector.AsVectorSingle(a); + Vector a = new(this.input, i); + Vector b = Vector.AsVectorSingle(a); b.CopyTo(this.result, i); } } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 5f1f5666d..4048bc210 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -27,20 +27,20 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; - var bVec = new Vector(256.0f / 255.0f); - var magicFloat = new Vector(32768.0f); - var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f - var mask = new Vector(255); + Vector bVec = new(256.0f / 255.0f); + Vector magicFloat = new(32768.0f); + Vector magicInt = new(1191182336); // reinterpreted value of 32768.0f + Vector mask = new(255); for (nuint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); - var vi = Vector.AsVectorUInt32(df); + Vector vi = Vector.AsVectorUInt32(df); vi &= mask; vi |= magicInt; - var vf = Vector.AsVectorSingle(vi); + Vector vf = Vector.AsVectorSingle(vi); vf = (vf - magicFloat) * bVec; df = vf; @@ -55,7 +55,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -74,7 +74,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -91,7 +91,7 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); - var scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 5d20f29d1..9c7fd5b6c 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -47,11 +47,11 @@ public class VectorFetching [Benchmark] public void FetchWithVectorConstructor() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - var a = new Vector(this.data, i); + Vector a = new(this.data, i); a = a * v; a.CopyTo(this.data, i); } @@ -60,7 +60,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCast() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -79,7 +79,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastNoTempVector() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -94,9 +94,9 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastFromReference() { - var v = new Vector(this.testValue); + Vector v = new(this.testValue); - var span = new Span(this.data); + Span span = new(this.data); ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs index 04621695c..5d137a615 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveStressBenchmarks [GlobalSetup] public void Setup() { - this.runner = new LoadResizeSaveStressRunner() + this.runner = new LoadResizeSaveStressRunner { ImageCount = Environment.ProcessorCount, Filter = Filter diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index 44c248dc9..75bc5289c 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -148,7 +148,7 @@ public class LoadResizeSaveStressRunner private void LogImageProcessed(int width, int height) { - this.LastProcessedImageSize = new Size(width, height); + this.LastProcessedImageSize = new ImageSharpSize(width, height); double pixels = width * (double)height; this.TotalProcessedMegapixels += pixels / 1_000_000.0; } diff --git a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs index 135145a31..93ac9fc0e 100644 --- a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs +++ b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs @@ -33,7 +33,7 @@ public class HistogramEqualization [Benchmark(Description = "Global Histogram Equalization")] public void GlobalHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new HistogramEqualizationOptions { LuminanceLevels = 256, Method = HistogramEqualizationMethod.Global @@ -42,7 +42,7 @@ public class HistogramEqualization [Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")] public void AdaptiveHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new HistogramEqualizationOptions { LuminanceLevels = 256, Method = HistogramEqualizationMethod.AdaptiveTileInterpolation diff --git a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs index e3e413fe4..707748499 100644 --- a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs +++ b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs @@ -13,7 +13,7 @@ public class OilPaint [Benchmark] public void DoOilPaint() { - using Image image = new Image(1920, 1200, new(127, 191, 255)); + using Image image = new(1920, 1200, new RgbaVector(127, 191, 255)); image.Mutate(ctx => ctx.OilPaint()); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 09673cb96..356027221 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Resize.cs @@ -22,7 +22,7 @@ public abstract class Resize private SDImage sourceBitmap; - protected Configuration Configuration { get; } = new Configuration(new JpegConfigurationModule()); + protected Configuration Configuration { get; } = new(new JpegConfigurationModule()); protected int DestSize { get; private set; } diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs index 248912b14..6850756df 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs @@ -17,7 +17,7 @@ internal class LoadResizeSaveParallelMemoryStress { private LoadResizeSaveParallelMemoryStress() { - this.Benchmarks = new LoadResizeSaveStressRunner() + this.Benchmarks = new LoadResizeSaveStressRunner { Filter = JpegKind.Baseline, }; @@ -38,7 +38,7 @@ internal class LoadResizeSaveParallelMemoryStress Console.WriteLine($"64 bit: {Environment.Is64BitProcess}"); CommandLineOptions options = args.Length > 0 ? CommandLineOptions.Parse(args) : null; - var lrs = new LoadResizeSaveParallelMemoryStress(); + LoadResizeSaveParallelMemoryStress lrs = new(); if (options != null) { lrs.Benchmarks.MaxDegreeOfParallelism = options.MaxDegreeOfParallelism; @@ -108,7 +108,7 @@ internal class LoadResizeSaveParallelMemoryStress } } - var stats = new Stats(timer, lrs.Benchmarks.TotalProcessedMegapixels); + Stats stats = new(timer, lrs.Benchmarks.TotalProcessedMegapixels); Console.WriteLine($"Total Megapixels: {stats.TotalMegapixels}, TotalOomRetries: {UnmanagedMemoryHandle.TotalOomRetries}, TotalOutstandingHandles: {UnmanagedMemoryHandle.TotalOutstandingHandles}, Total Gen2 GC count: {GC.CollectionCount(2)}"); Console.WriteLine(stats.GetMarkdown()); if (options?.FileOutput != null) @@ -203,7 +203,7 @@ internal class LoadResizeSaveParallelMemoryStress public string GetMarkdown() { - var bld = new StringBuilder(); + StringBuilder bld = new(); bld.AppendLine($"| {nameof(this.TotalSeconds)} | {nameof(this.MegapixelsPerSec)} | {nameof(this.MegapixelsPerSecPerCpu)} |"); bld.AppendLine( $"| {L(nameof(this.TotalSeconds))} | {L(nameof(this.MegapixelsPerSec))} | {L(nameof(this.MegapixelsPerSecPerCpu))} |"); diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index b5c8b70cd..3e4f77f9e 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -64,13 +64,13 @@ public class Program private static void RunResizeProfilingTest() { - var test = new ResizeProfilingBenchmarks(new ConsoleOutput()); + ResizeProfilingBenchmarks test = new(new ConsoleOutput()); test.ResizeBicubic(4000, 4000); } private static void RunToVector4ProfilingTest() { - var tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); + PixelOperationsTests.Rgba32_OperationsTests tests = new(new ConsoleOutput()); tests.Benchmark_ToVector4(); } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index 4247345c7..2e2f0d07d 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs @@ -13,10 +13,10 @@ public partial class ColorTests [Fact] public void Rgba64() { - var source = new Rgba64(100, 2222, 3333, 4444); + Rgba64 source = new(100, 2222, 3333, 4444); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba64 data = color.ToPixel(); @@ -26,10 +26,10 @@ public partial class ColorTests [Fact] public void Rgba32() { - var source = new Rgba32(1, 22, 33, 231); + Rgba32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba32 data = color.ToPixel(); @@ -39,10 +39,10 @@ public partial class ColorTests [Fact] public void Argb32() { - var source = new Argb32(1, 22, 33, 231); + Argb32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Argb32 data = color.ToPixel(); @@ -52,10 +52,10 @@ public partial class ColorTests [Fact] public void Bgra32() { - var source = new Bgra32(1, 22, 33, 231); + Bgra32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgra32 data = color.ToPixel(); @@ -65,10 +65,10 @@ public partial class ColorTests [Fact] public void Abgr32() { - var source = new Abgr32(1, 22, 33, 231); + Abgr32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Abgr32 data = color.ToPixel(); @@ -78,10 +78,10 @@ public partial class ColorTests [Fact] public void Rgb24() { - var source = new Rgb24(1, 22, 231); + Rgb24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgb24 data = color.ToPixel(); @@ -91,10 +91,10 @@ public partial class ColorTests [Fact] public void Bgr24() { - var source = new Bgr24(1, 22, 231); + Bgr24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgr24 data = color.ToPixel(); @@ -129,7 +129,7 @@ public partial class ColorTests where TPixel : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel actual = color.ToPixel(); @@ -150,7 +150,7 @@ public partial class ColorTests where TPixel2 : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel2 actual = color.ToPixel(); diff --git a/tests/ImageSharp.Tests/Color/ReferencePalette.cs b/tests/ImageSharp.Tests/Color/ReferencePalette.cs index 8e2696109..2db2aae19 100644 --- a/tests/ImageSharp.Tests/Color/ReferencePalette.cs +++ b/tests/ImageSharp.Tests/Color/ReferencePalette.cs @@ -273,7 +273,7 @@ internal static class ReferencePalette }; public static readonly Dictionary ColorNames = - new Dictionary(StringComparer.OrdinalIgnoreCase) + new(StringComparer.OrdinalIgnoreCase) { { nameof(Color.AliceBlue), Color.AliceBlue }, { nameof(Color.AntiqueWhite), Color.AntiqueWhite }, diff --git a/tests/ImageSharp.Tests/Color/RgbaDouble.cs b/tests/ImageSharp.Tests/Color/RgbaDouble.cs index 9a751e879..76fdf365c 100644 --- a/tests/ImageSharp.Tests/Color/RgbaDouble.cs +++ b/tests/ImageSharp.Tests/Color/RgbaDouble.cs @@ -115,7 +115,7 @@ public struct RgbaDouble : IPixel public static RgbaDouble FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One); - return new(source.X, source.Y, source.Z, source.W); + return new RgbaDouble(source.X, source.Y, source.Z, source.W); } /// diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs index 3e3bb4d49..eec27fcd7 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using Wacton.Unicolour; using Wacton.Unicolour.Icc; namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc; @@ -63,7 +64,7 @@ internal static class TestIccProfiles public static Wacton.Unicolour.Configuration GetUnicolourConfiguration(string file) => UnicolourConfigurationCache.GetOrAdd( file, - f => new Wacton.Unicolour.Configuration(iccConfig: new(GetFullPath(f), Intent.Unspecified, f))); + f => new Wacton.Unicolour.Configuration(iccConfig: new IccConfiguration(GetFullPath(f), Intent.Unspecified, f))); public static bool HasUnicolourConfiguration(string file) => UnicolourConfigurationCache.ContainsKey(file); diff --git a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs index 190bfe1dc..8421c1fd7 100644 --- a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs @@ -10,7 +10,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_EmptyBuffer_ReturnsEmptyString() { - var buffer = default(ReadOnlySpan); + ReadOnlySpan buffer = default(ReadOnlySpan); string result = Encoding.UTF8.GetString(buffer); @@ -20,7 +20,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_Buffer_ReturnsString() { - var buffer = new ReadOnlySpan(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); + ReadOnlySpan buffer = new(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); string result = Encoding.UTF8.GetString(buffer); diff --git a/tests/ImageSharp.Tests/Common/NumericsTests.cs b/tests/ImageSharp.Tests/Common/NumericsTests.cs index 2b9276943..ebee57060 100644 --- a/tests/ImageSharp.Tests/Common/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Common/NumericsTests.cs @@ -28,7 +28,7 @@ public class NumericsTests [InlineData(1, 100)] public void DivideCeil_RandomValues(int seed, int count) { - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < count; i++) { uint value = (uint)rng.Next(); diff --git a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs index 193110944..5ea7afaf8 100644 --- a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs @@ -10,7 +10,7 @@ public class StreamExtensionsTests [InlineData(-1)] public void Skip_CountZeroOrLower_PositionNotChanged(int count) { - using (var memStream = new MemoryStream(5)) + using (MemoryStream memStream = new(5)) { memStream.Position = 4; memStream.Skip(count); @@ -22,7 +22,7 @@ public class StreamExtensionsTests [Fact] public void Skip_SeekableStream_SeekIsCalled() { - using (var seekableStream = new SeekableStream(4)) + using (SeekableStream seekableStream = new(4)) { seekableStream.Skip(4); @@ -34,7 +34,7 @@ public class StreamExtensionsTests [Fact] public void Skip_NonSeekableStream_BytesAreRead() { - using (var nonSeekableStream = new NonSeekableStream()) + using (NonSeekableStream nonSeekableStream = new()) { nonSeekableStream.Skip(5); @@ -49,7 +49,7 @@ public class StreamExtensionsTests [Fact] public void Skip_EofStream_NoExceptionIsThrown() { - using (var eofStream = new EofStream(7)) + using (EofStream eofStream = new(7)) { eofStream.Skip(7); @@ -79,7 +79,7 @@ public class StreamExtensionsTests { public override bool CanSeek => false; - public List Counts = new List(); + public List Counts = new(); public NonSeekableStream() : base(4) diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index c8e6cd265..3c6c759f8 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -58,7 +58,7 @@ public class ConfigurationTests { Assert.True(this.DefaultConfiguration.MaxDegreeOfParallelism == Environment.ProcessorCount); - var cfg = new Configuration(); + Configuration cfg = new(); Assert.True(cfg.MaxDegreeOfParallelism == Environment.ProcessorCount); } @@ -71,7 +71,7 @@ public class ConfigurationTests [InlineData(5, false)] public void MaxDegreeOfParallelism_CompatibleWith_ParallelOptions(int maxDegreeOfParallelism, bool throws) { - var cfg = new Configuration(); + Configuration cfg = new(); if (throws) { Assert.Throws( @@ -87,8 +87,8 @@ public class ConfigurationTests [Fact] public void ConstructorCallConfigureOnFormatProvider() { - var provider = new Mock(); - var config = new Configuration(provider.Object); + Mock provider = new(); + Configuration config = new(provider.Object); provider.Verify(x => x.Configure(config)); } @@ -96,8 +96,8 @@ public class ConfigurationTests [Fact] public void AddFormatCallsConfig() { - var provider = new Mock(); - var config = new Configuration(); + Mock provider = new(); + Configuration config = new(); config.Configure(provider.Object); provider.Verify(x => x.Configure(config)); @@ -118,7 +118,7 @@ public class ConfigurationTests [Fact] public void DefaultConfigurationHasCorrectFormatCount() { - var config = Configuration.CreateDefaultInstance(); + Configuration config = Configuration.CreateDefaultInstance(); Assert.Equal(this.expectedDefaultConfigurationCount, config.ImageFormats.Count()); } @@ -140,7 +140,7 @@ public class ConfigurationTests [Fact] public void StreamBufferSize_CannotGoBelowMinimum() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws( () => config.StreamProcessingBufferSize = 0); @@ -150,14 +150,14 @@ public class ConfigurationTests public void MemoryAllocator_Setter_Roundtrips() { MemoryAllocator customAllocator = new SimpleGcMemoryAllocator(); - var config = new Configuration() { MemoryAllocator = customAllocator }; + Configuration config = new() { MemoryAllocator = customAllocator }; Assert.Same(customAllocator, config.MemoryAllocator); } [Fact] public void MemoryAllocator_SetNull_ThrowsArgumentNullException() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws(() => config.MemoryAllocator = null); } @@ -168,9 +168,9 @@ public class ConfigurationTests static void RunTest() { - var c1 = new Configuration(); - var c2 = new Configuration(new MockConfigurationModule()); - var c3 = Configuration.CreateDefaultInstance(); + Configuration c1 = new(); + Configuration c2 = new(new MockConfigurationModule()); + Configuration c3 = Configuration.CreateDefaultInstance(); Assert.Same(MemoryAllocator.Default, Configuration.Default.MemoryAllocator); Assert.Same(MemoryAllocator.Default, c1.MemoryAllocator); diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 88f4cde7a..1d0fdf62d 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -77,11 +77,11 @@ public class DrawImageTests PngEncoder encoder; if (provider.PixelType == PixelTypes.Rgba64) { - encoder = new() { BitDepth = PngBitDepth.Bit16 }; + encoder = new PngEncoder { BitDepth = PngBitDepth.Bit16 }; } else { - encoder = new(); + encoder = new PngEncoder(); } image.DebugSave(provider, testInfo, encoder: encoder); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 09ef49a61..5ebcc8bb9 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -332,7 +332,7 @@ public class BmpEncoderTests public void Encode_PreservesColorProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image input = provider.GetImage(BmpDecoder.Instance, new()); + using Image input = provider.GetImage(BmpDecoder.Instance, new BmpDecoderOptions()); ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index d8ec7c900..00a19466a 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs @@ -11,9 +11,9 @@ public class BmpFileHeaderTests [Fact] public void TestWrite() { - var header = new BmpFileHeader(1, 2, 3, 4); + BmpFileHeader header = new(1, 2, 3, 4); - var buffer = new byte[14]; + byte[] buffer = new byte[14]; header.WriteTo(buffer); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 6593b8df7..48253bee7 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -90,7 +90,7 @@ public class GifDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 }, + TargetSize = new Size { Width = 150, Height = 150 }, MaxFrames = 1 }; @@ -257,7 +257,7 @@ public class GifDecoderTests public void Issue405_BadApplicationExtensionBlockLength(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -269,7 +269,7 @@ public class GifDecoderTests public void Issue1668_InvalidColorIndex(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -318,7 +318,7 @@ public class GifDecoderTests public void Issue1962(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -330,7 +330,7 @@ public class GifDecoderTests public void Issue2012EmptyXmp(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -381,4 +381,21 @@ public class GifDecoderTests image.DebugSaveMultiFrame(provider); image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); } + + // https://github.com/SixLabors/ImageSharp/issues/2953 + [Theory] + [WithFile(TestImages.Gif.Issues.Issue2953, PixelTypes.Rgba32)] + public void Issue2953(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + // We should throw a InvalidImageContentException when trying to identify or load an invalid GIF file. + TestFile testFile = TestFile.Create(provider.SourceFileOrDescription); + + Assert.Throws(() => Image.Identify(testFile.FullPath)); + Assert.Throws(() => Image.Load(testFile.FullPath)); + + DecoderOptions options = new() { SkipMetadata = true }; + Assert.Throws(() => Image.Identify(options, testFile.FullPath)); + Assert.Throws(() => Image.Load(options, testFile.FullPath)); + } } diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 44ed5e38d..370106ca3 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -121,7 +121,7 @@ public class GifEncoderTests // Always save as we need to compare the encoded output. provider.Utility.SaveTestOutputFile(image, "gif", encoder, "global"); - encoder = new() + encoder = new GifEncoder { ColorTableMode = FrameColorTableMode.Local, Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }), diff --git a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs index 69c6317a7..f895afbd5 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs @@ -122,7 +122,7 @@ public class CurEncoderTests { if (expectedColor != rowSpan[x]) { - var xx = 0; + int xx = 0; } diff --git a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs index e076ccab6..85ff51b18 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Ico; using SixLabors.ImageSharp.Formats.Icon; @@ -277,7 +278,7 @@ public class IcoDecoderTests [WithFile(MultiSizeF, PixelTypes.Rgba32)] public void MultiSize_CanDecodeSingleFrame(TestImageProvider provider) { - using Image image = provider.GetImage(IcoDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(IcoDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); Assert.Single(image.Frames); } @@ -293,7 +294,7 @@ public class IcoDecoderTests TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new() { MaxFrames = 1 }, stream); + ImageInfo imageInfo = Image.Identify(new DecoderOptions { MaxFrames = 1 }, stream); Assert.Single(imageInfo.FrameMetadataCollection); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index cb8f52a96..fb1e062f2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -21,7 +21,7 @@ public class Block8x8Tests : JpegFixture { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); for (int i = 0; i < Block8x8.Size; i++) { @@ -47,7 +47,7 @@ public class Block8x8Tests : JpegFixture { short[] data = Create8x8ShortData(); - var source = Block8x8.Load(data); + Block8x8 source = Block8x8.Load(data); Block8x8F dest = source.AsFloatBlock(); @@ -61,7 +61,7 @@ public class Block8x8Tests : JpegFixture public void ToArray() { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); short[] result = block.ToArray(); @@ -72,8 +72,8 @@ public class Block8x8Tests : JpegFixture public void Equality_WhenFalse() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block1[0] = 42; block2[0] = 666; @@ -96,8 +96,8 @@ public class Block8x8Tests : JpegFixture public void TotalDifference() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block2[10] += 7; block2[63] += 8; @@ -157,7 +157,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -188,7 +188,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -223,7 +223,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 7b411a28f..062a8a5ee 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -46,7 +46,7 @@ public static class DCTTests { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref srcBlock); @@ -79,7 +79,7 @@ public static class DCTTests { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref srcBlock); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs index b89d9ad27..36b792fa1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs @@ -69,7 +69,7 @@ public class HuffmanScanEncoderTests { int maxNumber = 1 << 16; - var rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { uint number = (uint)rng.Next(0, maxNumber); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 1dba8ee1c..d58ff9823 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -783,8 +783,8 @@ public class JpegColorConverterTests g /= MaxColorChannelValue; b /= MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -804,9 +804,9 @@ public class JpegColorConverterTests r /= MaxColorChannelValue; g /= MaxColorChannelValue; b /= MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -817,9 +817,9 @@ public class JpegColorConverterTests float r = values.Component0[i] / MaxColorChannelValue; float g = values.Component1[i] / MaxColorChannelValue; float b = values.Component2[i] / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -828,9 +828,9 @@ public class JpegColorConverterTests private static void ValidateGrayScale(in JpegColorConverterBase.ComponentValues values, in JpegColorConverterBase.ComponentValues result, int i) { float y = values.Component0[i] / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(y, y, y)); + Rgb expected = Rgb.Clamp(new Rgb(y, y, y)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component0[i], result.Component0[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component0[i], result.Component0[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -846,9 +846,9 @@ public class JpegColorConverterTests float r = c * k / MaxColorChannelValue; float g = m * k / MaxColorChannelValue; float b = y * k / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index 20a9ad387..11c7dc86d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -461,7 +461,7 @@ public partial class JpegDecoderTests // We want to test the encoder to ensure the determined values can be encoded but not by encoding // the full size image as it would be too slow. // We will crop the image to a smaller size and then encode it. - image.Mutate(x => x.Crop(new(0, 0, 100, 100))); + image.Mutate(x => x.Crop(new Rectangle(0, 0, 100, 100))); using MemoryStream ms = new(); image.Save(ms, new JpegEncoder()); @@ -501,7 +501,7 @@ public partial class JpegDecoderTests // the profile contains 4 duplicated UserComment Assert.Equal(1, exifProfile.Values.Count(t => t.Tag == ExifTag.UserComment)); - image.Mutate(x => x.Crop(new(0, 0, 100, 100))); + image.Mutate(x => x.Crop(new Rectangle(0, 0, 100, 100))); image.Save(ms, new JpegEncoder()); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 6df354276..8126a37fe 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -116,7 +116,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); FormattableString details = $"{options.TargetSize.Value.Width}_{options.TargetSize.Value.Height}"; @@ -136,7 +136,7 @@ public partial class JpegDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 }, + TargetSize = new Size { Width = 150, Height = 150 }, Sampler = KnownResamplers.Bicubic }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -156,7 +156,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_IDCT_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -180,7 +180,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_Scale_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -204,7 +204,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_Combined_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -372,7 +372,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -387,7 +387,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -407,7 +407,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs index df74d266c..62362ec80 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs @@ -14,7 +14,7 @@ public class JpegFileMarkerTests { const byte app1 = JpegConstants.Markers.APP1; const int position = 5; - var marker = new JpegFileMarker(app1, position); + JpegFileMarker marker = new(app1, position); Assert.Equal(app1, marker.Marker); Assert.Equal(position, marker.Position); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs index 19b5265a1..37be0f8f5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs @@ -12,8 +12,8 @@ public class JpegMetadataTests [Fact] public void CloneIsDeep() { - var meta = new JpegMetadata { ColorType = JpegColorType.Luminance }; - var clone = (JpegMetadata)meta.DeepClone(); + JpegMetadata meta = new() { ColorType = JpegColorType.Luminance }; + JpegMetadata clone = (JpegMetadata)meta.DeepClone(); clone.ColorType = JpegColorType.YCbCrRatio420; @@ -23,7 +23,7 @@ public class JpegMetadataTests [Fact] public void Quality_DefaultQuality() { - var meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.Equal(meta.Quality, ImageSharp.Formats.Jpeg.Components.Quantization.DefaultQualityFactor); } @@ -33,7 +33,7 @@ public class JpegMetadataTests { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -43,7 +43,7 @@ public class JpegMetadataTests { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality, ChrominanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality, ChrominanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -54,7 +54,7 @@ public class JpegMetadataTests int qualityLuma = 50; int qualityChroma = 30; - var meta = new JpegMetadata { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; + JpegMetadata meta = new() { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; Assert.Equal(meta.Quality, qualityLuma); } @@ -62,7 +62,7 @@ public class JpegMetadataTests [Fact] public void Comment_EmptyComment() { - var meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.True(Array.Empty().SequenceEqual(meta.Comments)); } @@ -71,9 +71,9 @@ public class JpegMetadataTests public void Comment_OnlyComment() { string comment = "test comment"; - var expectedCollection = new Collection { comment }; + Collection expectedCollection = new() { comment }; - var meta = new JpegMetadata(); + JpegMetadata meta = new(); meta.Comments.Add(JpegComData.FromString(comment)); Assert.Equal(1, meta.Comments.Count); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index b202fd9ec..b6a59fa93 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -27,7 +27,7 @@ public class ParseStreamTests [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorSpace.Cmyk)] public void ColorSpace_IsDeducedCorrectly(string imageFile, object expectedColorSpaceValue) { - var expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; + JpegColorSpace expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile, metaDataOnly: true)) { @@ -47,7 +47,7 @@ public class ParseStreamTests Assert.Equal(expectedSizeInBlocks, decoder.Frame.McuSize); - var uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); IJpegComponent c0 = decoder.Components[0]; VerifyJpeg.VerifyComponent(c0, expectedSizeInBlocks, uniform1, uniform1); } @@ -62,7 +62,7 @@ public class ParseStreamTests [InlineData(TestImages.Jpeg.Baseline.Cmyk)] public void PrintComponentData(string imageFile) { - var sb = new StringBuilder(); + StringBuilder sb = new(); using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -98,8 +98,8 @@ public class ParseStreamTests object expectedLumaFactors, object expectedChromaFactors) { - var fLuma = (Size)expectedLumaFactors; - var fChroma = (Size)expectedChromaFactors; + Size fLuma = (Size)expectedLumaFactors; + Size fChroma = (Size)expectedChromaFactors; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -110,7 +110,7 @@ public class ParseStreamTests IJpegComponent c1 = decoder.Components[1]; IJpegComponent c2 = decoder.Components[2]; - var uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); Size expectedLumaSizeInBlocks = decoder.Frame.McuSize.MultiplyBy(fLuma); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index f5d7c159b..2fcd953ae 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -53,7 +53,7 @@ public partial class ReferenceImplementationsTests { float[] sourceArray = Create8x8RandomFloatData(-range, range, seed); - var source = Block8x8F.Load(sourceArray); + Block8x8F source = Block8x8F.Load(sourceArray); Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 499cf7991..60de0a204 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -47,13 +47,13 @@ public class SpectralJpegTests byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; JpegDecoderOptions option = new(); - using var decoder = new JpegDecoderCore(option); - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using JpegDecoderCore decoder = new(option); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // internal scan decoder which we substitute to assert spectral correctness - var debugConverter = new DebugSpectralConverter(); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, debugConverter, cancellationToken: default); + DebugSpectralConverter debugConverter = new(); + HuffmanScanDecoder scanDecoder = new(bufferedStream, debugConverter, cancellationToken: default); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -77,12 +77,12 @@ public class SpectralJpegTests byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; JpegDecoderOptions options = new(); - using var decoder = new JpegDecoderCore(options); - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using JpegDecoderCore decoder = new(options); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // internal scan decoder which we substitute to assert spectral correctness - var debugConverter = new DebugSpectralConverter(); + DebugSpectralConverter debugConverter = new(); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -198,7 +198,7 @@ public class SpectralJpegTests public override void PrepareForDecoding() { - var spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; + LibJpegTools.ComponentData[] spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; for (int i = 0; i < spectralComponents.Length; i++) { JpegComponent component = this.frame.Components[i]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index b9f4a90b6..d55a25453 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -33,14 +33,14 @@ public class SpectralToPixelConversionTests { // Stream byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // Decoding JpegDecoderOptions options = new(); - using var converter = new SpectralConverter(Configuration.Default); - using var decoder = new JpegDecoderCore(options); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, converter, cancellationToken: default); + using SpectralConverter converter = new(Configuration.Default); + using JpegDecoderCore decoder = new(options); + HuffmanScanDecoder scanDecoder = new(bufferedStream, converter, cancellationToken: default); decoder.ParseStream(bufferedStream, converter, cancellationToken: default); // Test metadata @@ -48,7 +48,7 @@ public class SpectralToPixelConversionTests provider.Utility.TestName = JpegDecoderTests.DecodeBaselineJpegOutputName; // Comparison - using var image = new Image(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new ImageMetadata()); + using Image image = new(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new ImageMetadata()); using Image referenceImage = provider.GetReferenceOutputImage(appendPixelTypeToFileName: false); ImageSimilarityReport report = ImageComparer.Exact.CompareImagesOrFrames(referenceImage, image); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index a3fbe4018..33e95c5aa 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -72,7 +72,7 @@ public class JpegFixture : MeasureFixture // ReSharper disable once InconsistentNaming public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { - var rnd = new Random(seed); + Random rnd = new(seed); int[] result = new int[64]; for (int i = 0; i < 8; i++) { @@ -87,7 +87,7 @@ public class JpegFixture : MeasureFixture public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42, int xBorder = 8, int yBorder = 8) { - var rnd = new Random(seed); + Random rnd = new(seed); float[] result = new float[64]; for (int y = 0; y < yBorder; y++) { @@ -112,7 +112,7 @@ public class JpegFixture : MeasureFixture internal void Print8x8Data(Span data) { - var bld = new StringBuilder(); + StringBuilder bld = new(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -135,7 +135,7 @@ public class JpegFixture : MeasureFixture count = data.Length; } - var sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < count; i++) { sb.Append($"{data[i],3} "); @@ -158,7 +158,7 @@ public class JpegFixture : MeasureFixture internal void CompareBlocks(Span a, Span b, float tolerance) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); double totalDifference = 0.0; bool failed = false; @@ -192,7 +192,7 @@ public class JpegFixture : MeasureFixture internal static bool CompareBlocks(Span a, Span b, float tolerance, out float diff) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); bool failed = false; diff = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index bd1df3377..888459112 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -65,7 +65,7 @@ internal static partial class LibJpegTools } string args = $@"""{sourceFile}"" ""{destFile}"""; - var process = new Process + Process process = new() { StartInfo = { @@ -95,21 +95,21 @@ internal static partial class LibJpegTools { RunDumpJpegCoeffsTool(testFile.FullPath, coeffFileFullPath); - using (var dumpStream = new FileStream(coeffFileFullPath, FileMode.Open)) - using (var rdr = new BinaryReader(dumpStream)) + using (FileStream dumpStream = new(coeffFileFullPath, FileMode.Open)) + using (BinaryReader rdr = new(dumpStream)) { int componentCount = rdr.ReadInt16(); - var result = new ComponentData[componentCount]; + ComponentData[] result = new ComponentData[componentCount]; for (int i = 0; i < componentCount; i++) { int widthInBlocks = rdr.ReadInt16(); int heightInBlocks = rdr.ReadInt16(); - var resultComponent = new ComponentData(widthInBlocks, heightInBlocks, i); + ComponentData resultComponent = new(widthInBlocks, heightInBlocks, i); result[i] = resultComponent; } - var buffer = new byte[64 * sizeof(short)]; + byte[] buffer = new byte[64 * sizeof(short)]; for (int i = 0; i < result.Length; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index b6e7b29a6..2d4db15df 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -30,7 +30,7 @@ internal static partial class ReferenceImplementations public static void TransformIDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformIDCT(ref temp); result.CopyTo(span); @@ -45,7 +45,7 @@ internal static partial class ReferenceImplementations public static void TransformFDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformFDCT(ref temp); result.CopyTo(span); 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 0d5f3114d..7c7f47f94 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 @@ -208,8 +208,8 @@ internal static partial class ReferenceImplementations /*y[0] = c0 + c1; y[4] = c0 - c1;*/ - var w0 = new Vector4(0.541196f); - var w1 = new Vector4(1.306563f); + Vector4 w0 = new(0.541196f); + Vector4 w1 = new(1.306563f); _mm_store_ps(d, 16, (w0 * c2) + (w1 * c3)); @@ -242,7 +242,7 @@ internal static partial class ReferenceImplementations _mm_store_ps(d, 40, c3 - c1); // y[5] = c3 - c1; y[3] = c0 - c2; - var invsqrt2 = new Vector4(0.707107f); + Vector4 invsqrt2 = new(0.707107f); c0 = (c0 + c2) * invsqrt2; c3 = (c3 + c1) * invsqrt2; @@ -272,7 +272,7 @@ internal static partial class ReferenceImplementations FDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - var c = new Vector4(0.1250f); + Vector4 c = new(0.1250f); #pragma warning disable SA1107 // Code should not contain multiple statements on one line _mm_store_ps(d, 0, _mm_load_ps(d, 0) * c); d = d.Slice(4); // 0 @@ -318,29 +318,29 @@ internal static partial class ReferenceImplementations // Accurate variants of constants from: // https://github.com/mozilla/mozjpeg/blob/master/simd/jfdctint-altivec.c #pragma warning disable SA1309 // Field names should not begin with underscore - private static readonly Vector4 _1_175876 = new Vector4(1.175875602f); + private static readonly Vector4 _1_175876 = new(1.175875602f); - private static readonly Vector4 _1_961571 = new Vector4(-1.961570560f); + private static readonly Vector4 _1_961571 = new(-1.961570560f); - private static readonly Vector4 _0_390181 = new Vector4(-0.390180644f); + private static readonly Vector4 _0_390181 = new(-0.390180644f); - private static readonly Vector4 _0_899976 = new Vector4(-0.899976223f); + private static readonly Vector4 _0_899976 = new(-0.899976223f); - private static readonly Vector4 _2_562915 = new Vector4(-2.562915447f); + private static readonly Vector4 _2_562915 = new(-2.562915447f); - private static readonly Vector4 _0_298631 = new Vector4(0.298631336f); + private static readonly Vector4 _0_298631 = new(0.298631336f); - private static readonly Vector4 _2_053120 = new Vector4(2.053119869f); + private static readonly Vector4 _2_053120 = new(2.053119869f); - private static readonly Vector4 _3_072711 = new Vector4(3.072711026f); + private static readonly Vector4 _3_072711 = new(3.072711026f); - private static readonly Vector4 _1_501321 = new Vector4(1.501321110f); + private static readonly Vector4 _1_501321 = new(1.501321110f); - private static readonly Vector4 _0_541196 = new Vector4(0.541196100f); + private static readonly Vector4 _0_541196 = new(0.541196100f); - private static readonly Vector4 _1_847759 = new Vector4(-1.847759065f); + private static readonly Vector4 _1_847759 = new(-1.847759065f); - private static readonly Vector4 _0_765367 = new Vector4(0.765366865f); + private static readonly Vector4 _0_765367 = new(0.765366865f); #pragma warning restore SA1309 // Field names should not begin with underscore /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs index 95ab076b0..10019c609 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs @@ -71,10 +71,10 @@ internal static partial class ReferenceImplementations public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); Subtract128_TransformFDCT_Upscale8_Inplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } @@ -82,10 +82,10 @@ internal static partial class ReferenceImplementations // [Obsolete("Looks like this method produces really bad results for bigger values!")] public static Block8x8 TransformIDCT(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); TransformIDCTInplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index 240a338f9..d7c2c0bbb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -74,7 +74,7 @@ internal static class SpanExtensions /// A new with float values public static float[] ConvertAllToFloat(this int[] src) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i]; @@ -91,7 +91,7 @@ internal static class SpanExtensions /// A new instance of public static Span AddScalarToAllValues(this Span src, float scalar) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; @@ -108,7 +108,7 @@ internal static class SpanExtensions /// A new instance of public static Span AddScalarToAllValues(this Span src, int scalar) { - var result = new int[src.Length]; + int[] result = new int[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 11dd1cd58..476538ccd 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -29,11 +29,11 @@ public class PbmDecoderTests public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType, PbmComponentType expectedComponentType) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -53,11 +53,11 @@ public class PbmDecoderTests public void ImageLoadL8CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -70,11 +70,11 @@ public class PbmDecoderTests public void ImageLoadRgb24CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -108,7 +108,7 @@ public class PbmDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PbmDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 05f1d963b..0fea65f6e 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -38,16 +38,16 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_PreserveColorType(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder(); + PbmEncoder options = new(); - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); memStream.Position = 0; - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -60,15 +60,15 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_WithPlainEncoding_PreserveBitsPerPixel(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder() + PbmEncoder options = new() { Encoding = PbmEncoding.Plain }; - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); @@ -78,7 +78,7 @@ public class PbmEncoderTests Assert.Equal(0x20, lastByte); memStream.Seek(0, SeekOrigin.Begin); - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -132,13 +132,13 @@ public class PbmEncoderTests { using (Image image = provider.GetImage()) { - var encoder = new PbmEncoder { ColorType = colorType, Encoding = encoding }; + PbmEncoder encoder = new() { ColorType = colorType, Encoding = encoding }; - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); memStream.Position = 0; - using (var encodedImage = (Image)Image.Load(memStream)) + using (Image encodedImage = (Image)Image.Load(memStream)) { ImageComparingUtils.CompareWithReferenceDecoder(provider, encodedImage, useExactComparer, compareTolerance); } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs index b7ce32ed8..6524b3506 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs @@ -21,11 +21,11 @@ public class PbmRoundTripTests public void PbmGrayscaleImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image colorImage = originalImage.CloneAs(); using Image encodedImage = this.RoundTrip(colorImage); @@ -42,11 +42,11 @@ public class PbmRoundTripTests public void PbmColorImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image encodedImage = this.RoundTrip(originalImage); // Assert @@ -57,10 +57,10 @@ public class PbmRoundTripTests private Image RoundTrip(Image originalImage) where TPixel : unmanaged, IPixel { - using var decodedStream = new MemoryStream(); + using MemoryStream decodedStream = new(); originalImage.SaveAsPbm(decodedStream); decodedStream.Seek(0, SeekOrigin.Begin); - var encodedImage = Image.Load(decodedStream); + Image encodedImage = Image.Load(decodedStream); return encodedImage; } } diff --git a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs index 1b66c4cc3..53f9a0278 100644 --- a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs @@ -30,7 +30,7 @@ public class Adler32Tests { // arrange byte[] data = GetBuffer(length); - var adler = new SharpAdler32(); + SharpAdler32 adler = new(); adler.Update(data); long expected = adler.Value; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index aff8bc12a..829cc64ff 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -64,7 +64,7 @@ public partial class PngDecoderTests { string chunkName = GetChunkTypeName(chunkType); - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 4d058e54e..1a74fe5b2 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -140,7 +140,7 @@ public partial class PngDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PngDecoder.Instance, options); @@ -178,7 +178,7 @@ public partial class PngDecoderTests DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PngDecoder.Instance, options); @@ -389,7 +389,7 @@ public partial class PngDecoderTests TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new DecoderOptions() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); + ImageInfo imageInfo = Image.Identify(new DecoderOptions { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); Assert.NotNull(imageInfo); Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel); @@ -674,7 +674,7 @@ public partial class PngDecoderTests public void Binary_PrematureEof() { PngDecoder decoder = PngDecoder.Instance; - PngDecoderOptions options = new() { GeneralOptions = new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData } }; + PngDecoderOptions options = new() { GeneralOptions = new DecoderOptions { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData } }; using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(TestImages.Png.Bad.FlagOfGermany0000016446, decoder, options); // TODO: Try to reduce this to 1. diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 796d35bf7..a930426b6 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -31,7 +31,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -45,7 +45,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -59,7 +59,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -73,7 +73,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -87,7 +87,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -101,7 +101,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -115,7 +115,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -129,7 +129,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -143,7 +143,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -157,7 +157,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -171,7 +171,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -185,7 +185,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -199,7 +199,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -227,7 +227,7 @@ public class PngEncoderFilterTests : MeasureFixture this.expectedResult = new byte[1 + (size * size * bpp)]; this.resultBuffer = new byte[1 + (size * size * bpp)]; - var rng = new Random(12345678); + Random rng = new(12345678); byte[] tmp = new byte[6]; for (int i = 0; i < this.previousScanline.Length; i += bpp) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index b0d0563cc..f1dcb357c 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -680,7 +680,7 @@ public partial class PngEncoderTests PaletteQuantizer quantizer = new( palette.Select(Color.FromPixel).ToArray(), - new QuantizerOptions() { ColorMatchingMode = ColorMatchingMode.Hybrid }); + new QuantizerOptions { ColorMatchingMode = ColorMatchingMode.Hybrid }); using MemoryStream ms = new(); image.Save(ms, new PngEncoder diff --git a/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs index 8fde21654..efc18c16a 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs @@ -14,7 +14,7 @@ public class PngFrameMetadataTests { PngFrameMetadata meta = new() { - FrameDelay = new(1, 0), + FrameDelay = new Rational(1, 0), DisposalMode = FrameDisposalMode.RestoreToBackground, BlendMode = FrameBlendMode.Over, }; @@ -25,7 +25,7 @@ public class PngFrameMetadataTests Assert.True(meta.DisposalMode.Equals(clone.DisposalMode)); Assert.True(meta.BlendMode.Equals(clone.BlendMode)); - clone.FrameDelay = new(2, 1); + clone.FrameDelay = new Rational(2, 1); clone.DisposalMode = FrameDisposalMode.RestoreToPrevious; clone.BlendMode = FrameBlendMode.Source; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 225e4deef..5cbc27611 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -31,7 +31,7 @@ public class PngMetadataTests ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List { new PngTextData("name", "value", "foo", "bar") }, + TextData = new List { new("name", "value", "foo", "bar") }, RepeatCount = 123, AnimateRootFrame = false }; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs index 878f3fb8d..4c46692f3 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs @@ -17,8 +17,8 @@ public class PngTextDataTests [Fact] public void AreEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Bar", "foo", "bar"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Bar", "foo", "bar"); Assert.Equal(property1, property2); Assert.True(property1 == property2); @@ -30,10 +30,10 @@ public class PngTextDataTests [Fact] public void AreNotEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Foo", string.Empty, string.Empty); - var property3 = new PngTextData("Bar", "Bar", "unit", "test"); - var property4 = new PngTextData("Foo", null, "test", "case"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Foo", string.Empty, string.Empty); + PngTextData property3 = new("Bar", "Bar", "unit", "test"); + PngTextData property4 = new("Foo", null, "test", "case"); Assert.NotEqual(property1, property2); Assert.True(property1 != property2); @@ -59,7 +59,7 @@ public class PngTextDataTests [Fact] public void ConstructorAssignsProperties() { - var property = new PngTextData("Foo", null, "unit", "test"); + PngTextData property = new("Foo", null, "unit", "test"); Assert.Equal("Foo", property.Keyword); Assert.Null(property.Value); Assert.Equal("unit", property.LanguageTag); diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index dbd7885e5..03669908e 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -749,7 +749,7 @@ public class TgaDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(TgaDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs index 4646de7f8..d19f27807 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs @@ -16,7 +16,7 @@ public class BigTiffMetadataTests [Fact] public void ExifLong8() { - var long8 = new ExifLong8(ExifTagValue.StripByteCounts); + ExifLong8 long8 = new(ExifTagValue.StripByteCounts); Assert.True(long8.TrySetValue(0)); Assert.Equal(0UL, long8.GetValue()); @@ -34,7 +34,7 @@ public class BigTiffMetadataTests [Fact] public void ExifSignedLong8() { - var long8 = new ExifSignedLong8(ExifTagValue.ImageID); + ExifSignedLong8 long8 = new(ExifTagValue.ImageID); Assert.False(long8.TrySetValue(0)); @@ -53,7 +53,7 @@ public class BigTiffMetadataTests [Fact] public void ExifLong8Array() { - var long8 = new ExifLong8Array(ExifTagValue.StripOffsets); + ExifLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue((short)-123)); Assert.Equal(new[] { 0UL }, long8.GetValue()); @@ -91,7 +91,7 @@ public class BigTiffMetadataTests [Fact] public void ExifSignedLong8Array() { - var long8 = new ExifSignedLong8Array(ExifTagValue.StripOffsets); + ExifSignedLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue(new[] { 0L })); Assert.Equal(new[] { 0L }, long8.GetValue()); @@ -105,9 +105,9 @@ public class BigTiffMetadataTests [Fact] public void NotCoveredTags() { - using var input = new Image(10, 10); + using Image input = new(10, 10); - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd01), (ExifDataType.SingleFloat, new float[] { 1.2f, 2.3f, 4.5f }) }, { new ExifTag((ExifTagValue)0xdd02), (ExifDataType.SingleFloat, 2.345f) }, @@ -122,7 +122,7 @@ public class BigTiffMetadataTests }; // arrange - var values = new List(); + List values = new(); foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -134,13 +134,13 @@ public class BigTiffMetadataTests input.Frames.RootFrame.Metadata.ExifProfile = new ExifProfile(values, Array.Empty()); // act - var encoder = new TiffEncoder(); - using var memStream = new MemoryStream(); + TiffEncoder encoder = new(); + using MemoryStream memStream = new(); input.Save(memStream, encoder); // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageFrameMetadata loadedFrameMetadata = output.Frames.RootFrame.Metadata; foreach (KeyValuePair tag in testTags) { @@ -158,7 +158,7 @@ public class BigTiffMetadataTests [Fact] public void NotCoveredTags64bit() { - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd11), (ExifDataType.Long8, ulong.MaxValue) }, { new ExifTag((ExifTagValue)0xdd12), (ExifDataType.SignedLong8, long.MaxValue) }, @@ -167,7 +167,7 @@ public class BigTiffMetadataTests ////{ new ExifTag((ExifTagValue)0xdd14), (ExifDataType.SignedLong8, new long[] { -1234, 56789L, long.MaxValue }) }, }; - var values = new List(); + List values = new(); foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -179,7 +179,7 @@ public class BigTiffMetadataTests // act byte[] inputBytes = WriteIfdTags64Bit(values); Configuration config = Configuration.Default; - var reader = new EntryReader( + EntryReader reader = new( new MemoryStream(inputBytes), BitConverter.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian, config.MemoryAllocator); @@ -205,8 +205,8 @@ public class BigTiffMetadataTests private static byte[] WriteIfdTags64Bit(List values) { byte[] buffer = new byte[8]; - var ms = new MemoryStream(); - var writer = new TiffStreamWriter(ms); + MemoryStream ms = new(); + TiffStreamWriter writer = new(ms); WriteLong8(writer, buffer, (ulong)values.Count); foreach (IExifValue entry in values) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs index b16119f33..cc2faeab7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs @@ -23,7 +23,7 @@ public class DeflateTiffCompressionTests using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new DeflateTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); + using DeflateTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs index 8c21e346a..25c9633c1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs @@ -37,7 +37,7 @@ public class LzwTiffCompressionTests using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new LzwTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); + using LzwTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); Assert.Equal(data, buffer); @@ -47,7 +47,7 @@ public class LzwTiffCompressionTests { Stream compressedStream = new MemoryStream(); - using (var encoder = new TiffLzwEncoder(Configuration.Default.MemoryAllocator)) + using (TiffLzwEncoder encoder = new(Configuration.Default.MemoryAllocator)) { encoder.Encode(inputData, compressedStream); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs index e79ed7ce7..b911d1b17 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs @@ -14,11 +14,11 @@ public class NoneTiffCompressionTests [InlineData(new byte[] { 10, 15, 20, 25, 30, 35, 40, 45 }, 5, new byte[] { 10, 15, 20, 25, 30 })] public void Decompress_ReadsData(byte[] inputData, uint byteCount, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new NoneTiffCompression(default, default, default); + using NoneTiffCompression decompressor = new(default, default, default); decompressor.Decompress(stream, 0, byteCount, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs index c91ab0e7f..8f71cdda7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs @@ -22,11 +22,11 @@ public class PackBitsTiffCompressionTests [InlineData(new byte[] { 0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA }, new byte[] { 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA })] // Apple PackBits sample public void Decompress_ReadsData(byte[] inputData, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); + using PackBitsTiffCompression decompressor = new(MemoryAllocator.Create(), default, default); decompressor.Decompress(stream, 0, (uint)inputData.Length, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index c809c6c7f..13be77a29 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -88,7 +88,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase private static uint[][] GeneratePalette(int count) { - var palette = new uint[count][]; + uint[][] palette = new uint[count][]; for (uint i = 0; i < count; i++) { @@ -101,7 +101,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase private static ushort[] GenerateColorMap(uint[][] colorPalette) { int colorCount = colorPalette.Length; - var colorMap = new ushort[colorCount * 3]; + ushort[] colorMap = new ushort[colorCount * 3]; for (int i = 0; i < colorCount; i++) { @@ -115,7 +115,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase private static Rgba32[][] GenerateResult(uint[][] colorPalette, int[][] pixelLookup) { - var result = new Rgba32[pixelLookup.Length][]; + Rgba32[][] result = new Rgba32[pixelLookup.Length][]; for (int y = 0; y < pixelLookup.Length; y++) { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index 3582dc75a..7040e167d 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -10,14 +10,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public abstract class PhotometricInterpretationTestBase { - public static Rgba32 DefaultColor = new Rgba32(42, 96, 18, 128); + public static Rgba32 DefaultColor = new(42, 96, 18, 128); public static Rgba32[][] Offset(Rgba32[][] input, int xOffset, int yOffset, int width, int height) { int inputHeight = input.Length; int inputWidth = input[0].Length; - var output = new Rgba32[height][]; + Rgba32[][] output = new Rgba32[height][]; for (int y = 0; y < output.Length; y++) { @@ -45,7 +45,7 @@ public abstract class PhotometricInterpretationTestBase int resultWidth = expectedResult[0].Length; int resultHeight = expectedResult.Length; - using (var image = new Image(resultWidth, resultHeight)) + using (Image image = new(resultWidth, resultHeight)) { image.Mutate(x => x.BackgroundColor(Color.FromPixel(DefaultColor))); Buffer2D pixels = image.GetRootFramePixelBuffer(); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index d8249c361..2ca9df3d0 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -12,19 +12,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4R = { @@ -112,19 +112,19 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4R = { @@ -175,19 +175,19 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4R = { @@ -251,7 +251,7 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase expectedResult, pixels => { - var buffers = new IMemoryOwner[inputData.Length]; + IMemoryOwner[] buffers = new IMemoryOwner[inputData.Length]; for (int i = 0; i < buffers.Length; i++) { buffers[i] = Configuration.Default.MemoryAllocator.Allocate(inputData[i].Length); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs index aeb135773..80a04a7d1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs @@ -10,19 +10,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4 = { @@ -74,19 +74,19 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4 = { @@ -116,19 +116,19 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4 = { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index 0b58e3891..fa193c184 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -10,14 +10,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Gray000 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray128 = new Rgba32(127, 127, 127, 255); - private static readonly Rgba32 Gray255 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Gray0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray8 = new Rgba32(119, 119, 119, 255); - private static readonly Rgba32 GrayF = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Bit0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Bit1 = new Rgba32(0, 0, 0, 255); + private static readonly Rgba32 Gray000 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray128 = new(127, 127, 127, 255); + private static readonly Rgba32 Gray255 = new(0, 0, 0, 255); + private static readonly Rgba32 Gray0 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray8 = new(119, 119, 119, 255); + private static readonly Rgba32 GrayF = new(0, 0, 0, 255); + private static readonly Rgba32 Bit0 = new(255, 255, 255, 255); + private static readonly Rgba32 Bit1 = new(0, 0, 0, 255); private static readonly byte[] BilevelBytes4X4 = { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index a16b26f9e..5dd1f7884 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -810,7 +810,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(TiffDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs index 1bf9f5a40..158a0d473 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs @@ -26,9 +26,9 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { // arrange - var tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; + TiffEncoder tiffEncoder = new() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); TiffFrameMetadata inputMeta = input.Frames.RootFrame.Metadata.GetTiffMetadata(); TiffCompression inputCompression = inputMeta.Compression; @@ -37,7 +37,7 @@ public abstract class TiffEncoderBaseTester // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ExifProfile exifProfileOutput = output.Frames.RootFrame.Metadata.ExifProfile; TiffFrameMetadata outputMeta = output.Frames.RootFrame.Metadata.GetTiffMetadata(); ImageFrame rootFrame = output.Frames.RootFrame; @@ -89,7 +89,7 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = photometricInterpretation, BitsPerPixel = bitsPerPixel, diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs index 716b978a7..9f6e74183 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs @@ -46,7 +46,7 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, @@ -69,27 +69,27 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester using Image image = provider.GetImage(); Assert.Equal(1, image.Frames.Count); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image1.Frames.RootFrame); image.Frames.AddFrame(image2.Frames.RootFrame); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Deflate }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new()) { image.Save(ms, encoder); ms.Position = 0; - using var output = Image.Load(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); @@ -121,11 +121,11 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester { using Image image = provider.GetImage(); - using var image0 = new Image(image.Width, image.Height, Color.Red.ToPixel()); + using Image image0 = new(image.Width, image.Height, Color.Red.ToPixel()); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image0.Frames.RootFrame); image.Frames.AddFrame(image1.Frames.RootFrame); @@ -133,19 +133,19 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit8; - var encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.PaletteColor, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Lzw }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new()) { image.Save(ms, encoder); ms.Position = 0; - using var output = Image.Load(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 9b26ab270..939baeeb6 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs @@ -11,8 +11,8 @@ public class TiffWriterTests [Fact] public void IsLittleEndian_IsTrueOnWindows() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); Assert.True(TiffStreamWriter.IsLittleEndian); } @@ -22,8 +22,8 @@ public class TiffWriterTests [InlineData(new byte[] { 1, 2, 3, 4, 5 }, 5)] public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(data); Assert.Equal(writer.Position, expectedResult); } @@ -31,8 +31,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByte() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(42); Assert.Equal(new byte[] { 42 }, stream.ToArray()); @@ -41,8 +41,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByteArray() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(new byte[] { 2, 4, 6, 8 }); Assert.Equal(new byte[] { 2, 4, 6, 8 }, stream.ToArray()); @@ -51,8 +51,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt16() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(1234, stackalloc byte[2]); Assert.Equal(new byte[] { 0xD2, 0x04 }, stream.ToArray()); @@ -61,8 +61,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt32() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(12345678U, stackalloc byte[4]); Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray()); @@ -78,8 +78,8 @@ public class TiffWriterTests public void WritePadded_WritesByteArray(byte[] bytes, byte[] expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.WritePadded(bytes); Assert.Equal(expectedResult, stream.ToArray()); @@ -88,10 +88,10 @@ public class TiffWriterTests [Fact] public void WriteMarker_WritesToPlacedPosition() { - using var stream = new MemoryStream(); + using MemoryStream stream = new(); Span buffer = stackalloc byte[4]; - using (var writer = new TiffStreamWriter(stream)) + using (TiffStreamWriter writer = new(stream)) { writer.Write(0x11111111, buffer); long marker = writer.PlaceMarker(buffer); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 4551e3e23..09aa94c75 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -89,7 +89,7 @@ public class LosslessUtilsTests 392450, 196861, 16712192, 16711680, 130564, 16451071 }; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, @@ -121,7 +121,7 @@ public class LosslessUtilsTests 16711680, 65027, 16712962 }; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs index a18eff73c..990c58385 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs @@ -13,7 +13,7 @@ public class Vp8HistogramTests { get { - var result = new List(); + List result = new(); result.Add(new object[] { new byte[] @@ -69,7 +69,7 @@ public class Vp8HistogramTests private static void RunCollectHistogramTest() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); byte[] reference = { @@ -172,7 +172,7 @@ public class Vp8HistogramTests public void GetAlpha_WithEmptyHistogram_Works() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); // act int alpha = histogram.GetAlpha(); @@ -186,7 +186,7 @@ public class Vp8HistogramTests public void GetAlpha_Works(byte[] reference, byte[] pred) { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); histogram.CollectHistogram(reference, pred, 0, 1); // act @@ -201,9 +201,9 @@ public class Vp8HistogramTests public void Merge_Works(byte[] reference, byte[] pred) { // arrange - var histogram1 = new Vp8Histogram(); + Vp8Histogram histogram1 = new(); histogram1.CollectHistogram(reference, pred, 0, 1); - var histogram2 = new Vp8Histogram(); + Vp8Histogram histogram2 = new(); histogram1.Merge(histogram2); // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs index cfe79e49e..7777c6108 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs @@ -66,18 +66,14 @@ public class Vp8LHistogramTests // All remaining values are expected to be zero. literals.AsSpan().CopyTo(expectedLiterals); - Vp8LBackwardRefs backwardRefs = new(pixelData.Length); + MemoryAllocator memoryAllocator = Configuration.Default.MemoryAllocator; + + using Vp8LBackwardRefs backwardRefs = new(memoryAllocator, pixelData.Length); for (int i = 0; i < pixelData.Length; i++) { - backwardRefs.Add(new PixOrCopy() - { - BgraOrDistance = pixelData[i], - Len = 1, - Mode = PixOrCopyMode.Literal - }); + backwardRefs.Add(PixOrCopy.CreateLiteral(pixelData[i])); } - MemoryAllocator memoryAllocator = Configuration.Default.MemoryAllocator; using OwnedVp8LHistogram histogram0 = OwnedVp8LHistogram.Create(memoryAllocator, backwardRefs, 3); using OwnedVp8LHistogram histogram1 = OwnedVp8LHistogram.Create(memoryAllocator, backwardRefs, 3); for (int i = 0; i < 5; i++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs index 0b85ececb..ded637967 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs @@ -11,7 +11,7 @@ public class Vp8ModeScoreTests [Fact] public void InitScore_Works() { - var score = new Vp8ModeScore(); + Vp8ModeScore score = new(); score.InitScore(); Assert.Equal(0, score.D); Assert.Equal(0, score.SD); @@ -25,7 +25,7 @@ public class Vp8ModeScoreTests public void CopyScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -36,7 +36,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore(); + Vp8ModeScore score2 = new(); score2.InitScore(); // act @@ -55,7 +55,7 @@ public class Vp8ModeScoreTests public void AddScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -66,7 +66,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore + Vp8ModeScore score2 = new() { Score = 123, Nz = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 1ffbd9f55..111544f7f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -349,7 +349,7 @@ public class WebpDecoderTests WebpDecoderOptions options = new() { BackgroundColorHandling = BackgroundColorHandling.Ignore, - GeneralOptions = new DecoderOptions() + GeneralOptions = new DecoderOptions { MaxFrames = 1 } @@ -388,7 +388,7 @@ public class WebpDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(WebpDecoder.Instance, options); @@ -460,7 +460,7 @@ public class WebpDecoderTests // Web using Image image = provider.GetImage( WebpDecoder.Instance, - new WebpDecoderOptions() { BackgroundColorHandling = BackgroundColorHandling.Ignore }); + new WebpDecoderOptions { BackgroundColorHandling = BackgroundColorHandling.Ignore }); // We can't use the reference decoder here. // It creates frames of different size without blending the frames. diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs index af6f7eea1..f9836ffb1 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs @@ -139,14 +139,14 @@ public class WebpEncoderTests }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "octree"); - gifEncoder = new GifEncoder() + gifEncoder = new GifEncoder { Quantizer = new WuQuantizer(options) }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "wu"); // Now clone and quantize the image using the same quantizers without alpha thresholding and save as webp. - options = new() + options = new QuantizerOptions { TransparencyThreshold = 0 }; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs index ab8fef60f..020b42f37 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs @@ -103,9 +103,9 @@ public class WebpMetaDataTests public void Encode_WritesExifWithPadding(WebpFileFormatType fileFormatType) { // arrange - using var input = new Image(25, 25); - using var memoryStream = new MemoryStream(); - var expectedExif = new ExifProfile(); + using Image input = new(25, 25); + using MemoryStream memoryStream = new(); + ExifProfile expectedExif = new(); string expectedSoftware = "ImageSharp"; expectedExif.SetValue(ExifTag.Software, expectedSoftware); input.Metadata.ExifProfile = expectedExif; @@ -115,7 +115,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -129,7 +129,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -137,7 +137,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -150,7 +150,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -158,7 +158,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -174,14 +174,14 @@ public class WebpMetaDataTests ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, new WebpEncoder() { FileFormat = fileFormat }); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageSharp.Metadata.Profiles.Icc.IccProfile actualProfile = output.Metadata.IccProfile; byte[] actualProfileBytes = actualProfile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index f50bc8933..6a46b26f2 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -19,7 +19,7 @@ public class YuvConversionTests public static void RunUpSampleYuvToRgbTest() { - var provider = TestImageProvider.File(TestImageLossyFullPath); + TestImageProvider provider = TestImageProvider.File(TestImageLossyFullPath); using Image image = provider.GetImage(WebpDecoder.Instance); image.DebugSave(provider); image.CompareToOriginal(provider, ReferenceDecoder); diff --git a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs index d663a803b..682f5373d 100644 --- a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs @@ -12,9 +12,9 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnProcessingContext() { - var option = new GraphicsOptions(); - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + GraphicsOptions option = new(); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); @@ -26,12 +26,12 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); context.SetGraphicsOptions(o => @@ -40,7 +40,7 @@ public class GraphicOptionsDefaultsExtensionsTests o.BlendPercentage = 0.4f; }); - var returnedOption = context.GetGraphicsOptions(); + GraphicsOptions returnedOption = context.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -48,8 +48,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnConfiguration() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); @@ -59,11 +59,11 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - var config = new Configuration(); + Configuration config = new(); config.SetGraphicsOptions(option); config.SetGraphicsOptions(o => @@ -72,7 +72,7 @@ public class GraphicOptionsDefaultsExtensionsTests o.BlendPercentage = 0.4f; }); - var returnedOption = config.GetGraphicsOptions(); + GraphicsOptions returnedOption = config.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -80,13 +80,13 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_SettingNullThenReturnsNewInstance() { - var config = new Configuration(); + Configuration config = new(); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); config.SetGraphicsOptions((GraphicsOptions)null); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.NotNull(options2); // we set it to null should now be a new instance @@ -96,10 +96,10 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); + Configuration config = new(); config.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } @@ -107,63 +107,63 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsInstance() { - var config = new Configuration(); + Configuration config = new(); Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); } [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsSameValue() { - var config = new Configuration(); + Configuration config = new(); - var options = config.GetGraphicsOptions(); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.Equal(options, options2); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstanceEvenIfSetToNull() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions((GraphicsOptions)null); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.Equal(option, ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = context.GetGraphicsOptions(); + GraphicsOptions options = context.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } diff --git a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs index 353159986..0ccb80d3f 100644 --- a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs @@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Tests; public class GraphicsOptionsTests { - private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new GraphicsOptionsComparer(); - private readonly GraphicsOptions newGraphicsOptions = new GraphicsOptions(); + private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new(); + private readonly GraphicsOptions newGraphicsOptions = new(); private readonly GraphicsOptions cloneGraphicsOptions = new GraphicsOptions().DeepClone(); [Fact] @@ -57,7 +57,7 @@ public class GraphicsOptionsTests [Fact] public void NonDefaultClone() { - var expected = new GraphicsOptions + GraphicsOptions expected = new() { AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop, Antialias = false, @@ -74,7 +74,7 @@ public class GraphicsOptionsTests [Fact] public void CloneIsDeep() { - var expected = new GraphicsOptions(); + GraphicsOptions expected = new(); GraphicsOptions actual = expected.DeepClone(); actual.AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop; diff --git a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs index 4c06d0cd5..1bf137f34 100644 --- a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs @@ -15,7 +15,7 @@ public class ColorNumericsTests public void GetBT709Luminance_WithVector4(float x, float y, float z, int luminanceLevels, int expected) { // arrange - var vector = new Vector4(x, y, z, 0.0f); + Vector4 vector = new(x, y, z, 0.0f); // act int actual = ColorNumerics.GetBT709Luminance(ref vector, luminanceLevels); diff --git a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs index 75f988a4c..1106144c4 100644 --- a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs @@ -9,7 +9,7 @@ public class NumericsTests { private delegate void SpanAction(Span span, TArg arg, TArg1 arg1); - private readonly ApproximateFloatComparer approximateFloatComparer = new ApproximateFloatComparer(1e-6f); + private readonly ApproximateFloatComparer approximateFloatComparer = new(1e-6f); [Theory] [InlineData(0)] @@ -162,7 +162,7 @@ public class NumericsTests [InlineData(63)] public void PremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -182,7 +182,7 @@ public class NumericsTests [InlineData(63)] public void UnPremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -280,7 +280,7 @@ public class NumericsTests { Span actual = new T[length]; - var r = new Random(); + Random r = new(); for (int i = 0; i < length; i++) { actual[i] = (T)Convert.ChangeType(r.Next(byte.MinValue, byte.MaxValue), typeof(T)); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs index c13a30052..983c3cc2b 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs @@ -28,7 +28,7 @@ public class ParallelExecutionSettingsTests } else { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, Configuration.Default.MemoryAllocator); Assert.Equal(maxDegreeOfParallelism, parallelSettings.MaxDegreeOfParallelism); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs index d393850d6..4b06f877f 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs @@ -26,7 +26,7 @@ public class ParallelRowIteratorTests /// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength /// public static TheoryData IterateRows_OverMinimumPixelsLimit_Data = - new TheoryData + new() { { 1, 0, 100, -1, 100, 1 }, { 2, 0, 9, 5, 4, 2 }, @@ -52,12 +52,12 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -73,7 +73,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -93,15 +93,15 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows) { @@ -111,7 +111,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -131,12 +131,12 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -152,7 +152,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -172,15 +172,15 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows, Span buffer) { @@ -190,7 +190,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -201,7 +201,7 @@ public class ParallelRowIteratorTests } public static TheoryData IterateRows_WithEffectiveMinimumPixelsLimit_Data = - new TheoryData + new() { { 2, 200, 50, 2, 1, -1, 2 }, { 2, 200, 200, 1, 1, -1, 1 }, @@ -223,12 +223,12 @@ public class ParallelRowIteratorTests int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -244,7 +244,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -265,12 +265,12 @@ public class ParallelRowIteratorTests int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -286,7 +286,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -297,7 +297,7 @@ public class ParallelRowIteratorTests } public static readonly TheoryData IterateRectangularBuffer_Data = - new TheoryData + new() { { 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox { 2, 582, 453, 10, 10, 291, 226 }, @@ -322,7 +322,7 @@ public class ParallelRowIteratorTests using (Buffer2D expected = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) using (Buffer2D actual = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) { - var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); + Rectangle rect = new(rectX, rectY, rectWidth, rectHeight); void FillRow(int y, Buffer2D buffer) { @@ -339,7 +339,7 @@ public class ParallelRowIteratorTests } // Fill actual data using IterateRows: - var settings = new ParallelExecutionSettings(maxDegreeOfParallelism, memoryAllocator); + ParallelExecutionSettings settings = new(maxDegreeOfParallelism, memoryAllocator); void RowAction(RowInterval rows) { @@ -350,7 +350,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rect, @@ -369,15 +369,15 @@ public class ParallelRowIteratorTests [InlineData(10, -10)] public void IterateRowsRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals(rect, in parallelSettings, in operation)); @@ -392,15 +392,15 @@ public class ParallelRowIteratorTests [InlineData(10, -10)] public void IterateRowsWithTempBufferRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows, Span memory) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals, Rgba32>(rect, in parallelSettings, in operation)); @@ -434,7 +434,7 @@ public class ParallelRowIteratorTests { } - public StrongBox MaxY { get; } = new StrongBox(); + public StrongBox MaxY { get; } = new(); public void Invoke(int y) { diff --git a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs index 95f1d4e28..215cd58bc 100644 --- a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs +++ b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs @@ -10,7 +10,7 @@ public class RowIntervalTests [Fact] public void Slice1() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(5); Assert.Equal(15, sliced.Min); @@ -20,7 +20,7 @@ public class RowIntervalTests [Fact] public void Slice2() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(3, 5); Assert.Equal(13, sliced.Min); @@ -30,8 +30,8 @@ public class RowIntervalTests [Fact] public void Equality_WhenTrue() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 123); Assert.True(a.Equals(b)); Assert.True(a.Equals((object)b)); @@ -42,9 +42,9 @@ public class RowIntervalTests [Fact] public void Equality_WhenFalse() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 125); - var c = new RowInterval(40, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 125); + RowInterval c = new(40, 123); Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); diff --git a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs index 64f79840c..0cacbdc87 100644 --- a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs +++ b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers; public class TolerantMathTests { - private readonly TolerantMath tolerantMath = new TolerantMath(0.1); + private readonly TolerantMath tolerantMath = new(0.1); [Theory] [InlineData(0)] diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 25674e6a8..0680c9a82 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -10,7 +10,7 @@ public class ImageCloneTests [Fact] public void CloneAs_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.CloneAs()); @@ -19,7 +19,7 @@ public class ImageCloneTests [Fact] public void Clone_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.Clone()); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs index 14c38d1f7..887a67dd3 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Globalization; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests; @@ -14,7 +15,7 @@ public abstract partial class ImageFrameCollectionTests : IDisposable public ImageFrameCollectionTests() { // Needed to get English exception messages, which are checked in several tests. - System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); + System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); this.Image = new Image(10, 10); this.Collection = new ImageFrameCollection(this.Image, 10, 10, default(Rgba32)); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs index ef5b5f4de..f8146363c 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs @@ -16,7 +16,7 @@ public class ImageFrameTests private void LimitBufferCapacity(int bufferCapacityInBytes) { - var allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.BufferCapacityInBytes = bufferCapacityInBytes; this.configuration.MemoryAllocator = allocator; } @@ -31,7 +31,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; Rgba32 val = frame[3, 4]; Assert.Equal(default(Rgba32), val); @@ -40,7 +40,7 @@ public class ImageFrameTests Assert.Equal(Color.Red.ToPixel(), val); } - public static TheoryData OutOfRangeData = new TheoryData() + public static TheoryData OutOfRangeData = new() { { false, -1 }, { false, 10 }, @@ -57,7 +57,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => _ = frame[x, 3]); Assert.Equal("x", ex.ParamName); @@ -72,7 +72,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[x, 3] = default); Assert.Equal("x", ex.ParamName); @@ -87,7 +87,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[3, y] = default); Assert.Equal("y", ex.ParamName); @@ -105,7 +105,7 @@ public class ImageFrameTests this.LimitBufferCapacity(20); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); if (disco) { Assert.True(image.GetPixelMemoryGroup().Count > 1); @@ -131,7 +131,7 @@ public class ImageFrameTests [InlineData(true)] public void CopyPixelDataTo_DestinationTooShort_Throws(bool byteSpan) { - using var image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); Assert.ThrowsAny(() => { @@ -173,7 +173,7 @@ public class ImageFrameTests [Fact] public void NullReference_Throws() { - using var img = new Image(1, 1); + using Image img = new(1, 1); ImageFrame frame = img.Frames.RootFrame; Assert.Throws(() => frame.ProcessPixelRows(null)); diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index f9c01ab56..e2f3c6337 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -32,7 +32,7 @@ public class ImageSaveTests : IDisposable this.encoderNotInFormat = new Mock(); this.fileSystem = new Mock(); - var config = new Configuration + Configuration config = new() { FileSystem = this.fileSystem.Object }; diff --git a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs index f9a68c8bf..a1966e2bb 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs @@ -114,7 +114,7 @@ public partial class ImageTests { DecoderOptions options = new() { - Configuration = new() + Configuration = new Configuration() }; Assert.Throws(() => Image.DetectFormat(options, this.DataStream)); @@ -145,7 +145,7 @@ public partial class ImageTests { DecoderOptions options = new() { - Configuration = new() + Configuration = new Configuration() }; return Assert.ThrowsAsync(async () => await Image.DetectFormatAsync(options, new AsyncStreamWrapper(this.DataStream, () => false))); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 7f6651d90..6a196fd16 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -131,7 +131,7 @@ public partial class ImageTests [Fact] public void WhenNoMatchingFormatFound_Throws_UnknownImageFormatException() { - DecoderOptions options = new() { Configuration = new() }; + DecoderOptions options = new() { Configuration = new Configuration() }; Assert.Throws(() => Image.Identify(options, this.DataStream)); } @@ -279,7 +279,7 @@ public partial class ImageTests [Fact] public Task WhenNoMatchingFormatFoundAsync_Throws_UnknownImageFormatException() { - DecoderOptions options = new() { Configuration = new() }; + DecoderOptions options = new() { Configuration = new Configuration() }; AsyncStreamWrapper asyncStream = new(this.DataStream, () => false); return Assert.ThrowsAsync(async () => await Image.IdentifyAsync(options, asyncStream)); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index 51e2a01a2..b0875a1e6 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs @@ -35,7 +35,7 @@ public partial class ImageTests public Configuration LocalConfiguration { get; } - public TestFormat TestFormat { get; } = new TestFormat(); + public TestFormat TestFormat { get; } = new(); /// /// Gets the top-level configuration in the context of this test case. @@ -58,7 +58,7 @@ public partial class ImageTests // TODO: Remove all this mocking. It's too complicated and we can now use fakes. this.localStreamReturnImageRgba32 = new Image(1, 1); this.localStreamReturnImageAgnostic = new Image(1, 1); - this.LocalImageInfo = new(new(1, 1), new ImageMetadata() { DecodedImageFormat = PngFormat.Instance }); + this.LocalImageInfo = new ImageInfo(new Size(1, 1), new ImageMetadata { DecodedImageFormat = PngFormat.Instance }); this.localImageFormatMock = new Mock(); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs index 9b9f968bb..a03157822 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private static readonly byte[] Data = new byte[] { 0x01 }; - private MemoryStream Stream { get; } = new MemoryStream(Data); + private MemoryStream Stream { get; } = new(Data); [Fact] public void Image_Load_Throws_UnknownImageFormatException() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index e3c4a7df1..6322e65aa 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -39,7 +39,7 @@ public partial class ImageTests } this.bitmap = bitmap; - var rectangle = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height); + System.Drawing.Rectangle rectangle = new(0, 0, bitmap.Width, bitmap.Height); this.bmpData = bitmap.LockBits(rectangle, ImageLockMode.ReadWrite, bitmap.PixelFormat); this.length = bitmap.Width * bitmap.Height; } @@ -124,13 +124,13 @@ public partial class ImageTests [Fact] public void WrapMemory_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[25]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[25]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -149,22 +149,22 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory memory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) { Assert.Equal(memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -195,19 +195,19 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - var memoryManager = new BitmapMemoryManager(bmp); + BitmapMemoryManager memoryManager = new(bmp); Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) { Assert.Equal(memoryManager.Memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -227,13 +227,13 @@ public partial class ImageTests [Fact] public void WrapMemory_FromBytes_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new byte[25 * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[25 * Unsafe.SizeOf()]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -252,16 +252,16 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Memory byteMemory = new CastMemoryManager(pixelMemory).Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -276,7 +276,7 @@ public partial class ImageTests image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -300,16 +300,16 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public unsafe void WrapMemory_Throws_OnTooLessWrongSize(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; Exception thrownException = null; fixed (void* ptr = array) { try { - using var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); + using Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); } catch (Exception e) { @@ -328,14 +328,14 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public unsafe void WrapMemory_FromPointer_CreatedImageIsCorrect(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; fixed (void* ptr = array) { - using (var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) + using (Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); Span imageSpan = imageMem.Span; @@ -359,9 +359,9 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); @@ -369,7 +369,7 @@ public partial class ImageTests fixed (void* p = pixelMemory.Span) { - using (var image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -381,7 +381,7 @@ public partial class ImageTests image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -407,8 +407,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -421,8 +421,8 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } @@ -443,8 +443,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -457,10 +457,10 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -469,7 +469,7 @@ public partial class ImageTests { for (int i = 0; i < height; ++i) { - var arrayIndex = width * i; + int arrayIndex = width * i; Span rowSpan = accessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -490,8 +490,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new TestMemoryOwner { Memory = array }; + byte[] array = new byte[size * Unsafe.SizeOf()]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -504,11 +504,11 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfByte_ValidSize(int size, int height, int width) { - var pixelSize = Unsafe.SizeOf(); - var array = new byte[size * pixelSize]; - var memory = new TestMemoryOwner { Memory = array }; + int pixelSize = Unsafe.SizeOf(); + byte[] array = new byte[size * pixelSize]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -517,7 +517,7 @@ public partial class ImageTests { for (int i = 0; i < height; ++i) { - var arrayIndex = pixelSize * width * i; + int arrayIndex = pixelSize * width * i; Span rowSpan = acccessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -538,8 +538,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -552,8 +552,8 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfByte_ValidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } diff --git a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs index 12caa6e7a..8d1b54658 100644 --- a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs +++ b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs @@ -31,7 +31,7 @@ public class LargeImageIntegrationTests Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - using var image = new Image(configuration, 2048, 2048); + using Image image = new(configuration, 2048, 2048); Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory mem)); Assert.Equal(2048 * 2048, mem.Length); } @@ -69,7 +69,7 @@ public class LargeImageIntegrationTests Configuration = configuration }; - using var image = Image.Load(options, path); + using Image image = Image.Load(options, path); File.Delete(path); Assert.Equal(1, image.GetPixelMemoryGroup().Count); } diff --git a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs index 27cbe1a7e..27e42f84e 100644 --- a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs @@ -32,7 +32,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void PixelAccessorDimensionsAreCorrect() { - using var image = new Image(123, 456); + using Image image = new(123, 456); this.ProcessPixelRowsImpl(image, accessor => { Assert.Equal(123, accessor.Width); @@ -43,7 +43,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_SingleImage() { - using var image = new Image(256, 256); + using Image image = new(256, 256); this.ProcessPixelRowsImpl(image, accessor => { for (int y = 0; y < accessor.Height; y++) @@ -71,7 +71,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_MultiImage2() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { @@ -82,7 +82,7 @@ public abstract class ProcessPixelRowsTestBase } } - using var img2 = new Image(256, 256); + using Image img2 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, (accessor1, accessor2) => { @@ -109,7 +109,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_MultiImage3() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer2 = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { @@ -120,8 +120,8 @@ public abstract class ProcessPixelRowsTestBase } } - using var img2 = new Image(256, 256); - using var img3 = new Image(256, 256); + using Image img2 = new(256, 256); + using Image img3 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, img3, (accessor1, accessor2, accessor3) => { @@ -154,8 +154,8 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void Disposed_ThrowsObjectDisposedException() { - using var nonDisposed = new Image(1, 1); - var disposed = new Image(1, 1); + using Image nonDisposed = new(1, 1); + Image disposed = new(1, 1); disposed.Dispose(); Assert.Throws(() => this.ProcessPixelRowsImpl(disposed, _ => { })); @@ -178,11 +178,11 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer); Configuration.Default.MemoryAllocator = allocator; - var image = new Image(10, 10); + Image image = new(10, 10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -215,13 +215,13 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); Assert.Equal(2, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -255,15 +255,15 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var buffer3 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2, buffer3); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer3 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2, buffer3); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); - var image3 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); + Image image3 = new(10, 10); Assert.Equal(3, UnmanagedMemoryHandle.TotalOutstandingHandles); try diff --git a/tests/ImageSharp.Tests/Issues/Issue594.cs b/tests/ImageSharp.Tests/Issues/Issue594.cs index 7f976a373..36308edae 100644 --- a/tests/ImageSharp.Tests/Issues/Issue594.cs +++ b/tests/ImageSharp.Tests/Issues/Issue594.cs @@ -40,7 +40,7 @@ public class Issue594 const float z = 0.5f; const float w = -0.7f; - pixel = new(x, y, z, w); + pixel = new NormalizedByte4(x, y, z, w); Assert.Equal(0xA740DA0D, pixel.PackedValue); NormalizedByte4 n = NormalizedByte4.FromRgba32(pixel.ToRgba32()); Assert.Equal(0xA740DA0D, n.PackedValue); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs index 33950c469..c4cef5d93 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs @@ -58,7 +58,7 @@ public abstract class BufferTestSuite } } - public static readonly TheoryData LengthValues = new TheoryData { 0, 1, 7, 1023, 1024 }; + public static readonly TheoryData LengthValues = new() { 0, 1, 7, 1023, 1024 }; [Theory] [MemberData(nameof(LengthValues))] @@ -172,7 +172,7 @@ public abstract class BufferTestSuite { using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { - var expectedVals = new T[buffer.Length()]; + T[] expectedVals = new T[buffer.Length()]; for (int i = 0; i < buffer.Length(); i++) { @@ -213,7 +213,7 @@ public abstract class BufferTestSuite private T TestIndexOutOfRangeShouldThrow(int desiredLength) where T : struct, IEquatable { - var dummy = default(T); + T dummy = default(T); using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs index 517eda707..8eb364828 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs @@ -14,7 +14,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void Dispose_ResultsInSingleRelease(int disposeCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); Assert.Equal(0, guard.ReleaseInvocationCount); for (int i = 0; i < disposeCount; i++) @@ -45,7 +45,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void AddRef_PreventsReleaseOnDispose(int addRefCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); for (int i = 0; i < addRefCount; i++) { @@ -80,7 +80,7 @@ public class RefCountedLifetimeGuardTests [Fact] public void AddRefReleaseRefMisuse_DoesntLeadToMultipleReleases() { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); guard.Dispose(); guard.AddRef(); guard.ReleaseRef(); @@ -91,8 +91,8 @@ public class RefCountedLifetimeGuardTests [Fact] public void UnmanagedBufferLifetimeGuard_Handle_IsReturnedByRef() { - var h = UnmanagedMemoryHandle.Allocate(10); - using var guard = new UnmanagedBufferLifetimeGuard.FreeHandle(h); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(10); + using UnmanagedBufferLifetimeGuard.FreeHandle guard = new(h); Assert.True(guard.Handle.IsValid); guard.Handle.Free(); Assert.False(guard.Handle.IsValid); @@ -101,7 +101,7 @@ public class RefCountedLifetimeGuardTests [MethodImpl(MethodImplOptions.NoInlining)] private static void LeakGuard(bool addRef) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); if (addRef) { guard.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs index a956190cd..72b90c238 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs @@ -16,7 +16,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - using (var buffer = new SharedArrayPoolBuffer(900)) + using (SharedArrayPoolBuffer buffer = new(900)) { Assert.Equal(900, buffer.GetSpan().Length); buffer.GetSpan().Fill(42); @@ -36,7 +36,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - var buffer = new SharedArrayPoolBuffer(900); + SharedArrayPoolBuffer buffer = new(900); Span span = buffer.GetSpan(); buffer.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs index 665f34a34..0e791c5d9 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs @@ -17,7 +17,7 @@ public class SimpleGcMemoryAllocatorTests } } - protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new SimpleGcMemoryAllocator(); + protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new(); public static TheoryData InvalidLengths { get; set; } = new() { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index fd8b6af59..f518b2272 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -24,8 +24,8 @@ public partial class UniformUnmanagedMemoryPoolTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; - var pool = new UniformUnmanagedMemoryPool(128, 256, trimSettings); + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool pool = new(128, 256, trimSettings); UnmanagedMemoryHandle[] a = pool.Rent(64); UnmanagedMemoryHandle[] b = pool.Rent(64); @@ -77,11 +77,11 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var trimSettings1 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; - var pool1 = new UniformUnmanagedMemoryPool(128, 256, trimSettings1); + UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool pool1 = new(128, 256, trimSettings1); Thread.Sleep(8_000); // Let some callbacks fire already - var trimSettings2 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; - var pool2 = new UniformUnmanagedMemoryPool(128, 256, trimSettings2); + UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool pool2 = new(128, 256, trimSettings2); pool1.Return(pool1.Rent(64)); pool2.Return(pool2.Rent(64)); @@ -104,7 +104,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 4_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 4_000 }; _ = new UniformUnmanagedMemoryPool(128, 256, trimSettings); } } @@ -129,13 +129,13 @@ public partial class UniformUnmanagedMemoryPoolTests Assert.False(Environment.Is64BitProcess); const int oneMb = 1 << 20; - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { 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); - var pool = new UniformUnmanagedMemoryPool(oneMb, 16, trimSettings); + UniformUnmanagedMemoryPool pool = new(oneMb, 16, trimSettings); pool.Return(pool.Rent(16)); Assert.Equal(16, UnmanagedMemoryHandle.TotalOutstandingHandles); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs index 69fc1a5f7..ec79d91c3 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs @@ -55,7 +55,7 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(7, 4)] public void Constructor_InitializesProperties(int arrayLength, int capacity) { - var pool = new UniformUnmanagedMemoryPool(arrayLength, capacity); + UniformUnmanagedMemoryPool pool = new(arrayLength, capacity); Assert.Equal(arrayLength, pool.BufferLength); Assert.Equal(capacity, pool.Capacity); } @@ -65,8 +65,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(8, 10)] public void Rent_SingleBuffer_ReturnsCorrectBuffer(int length, int capacity) { - var pool = new UniformUnmanagedMemoryPool(length, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, capacity); + using CleanupUtil cleanup = new(pool); for (int i = 0; i < capacity; i++) { @@ -83,7 +83,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); @@ -105,7 +105,7 @@ public partial class UniformUnmanagedMemoryPoolTests Assert.True(span.SequenceEqual(expected)); } - private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new Span(h.Pointer, length); + private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new(h.Pointer, length); [Theory] [InlineData(1, 1)] @@ -114,8 +114,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(5, 10)] public void Rent_MultiBuffer_ReturnsCorrectBuffers(int length, int bufferCount) { - var pool = new UniformUnmanagedMemoryPool(length, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] handles = pool.Rent(bufferCount); cleanup.Register(handles); @@ -131,8 +131,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_MultipleTimesWithoutReturn_ReturnsDifferentHandles() { - var pool = new UniformUnmanagedMemoryPool(128, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] a = pool.Rent(2); cleanup.Register(a); UnmanagedMemoryHandle b = pool.Rent(); @@ -149,10 +149,10 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(12, 4, 12)] public void RentReturnRent_SameBuffers(int totalCount, int rentUnit, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); - var allHandles = new HashSet(); - var handleUnits = new List(); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); + HashSet allHandles = new(); + List handleUnits = new(); UnmanagedMemoryHandle[] handles; for (int i = 0; i < totalCount; i += rentUnit) @@ -197,8 +197,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() { - var pool = new UniformUnmanagedMemoryPool(7, 1000); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(7, 1000); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(1000); Assert.NotNull(initial); cleanup.Register(initial); @@ -212,8 +212,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(4, 7, 10)] public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(initialRent); Assert.NotNull(initial); cleanup.Register(initial); @@ -228,8 +228,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(3, 3, 7)] public void Rent_MultiBuff_BelowCapacity_Succeeds(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] b0 = pool.Rent(initialRent); Assert.NotNull(b0); cleanup.Register(b0); @@ -250,8 +250,8 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest(string multipleInner) { - var pool = new UniformUnmanagedMemoryPool(16, 16); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(16, 16); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle b0 = pool.Rent(); IntPtr h0 = b0.Handle; UnmanagedMemoryHandle b1 = pool.Rent(); @@ -290,7 +290,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); pool.Return(a); @@ -306,13 +306,13 @@ public partial class UniformUnmanagedMemoryPoolTests public void RentReturn_IsThreadSafe() { int count = Environment.ProcessorCount * 200; - var pool = new UniformUnmanagedMemoryPool(8, count); - using var cleanup = new CleanupUtil(pool); - var rnd = new Random(0); + UniformUnmanagedMemoryPool pool = new(8, count); + using CleanupUtil cleanup = new(pool); + Random rnd = new(0); Parallel.For(0, Environment.ProcessorCount, (int i) => { - var allHandles = new List(); + List allHandles = new(); int pauseAt = rnd.Next(100); for (int j = 0; j < 100; j++) { @@ -359,7 +359,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance(bool withGuardedBuffers) { - var pool = new UniformUnmanagedMemoryPool(16, 128); + UniformUnmanagedMemoryPool pool = new(16, 128); if (withGuardedBuffers) { UnmanagedMemoryHandle h = pool.Rent(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index aa34a5c10..f62e99a8b 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -44,7 +44,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests } public static TheoryData AllocateData = - new TheoryData() + new() { { default(S4), 16, 256, 256, 1024, 64, 64, 1, -1, 64 }, { default(S4), 16, 256, 256, 1024, 256, 256, 1, -1, 256 }, @@ -69,7 +69,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests int expectedSizeOfLastBuffer) where T : struct { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedArrayPoolThresholdInBytes, maxContiguousPoolBufferInBytes, maxPoolSizeInBytes, @@ -86,13 +86,13 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_MultipleTimes_ExceedPoolLimit() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( 64, 128, 1024, 1024); - var groups = new List>(); + List> groups = new(); for (int i = 0; i < 16; i++) { int lengthInElements = 128 / Unsafe.SizeOf(); @@ -110,7 +110,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_SizeInBytesOverLongMaxValue_ThrowsInvalidMemoryOperationException() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); Assert.Throws(() => allocator.AllocateGroup(int.MaxValue * (long)int.MaxValue, int.MaxValue)); } @@ -128,7 +128,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public unsafe void Allocate_MemoryIsPinnableMultipleTimes() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); using IMemoryOwner memoryOwner = allocator.Allocate(100); using (MemoryHandle pin = memoryOwner.Memory.Pin()) @@ -149,7 +149,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { - var allocator = MemoryAllocator.Create(); + MemoryAllocator allocator = MemoryAllocator.Create(); long sixteenMegabytes = 16 * (1 << 20); // Should allocate 4 times 4MB discontiguos blocks: @@ -165,7 +165,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { - var allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { MaximumPoolSizeMegabytes = 8 }); @@ -205,7 +205,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); IMemoryOwner buffer0 = allocator.Allocate(bool.Parse(sharedStr) ? 300 : 600); buffer0.GetSpan()[0] = 42; buffer0.Dispose(); @@ -223,7 +223,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); MemoryGroup g0 = allocator.AllocateGroup(bool.Parse(sharedStr) ? 300 : 600, 100); g0.Single().Span[0] = 42; g0.Dispose(); @@ -238,7 +238,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); MemoryGroup g = allocator.AllocateGroup(2048, 128); g.Dispose(); Assert.Equal(4, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -253,7 +253,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); IMemoryOwner b = allocator.Allocate(256); MemoryGroup g = allocator.AllocateGroup(2048, 128); Assert.Equal(5, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -297,7 +297,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateGroupAndForget(allocator, lengthInner); @@ -365,7 +365,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateSingleAndForget(allocator, lengthInner); @@ -422,7 +422,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = 4 }); @@ -434,7 +434,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = 4 }); @@ -450,7 +450,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { const long threeGB = 3L * (1 << 30); - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = (int)(threeGB / 1024) }); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs index d0a5cfa9a..3b33eae5e 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs @@ -21,7 +21,7 @@ public class UnmanagedBufferTests [Fact] public void Allocate_CreatesValidBuffer() { - using var buffer = UnmanagedBuffer.Allocate(10); + using UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Span span = buffer.GetSpan(); Assert.Equal(10, span.Length); span[9] = 123; @@ -35,7 +35,7 @@ public class UnmanagedBufferTests static void RunTest() { - var buffer = UnmanagedBuffer.Allocate(10); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); Span span = buffer.GetSpan(); @@ -76,10 +76,10 @@ public class UnmanagedBufferTests static List> FillList(int countInner) { - var l = new List>(); + List> l = new(); for (int i = 0; i < countInner; i++) { - var h = UnmanagedBuffer.Allocate(42); + UnmanagedBuffer h = UnmanagedBuffer.Allocate(42); l.Add(h); } diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs index 7a0736b54..59b793e01 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs @@ -11,7 +11,7 @@ public class UnmanagedMemoryHandleTests [Fact] public unsafe void Allocate_AllocatesReadWriteMemory() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); Assert.False(h.IsInvalid); Assert.True(h.IsValid); byte* ptr = (byte*)h.Handle; @@ -31,7 +31,7 @@ public class UnmanagedMemoryHandleTests [Fact] public void Free_ClosesHandle() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); h.Free(); Assert.True(h.IsInvalid); Assert.Equal(IntPtr.Zero, h.Handle); @@ -47,11 +47,11 @@ public class UnmanagedMemoryHandleTests static void RunTest(string countStr) { int countInner = int.Parse(countStr); - var l = new List(); + List l = new(); for (int i = 0; i < countInner; i++) { Assert.Equal(i, UnmanagedMemoryHandle.TotalOutstandingHandles); - var h = UnmanagedMemoryHandle.Allocate(42); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(42); Assert.Equal(i + 1, UnmanagedMemoryHandle.TotalOutstandingHandles); l.Add(h); } @@ -68,7 +68,7 @@ public class UnmanagedMemoryHandleTests [Fact] public void Equality_WhenTrue() { - var h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); UnmanagedMemoryHandle h2 = h1; Assert.True(h1.Equals(h2)); @@ -82,8 +82,8 @@ public class UnmanagedMemoryHandleTests [Fact] public void Equality_WhenFalse() { - var h1 = UnmanagedMemoryHandle.Allocate(10); - var h2 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h2 = UnmanagedMemoryHandle.Allocate(10); Assert.False(h1.Equals(h2)); Assert.False(h2.Equals(h1)); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs index 88c05fdd0..e17c8c46f 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs @@ -10,7 +10,7 @@ public partial class Buffer2DTests { public class SwapOrCopyContent { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void SwapOrCopyContent_WhenBothAllocated() @@ -40,8 +40,8 @@ public partial class Buffer2DTests [Fact] public void SwapOrCopyContent_WhenDestinationIsOwned_ShouldNotSwapInDisposedSourceBuffer() { - using var destData = MemoryGroup.Wrap(new int[100]); - using var dest = new Buffer2D(destData, 10, 10); + using MemoryGroup destData = MemoryGroup.Wrap(new int[100]); + using Buffer2D dest = new(destData, 10, 10); using (Buffer2D source = this.memoryAllocator.Allocate2D(10, 10, AllocationOptions.Clean)) { @@ -112,11 +112,11 @@ public partial class Buffer2DTests [InlineData(true)] public void WhenDestIsNotAllocated_SameSize_ShouldCopy(bool sourceIsAllocated) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(21, 1); @@ -136,11 +136,11 @@ public partial class Buffer2DTests [InlineData(true)] public void WhenDestIsNotMemoryOwner_DifferentSize_Throws(bool sourceIsOwner) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(22, 1); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index 8ba3bf70a..6dfdd294c 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -24,7 +24,7 @@ public partial class Buffer2DTests } } - private TestMemoryAllocator MemoryAllocator { get; } = new TestMemoryAllocator(); + private TestMemoryAllocator MemoryAllocator { get; } = new(); private const int Big = 99999; @@ -147,7 +147,7 @@ public partial class Buffer2DTests const int unpooledBufferSize = 8_000; int elementSize = sizeof(TestStructs.Foo); - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedPoolThreshold * elementSize, poolBufferSize * elementSize, maxPoolSize * elementSize, @@ -155,7 +155,7 @@ public partial class Buffer2DTests using Buffer2D buffer = allocator.Allocate2D(width, height); - var rnd = new Random(42); + Random rnd = new(42); for (int y = 0; y < buffer.Height; y++) { @@ -208,7 +208,7 @@ public partial class Buffer2DTests } } - public static TheoryData GetRowSpanY_OutOfRange_Data = new TheoryData() + public static TheoryData GetRowSpanY_OutOfRange_Data = new() { { Big, 10, 8, -1 }, { Big, 10, 8, 8 }, @@ -227,7 +227,7 @@ public partial class Buffer2DTests Assert.True(ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException); } - public static TheoryData Indexer_OutOfRange_Data = new TheoryData() + public static TheoryData Indexer_OutOfRange_Data = new() { { Big, 10, 8, 1, -1 }, { Big, 10, 8, 1, 8 }, @@ -284,7 +284,7 @@ public partial class Buffer2DTests [InlineData(5, 1, 1, 3, 2)] public void CopyColumns(int width, int height, int startIndex, int destIndex, int columnCount) { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(width, height)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -306,7 +306,7 @@ public partial class Buffer2DTests [Fact] public void CopyColumns_InvokeMultipleTimes() { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(100, 100)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -341,9 +341,9 @@ public partial class Buffer2DTests public static TheoryData InvalidLengths { get; set; } = new() { - { new(-1, -1) }, - { new(32768, 32769) }, - { new(32769, 32768) } + { new Size(-1, -1) }, + { new Size(32768, 32769) }, + { new Size(32769, 32768) } }; [Theory] diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index 46907b9c0..be7edbacc 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -7,14 +7,14 @@ namespace SixLabors.ImageSharp.Tests.Memory; public class BufferAreaTests { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void Construct() { using Buffer2D buffer = this.memoryAllocator.Allocate2D(10, 20); - var rectangle = new Rectangle(3, 2, 5, 6); - var area = new Buffer2DRegion(buffer, rectangle); + Rectangle rectangle = new(3, 2, 5, 6); + Buffer2DRegion area = new(buffer, rectangle); Assert.Equal(buffer, area.Buffer); Assert.Equal(rectangle, area.Rectangle); @@ -43,7 +43,7 @@ public class BufferAreaTests { this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, 5, 6); + Rectangle r = new(rx, ry, 5, 6); Buffer2DRegion region = buffer.GetRegion(r); @@ -62,7 +62,7 @@ public class BufferAreaTests this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, w, h); + Rectangle r = new(rx, ry, w, h); Buffer2DRegion region = buffer.GetRegion(r); @@ -87,7 +87,7 @@ public class BufferAreaTests Buffer2DRegion area1 = area0.GetSubRegion(4, 4, 5, 5); - var expectedRect = new Rectangle(10, 12, 5, 5); + Rectangle expectedRect = new(10, 12, 5, 5); Assert.Equal(buffer, area1.Buffer); Assert.Equal(expectedRect, area1.Rectangle); @@ -120,7 +120,7 @@ public class BufferAreaTests this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(22, 13); - var emptyRow = new int[22]; + int[] emptyRow = new int[22]; buffer.GetRegion().Clear(); for (int y = 0; y < 13; y++) diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs index a49ab7778..4e67df53b 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs @@ -8,8 +8,8 @@ public class MemoryGroupIndexTests [Fact] public void Equal() { - var a = new MemoryGroupIndex(10, 1, 3); - var b = new MemoryGroupIndex(10, 1, 3); + MemoryGroupIndex a = new(10, 1, 3); + MemoryGroupIndex b = new(10, 1, 3); Assert.True(a.Equals(b)); Assert.True(a == b); @@ -21,8 +21,8 @@ public class MemoryGroupIndexTests [Fact] public void SmallerBufferIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 5, 3); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 5, 3); Assert.False(a == b); Assert.True(a != b); @@ -33,8 +33,8 @@ public class MemoryGroupIndexTests [Fact] public void SmallerElementIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 3, 9); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 3, 9); Assert.False(a == b); Assert.True(a != b); @@ -45,7 +45,7 @@ public class MemoryGroupIndexTests [Fact] public void Increment() { - var a = new MemoryGroupIndex(10, 3, 3); + MemoryGroupIndex a = new(10, 3, 3); a += 1; Assert.Equal(new MemoryGroupIndex(10, 3, 4), a); } @@ -53,8 +53,8 @@ public class MemoryGroupIndexTests [Fact] public void Increment_OverflowBuffer() { - var a = new MemoryGroupIndex(10, 5, 3); - var b = new MemoryGroupIndex(10, 5, 9); + MemoryGroupIndex a = new(10, 5, 3); + MemoryGroupIndex b = new(10, 5, 9); a += 8; b += 1; diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs index 4c7de5412..678a089a8 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs @@ -59,7 +59,7 @@ public partial class MemoryGroupTests this.MemoryAllocator.BufferCapacityInBytes = bufferCapacity; // Act: - using var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); // Assert: ValidateAllocateMemoryGroup(expectedNumberOfBuffers, expectedBufferSize, expectedSizeOfLastBuffer, g); @@ -83,7 +83,7 @@ public partial class MemoryGroupTests return; } - var pool = new UniformUnmanagedMemoryPool(bufferCapacity, expectedNumberOfBuffers); + UniformUnmanagedMemoryPool pool = new(bufferCapacity, expectedNumberOfBuffers); // Act: Assert.True(MemoryGroup.TryAllocate(pool, totalLength, bufferAlignment, AllocationOptions.None, out MemoryGroup g)); @@ -98,7 +98,7 @@ public partial class MemoryGroupTests [InlineData(AllocationOptions.Clean)] public unsafe void Allocate_FromPool_AllocationOptionsAreApplied(AllocationOptions options) { - var pool = new UniformUnmanagedMemoryPool(10, 5); + UniformUnmanagedMemoryPool pool = new(10, 5); UnmanagedMemoryHandle[] buffers = pool.Rent(5); foreach (UnmanagedMemoryHandle b in buffers) { @@ -128,7 +128,7 @@ public partial class MemoryGroupTests int requestBytes, bool shouldSucceed) { - var pool = new UniformUnmanagedMemoryPool(bufferCapacityBytes, poolCapacity); + UniformUnmanagedMemoryPool pool = new(bufferCapacityBytes, poolCapacity); int alignmentElements = alignmentBytes / Unsafe.SizeOf(); int requestElements = requestBytes / Unsafe.SizeOf(); @@ -194,7 +194,7 @@ public partial class MemoryGroupTests HashSet bufferHashes; int expectedBlockCount = 5; - using (var g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) + using (MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) { IReadOnlyList allocationLog = this.MemoryAllocator.AllocationLog; Assert.Equal(expectedBlockCount, allocationLog.Count); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs index 23aaf3c55..c140571fc 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs @@ -50,7 +50,7 @@ public partial class MemoryGroupTests public void GroupToSpan_Success(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; src.CopyTo(trg); int expected = 1; @@ -67,7 +67,7 @@ public partial class MemoryGroupTests public void GroupToSpan_OutOfRange(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; Assert.ThrowsAny(() => src.CopyTo(trg)); } @@ -78,7 +78,7 @@ public partial class MemoryGroupTests [InlineData(0, 3, 0)] public void SpanToGroup_Success(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; for (int i = 0; i < src.Length; i++) { src[i] = i + 1; @@ -100,7 +100,7 @@ public partial class MemoryGroupTests [InlineData(0, 3, 1)] public void SpanToGroup_OutOfRange(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; using MemoryGroup trg = this.CreateTestGroup(totalLength, bufferLength, true); Assert.ThrowsAny(() => src.AsSpan().CopyTo(trg)); } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs index 316150c30..fe1867f20 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs @@ -12,7 +12,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase [Fact] public void IsValid_TrueAfterCreation() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); Assert.True(g.IsValid); } @@ -20,7 +20,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase [Fact] public void IsValid_FalseAfterDisposal() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); g.Dispose(); Assert.False(g.IsValid); @@ -28,7 +28,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase #pragma warning disable SA1509 private static readonly TheoryData CopyAndTransformData = - new TheoryData() + new() { { 20, 10, 20, 10 }, { 20, 5, 20, 4 }, @@ -102,10 +102,10 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase int[] data0 = { 1, 2, 3, 4 }; int[] data1 = { 5, 6, 7, 8 }; int[] data2 = { 9, 10 }; - using var mgr0 = new TestMemoryManager(data0); - using var mgr1 = new TestMemoryManager(data1); + using TestMemoryManager mgr0 = new(data0); + using TestMemoryManager mgr1 = new(data1); - using var group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); + using MemoryGroup group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); Assert.Equal(3, group.Count); Assert.Equal(4, group.BufferLength); @@ -124,7 +124,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase } } - public static TheoryData GetBoundedSlice_SuccessData = new TheoryData() + public static TheoryData GetBoundedSlice_SuccessData = new() { { 300, 100, 110, 80 }, { 300, 100, 100, 100 }, @@ -153,7 +153,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase } } - public static TheoryData GetBoundedSlice_ErrorData = new TheoryData() + public static TheoryData GetBoundedSlice_ErrorData = new() { { 300, 100, -1, 91 }, { 300, 100, 110, 91 }, @@ -217,7 +217,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase using MemoryGroup group = this.CreateTestGroup(100, 10, true); group.Clear(); - var expectedRow = new int[10]; + int[] expectedRow = new int[10]; foreach (Memory memory in group) { Assert.True(memory.Span.SequenceEqual(expectedRow)); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs index 8fe6ef3dd..0eaebbfef 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Memory.DiscontiguousBuffers; public abstract class MemoryGroupTestsBase { - internal readonly TestMemoryAllocator MemoryAllocator = new TestMemoryAllocator(); + internal readonly TestMemoryAllocator MemoryAllocator = new(); /// /// Create a group, either uninitialized or filled with incrementing numbers starting with 1. @@ -15,7 +15,7 @@ public abstract class MemoryGroupTestsBase internal MemoryGroup CreateTestGroup(long totalLength, int bufferLength, bool fillSequence = false) { this.MemoryAllocator.BufferCapacityInBytes = bufferLength * sizeof(int); - var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); + MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); if (!fillSequence) { diff --git a/tests/ImageSharp.Tests/Memory/TestStructs.cs b/tests/ImageSharp.Tests/Memory/TestStructs.cs index ccbee5bd5..bb6a07ec9 100644 --- a/tests/ImageSharp.Tests/Memory/TestStructs.cs +++ b/tests/ImageSharp.Tests/Memory/TestStructs.cs @@ -19,7 +19,7 @@ public static class TestStructs internal static Foo[] CreateArray(int size) { - var result = new Foo[size]; + Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { result[i] = new Foo(i + 1, i + 1); @@ -70,7 +70,7 @@ public static class TestStructs internal static AlignedFoo[] CreateArray(int size) { - var result = new AlignedFoo[size]; + AlignedFoo[] result = new AlignedFoo[size]; for (int i = 0; i < size; i++) { result[i] = new AlignedFoo(i + 1, i + 1); diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 252784a7c..395dfd455 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -38,7 +38,7 @@ public static class MemoryAllocatorValidator public static TestMemoryDiagnostics MonitorAllocations() { - var diag = new TestMemoryDiagnostics(); + TestMemoryDiagnostics diag = new(); LocalInstance.Value = diag; return diag; } diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index cdd6f0cc4..6d35517ac 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -48,7 +48,7 @@ public class ImageFrameMetadataTests XmpProfile xmpProfile = new(Array.Empty()); IccProfile iccProfile = new() { - Header = new IccProfileHeader() + Header = new IccProfileHeader { CmmType = "Unittest" } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs index 76e2d35c4..ff8b034c5 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs @@ -25,10 +25,10 @@ public class CicpProfileTests public void WritingPng_PreservesCicpProfile() { // arrange - using var image = new Image(1, 1); - var original = CreateCicpProfile(); + using Image image = new(1, 1); + CicpProfile original = CreateCicpProfile(); image.Metadata.CicpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -49,7 +49,7 @@ public class CicpProfileTests private static CicpProfile CreateCicpProfile() { - var profile = new CicpProfile() + CicpProfile profile = new() { ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2, TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084, @@ -70,7 +70,7 @@ public class CicpProfileTests private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs index 8072bebd7..6c499f40c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -88,7 +88,7 @@ public class ExifProfileTests [Fact] public void EmptyWriter() { - var profile = new ExifProfile() { Parts = ExifParts.GpsTags }; + ExifProfile profile = new() { Parts = ExifParts.GpsTags }; profile.SetValue(ExifTag.Copyright, "Copyright text"); byte[] bytes = profile.ToByteArray(); @@ -120,14 +120,14 @@ public class ExifProfileTests [InlineData(TestImageWriteFormat.WebpLossy)] public void WriteFraction(TestImageWriteFormat imageFormat) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); double exposureTime = 1.0 / 1600; ExifProfile profile = GetExifProfile(); profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime)); - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -231,7 +231,7 @@ public class ExifProfileTests IExifValue referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite); Assert.Null(referenceBlackWhite.Value); - var expectedLatitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) }; + Rational[] expectedLatitude = new Rational[] { new(12.3), new(4.56), new(789.0) }; image.Metadata.ExifProfile.SetValue(ExifTag.GPSLatitude, expectedLatitude); IExifValue latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude); @@ -308,11 +308,11 @@ public class ExifProfileTests [Fact] public void Syncs() { - var exifProfile = new ExifProfile(); + ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); - var metaData = new ImageMetadata + ImageMetadata metaData = new() { ExifProfile = exifProfile, HorizontalResolution = 200, @@ -366,15 +366,15 @@ public class ExifProfileTests foreach (ExifTag tag in tags) { // Arrange - var junk = new StringBuilder(); + StringBuilder junk = new(); for (int i = 0; i < 65600; i++) { junk.Append('a'); } - var image = new Image(100, 100); + Image image = new(100, 100); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); expectedProfile.SetValue(tag, junk.ToString()); image.Metadata.ExifProfile = expectedProfile; @@ -437,7 +437,7 @@ public class ExifProfileTests byte[] bytes = profile.ToByteArray(); Assert.Equal(531, bytes.Length); - var profile2 = new ExifProfile(bytes); + ExifProfile profile2 = new(bytes); Assert.Equal(25, profile2.Values.Count); } @@ -449,7 +449,7 @@ public class ExifProfileTests public void WritingImagePreservesExifProfile(TestImageWriteFormat imageFormat) { // Arrange - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = CreateExifProfile(); // Act @@ -472,11 +472,11 @@ public class ExifProfileTests // Arrange byte[] exifBytesWithoutExifCode = ExifConstants.LittleEndianByteOrderMarker.ToArray(); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); // Act byte[] actualBytes = expectedProfile.ToByteArray(); - var actualProfile = new ExifProfile(actualBytes); + ExifProfile actualProfile = new(actualBytes); // Assert Assert.NotNull(actualBytes); @@ -492,7 +492,7 @@ public class ExifProfileTests private static ExifProfile CreateExifProfile() { - var profile = new ExifProfile(); + ExifProfile profile = new(); foreach (KeyValuePair exifProfileValue in TestProfileValues) { @@ -505,7 +505,7 @@ public class ExifProfileTests [Fact] public void IfdStructure() { - var exif = new ExifProfile(); + ExifProfile exif = new(); exif.SetValue(ExifTag.XPAuthor, "Dan Petitt"); Span actualBytes = exif.ToByteArray(); @@ -547,7 +547,7 @@ public class ExifProfileTests private static Image WriteAndReadJpeg(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsJpeg(memStream); image.Dispose(); @@ -557,7 +557,7 @@ public class ExifProfileTests private static Image WriteAndReadPng(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsPng(memStream); image.Dispose(); @@ -567,8 +567,8 @@ public class ExifProfileTests private static Image WriteAndReadWebp(Image image, WebpFileFormatType fileFormat) { - using var memStream = new MemoryStream(); - image.SaveAsWebp(memStream, new WebpEncoder() { FileFormat = fileFormat }); + using MemoryStream memStream = new(); + image.SaveAsWebp(memStream, new WebpEncoder { FileFormat = fileFormat }); image.Dispose(); memStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs index 8fe19b37d..983ff4493 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs @@ -11,7 +11,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsEmpty_ReturnsEmptyCollection() { - var reader = new ExifReader(Array.Empty()); + ExifReader reader = new(Array.Empty()); IList result = reader.ReadValues(); @@ -21,7 +21,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsMinimal_ReturnsEmptyCollection() { - var reader = new ExifReader(new byte[] { 69, 120, 105, 102, 0, 0 }); + ExifReader reader = new(new byte[] { 69, 120, 105, 102, 0, 0 }); IList result = reader.ReadValues(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs index 1154b3439..3f13afa6f 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs @@ -12,7 +12,7 @@ public class ExifTagDescriptionAttributeTests [Fact] public void TestExifTag() { - var exifProfile = new ExifProfile(); + ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1); IExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index 99cafa896..cb006ba29 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -9,14 +9,14 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Exif.Values; [Trait("Profile", "Exif")] public class ExifValuesTests { - public static TheoryData ByteTags => new TheoryData + public static TheoryData ByteTags => new() { { ExifTag.FaxProfile }, { ExifTag.ModeNumber }, { ExifTag.GPSAltitudeRef } }; - public static TheoryData ByteArrayTags => new TheoryData + public static TheoryData ByteArrayTags => new() { { ExifTag.ClipPath }, { ExifTag.VersionYear }, @@ -26,7 +26,7 @@ public class ExifValuesTests { ExifTag.GPSVersionID }, }; - public static TheoryData DoubleArrayTags => new TheoryData + public static TheoryData DoubleArrayTags => new() { { ExifTag.PixelScale }, { ExifTag.IntergraphMatrix }, @@ -34,7 +34,7 @@ public class ExifValuesTests { ExifTag.ModelTransform } }; - public static TheoryData LongTags => new TheoryData + public static TheoryData LongTags => new() { { ExifTag.SubfileType }, { ExifTag.SubIFDOffset }, @@ -59,7 +59,7 @@ public class ExifValuesTests { ExifTag.ImageNumber }, }; - public static TheoryData LongArrayTags => new TheoryData + public static TheoryData LongArrayTags => new() { { ExifTag.FreeOffsets }, { ExifTag.FreeByteCounts }, @@ -73,7 +73,7 @@ public class ExifValuesTests { ExifTag.IntergraphRegisters } }; - public static TheoryData NumberTags => new TheoryData + public static TheoryData NumberTags => new() { { ExifTag.ImageWidth }, { ExifTag.ImageLength }, @@ -85,7 +85,7 @@ public class ExifValuesTests { ExifTag.PixelYDimension } }; - public static TheoryData NumberArrayTags => new TheoryData + public static TheoryData NumberArrayTags => new() { { ExifTag.StripOffsets }, { ExifTag.StripByteCounts }, @@ -94,7 +94,7 @@ public class ExifValuesTests { ExifTag.ImageLayer } }; - public static TheoryData RationalTags => new TheoryData + public static TheoryData RationalTags => new() { { ExifTag.XPosition }, { ExifTag.YPosition }, @@ -131,7 +131,7 @@ public class ExifValuesTests { ExifTag.GPSHPositioningError }, }; - public static TheoryData RationalArrayTags => new TheoryData + public static TheoryData RationalArrayTags => new() { { ExifTag.WhitePoint }, { ExifTag.PrimaryChromaticities }, @@ -145,7 +145,7 @@ public class ExifValuesTests { ExifTag.LensSpecification } }; - public static TheoryData ShortTags => new TheoryData + public static TheoryData ShortTags => new() { { ExifTag.OldSubfileType }, { ExifTag.Compression }, @@ -196,7 +196,7 @@ public class ExifValuesTests { ExifTag.GPSDifferential } }; - public static TheoryData ShortArrayTags => new TheoryData + public static TheoryData ShortArrayTags => new() { { ExifTag.BitsPerSample }, { ExifTag.MinSampleValue }, @@ -220,7 +220,7 @@ public class ExifValuesTests { ExifTag.SubjectLocation } }; - public static TheoryData SignedRationalTags => new TheoryData + public static TheoryData SignedRationalTags => new() { { ExifTag.ShutterSpeedValue }, { ExifTag.BrightnessValue }, @@ -230,17 +230,17 @@ public class ExifValuesTests { ExifTag.CameraElevationAngle } }; - public static TheoryData SignedRationalArrayTags => new TheoryData + public static TheoryData SignedRationalArrayTags => new() { { ExifTag.Decode } }; - public static TheoryData SignedShortArrayTags => new TheoryData + public static TheoryData SignedShortArrayTags => new() { { ExifTag.TimeZoneOffset } }; - public static TheoryData StringTags => new TheoryData + public static TheoryData StringTags => new() { { ExifTag.ImageDescription }, { ExifTag.Make }, @@ -298,13 +298,13 @@ public class ExifValuesTests { ExifTag.GPSDateStamp }, }; - public static TheoryData UndefinedTags => new TheoryData + public static TheoryData UndefinedTags => new() { { ExifTag.FileSource }, { ExifTag.SceneType } }; - public static TheoryData UndefinedArrayTags => new TheoryData + public static TheoryData UndefinedArrayTags => new() { { ExifTag.JPEGTables }, { ExifTag.OECF }, @@ -320,14 +320,14 @@ public class ExifValuesTests { ExifTag.ImageSourceData }, }; - public static TheoryData EncodedStringTags => new TheoryData + public static TheoryData EncodedStringTags => new() { { ExifTag.UserComment }, { ExifTag.GPSProcessingMethod }, { ExifTag.GPSAreaInformation } }; - public static TheoryData Ucs2StringTags => new TheoryData + public static TheoryData Ucs2StringTags => new() { { ExifTag.XPTitle }, { ExifTag.XPComment }, @@ -347,7 +347,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -361,7 +361,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -375,7 +375,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifDoubleArray)value; + ExifDoubleArray typed = (ExifDoubleArray)value; Assert.Equal(expected, typed.Value); } @@ -389,7 +389,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLong)value; + ExifLong typed = (ExifLong)value; Assert.Equal(expected, typed.Value); } @@ -403,7 +403,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLongArray)value; + ExifLongArray typed = (ExifLongArray)value; Assert.Equal(expected, typed.Value); } @@ -447,7 +447,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumber)value; + ExifNumber typed = (ExifNumber)value; Assert.Equal(expected, typed.Value); typed.Value = ushort.MaxValue + 1; @@ -464,7 +464,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumberArray)value; + ExifNumberArray typed = (ExifNumberArray)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(int.MaxValue)); @@ -481,14 +481,14 @@ public class ExifValuesTests [MemberData(nameof(RationalTags))] public void ExifRationalTests(ExifTag tag) { - var expected = new Rational(21, 42); + Rational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(new SignedRational(expected.ToDouble()))); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRational)value; + ExifRational typed = (ExifRational)value; Assert.Equal(expected, typed.Value); } @@ -502,7 +502,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRationalArray)value; + ExifRationalArray typed = (ExifRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -518,7 +518,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((short)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShort)value; + ExifShort typed = (ExifShort)value; Assert.Equal(expected, typed.Value); } @@ -532,7 +532,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShortArray)value; + ExifShortArray typed = (ExifShortArray)value; Assert.Equal(expected, typed.Value); } @@ -540,13 +540,13 @@ public class ExifValuesTests [MemberData(nameof(SignedRationalTags))] public void ExifSignedRationalTests(ExifTag tag) { - var expected = new SignedRational(21, 42); + SignedRational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRational)value; + ExifSignedRational typed = (ExifSignedRational)value; Assert.Equal(expected, typed.Value); } @@ -560,7 +560,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRationalArray)value; + ExifSignedRationalArray typed = (ExifSignedRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -575,7 +575,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedShortArray)value; + ExifSignedShortArray typed = (ExifSignedShortArray)value; Assert.Equal(expected, typed.Value); } @@ -589,7 +589,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(0M)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifString)value; + ExifString typed = (ExifString)value; Assert.Equal(expected, typed.Value); } @@ -604,7 +604,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -618,7 +618,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -628,18 +628,18 @@ public class ExifValuesTests { foreach (object code in Enum.GetValues(typeof(EncodedString.CharacterCode))) { - var charCode = (EncodedString.CharacterCode)code; + EncodedString.CharacterCode charCode = (EncodedString.CharacterCode)code; Assert.Equal(ExifEncodedStringHelpers.CharacterCodeBytesLength, ExifEncodedStringHelpers.GetCodeBytes(charCode).Length); const string expectedText = "test string"; - var expected = new EncodedString(charCode, expectedText); + EncodedString expected = new(charCode, expectedText); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifEncodedString)value; + ExifEncodedString typed = (ExifEncodedString)value; Assert.Equal(expected, typed.Value); Assert.Equal(expectedText, (string)typed.Value); Assert.Equal(charCode, typed.Value.Code); @@ -656,7 +656,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifUcs2String)value; + ExifUcs2String typed = (ExifUcs2String)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(Encoding.GetEncoding("UCS-2").GetBytes(expected))); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs index f6ac8517d..79578f1ad 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs @@ -81,5 +81,5 @@ public class IccDataWriterCurvesTests Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() => new IccDataWriter(); + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs index 8f696e99d..27db7e4e6 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs @@ -81,5 +81,5 @@ public class IccDataWriterLutTests Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() => new IccDataWriter(); + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index 9c4abfe3e..27ce0ffa8 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -22,7 +22,7 @@ public class IccProfileTests public void CalculateHash_WithByteArray_DoesNotModifyData() { byte[] data = IccTestDataProfiles.ProfileRandomArray; - var copy = new byte[data.Length]; + byte[] copy = new byte[data.Length]; Buffer.BlockCopy(data, 0, copy, 0, data.Length); IccProfile.CalculateHash(data); @@ -34,7 +34,7 @@ public class IccProfileTests [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) { - var profile = new IccProfile(data); + IccProfile profile = new(data); bool result = profile.CheckIsValid(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index 24671aa3c..71c58c25d 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -12,7 +12,7 @@ public class IccWriterTests [Fact] public void WriteProfile_NoEntries() { - var profile = new IccProfile + IccProfile profile = new() { Header = IccTestDataProfiles.HeaderRandomWrite }; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs index 968fa86c4..5af672c21 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs @@ -19,7 +19,7 @@ public class IccProfileIdTests [Fact] public void SetIsTrueWhenNonDefaultValue() { - var id = new IccProfileId(1, 2, 3, 4); + IccProfileId id = new(1, 2, 3, 4); Assert.True(id.IsSet); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index 1a52ade62..c64fcab58 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -22,7 +22,7 @@ public class IptcProfileTests public void IptcProfile_WithUtf8Data_WritesEnvelopeRecord_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.City, "ESPAÑA"); profile.UpdateData(); byte[] expectedEnvelopeData = { 28, 1, 90, 0, 3, 27, 37, 71 }; @@ -39,7 +39,7 @@ public class IptcProfileTests public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = tag.MaxLength(); @@ -56,7 +56,7 @@ public class IptcProfileTests public void IptcProfile_SetValue_WithStrictDisabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = value.Length; @@ -77,8 +77,8 @@ public class IptcProfileTests public void IptcProfile_SetDateValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var datetime = new DateTimeOffset(new DateTime(1994, 3, 17)); + IptcProfile profile = new(); + DateTimeOffset datetime = new(new DateTime(1994, 3, 17)); // act profile.SetDateTimeValue(tag, datetime); @@ -96,8 +96,8 @@ public class IptcProfileTests public void IptcProfile_SetTimeValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var dateTimeUtc = new DateTime(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); + IptcProfile profile = new(); + DateTime dateTimeUtc = new(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); DateTimeOffset dateTimeOffset = new DateTimeOffset(dateTimeUtc).ToOffset(TimeSpan.FromHours(2)); // act @@ -116,7 +116,7 @@ public class IptcProfileTests using (Image image = provider.GetImage(JpegDecoder.Instance)) { Assert.NotNull(image.Metadata.IptcProfile); - var iptcValues = image.Metadata.IptcProfile.Values.ToList(); + List iptcValues = image.Metadata.IptcProfile.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -130,7 +130,7 @@ public class IptcProfileTests { IptcProfile iptc = image.Frames.RootFrame.Metadata.IptcProfile; Assert.NotNull(iptc); - var iptcValues = iptc.Values.ToList(); + List iptcValues = iptc.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -170,7 +170,7 @@ public class IptcProfileTests public void IptcProfile_ToAndFromByteArray_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; profile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -179,10 +179,10 @@ public class IptcProfileTests // act profile.UpdateData(); byte[] profileBytes = profile.Data; - var profileFromBytes = new IptcProfile(profileBytes); + IptcProfile profileFromBytes = new(profileBytes); // assert - var iptcValues = profileFromBytes.Values.ToList(); + List iptcValues = profileFromBytes.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -191,7 +191,7 @@ public class IptcProfileTests public void IptcProfile_CloneIsDeep() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string captionWriter = "unittest"; const string caption = "test"; profile.SetValue(IptcTag.CaptionWriter, captionWriter); @@ -203,7 +203,7 @@ public class IptcProfileTests // assert Assert.Equal(2, clone.Values.Count()); - var cloneValues = clone.Values.ToList(); + List cloneValues = clone.Values.ToList(); ContainsIptcValue(cloneValues, IptcTag.CaptionWriter, captionWriter); ContainsIptcValue(cloneValues, IptcTag.Caption, "changed"); ContainsIptcValue(profile.Values.ToList(), IptcTag.Caption, caption); @@ -213,7 +213,7 @@ public class IptcProfileTests public void IptcValue_CloneIsDeep() { // arrange - var iptcValue = new IptcValue(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); + IptcValue iptcValue = new(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); // act IptcValue clone = iptcValue.DeepClone(); @@ -240,7 +240,7 @@ public class IptcProfileTests // assert IptcProfile actual = reloadedImage.Metadata.IptcProfile; Assert.NotNull(actual); - var iptcValues = actual.Values.ToList(); + List iptcValues = actual.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -263,7 +263,7 @@ public class IptcProfileTests public void IptcProfile_AddRepeatable_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue1 = "test"; const string expectedValue2 = "another one"; profile.SetValue(tag, expectedValue1, false); @@ -272,7 +272,7 @@ public class IptcProfileTests profile.SetValue(tag, expectedValue2, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(2, values.Count); ContainsIptcValue(values, tag, expectedValue1); ContainsIptcValue(values, tag, expectedValue2); @@ -315,7 +315,7 @@ public class IptcProfileTests public void IptcProfile_AddNoneRepeatable_DoesOverrideOldValue(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue = "another one"; profile.SetValue(tag, "test", false); @@ -323,7 +323,7 @@ public class IptcProfileTests profile.SetValue(tag, expectedValue, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(1, values.Count); ContainsIptcValue(values, tag, expectedValue); } @@ -332,7 +332,7 @@ public class IptcProfileTests public void IptcProfile_RemoveByTag_RemovesAllEntrys() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -348,7 +348,7 @@ public class IptcProfileTests public void IptcProfile_RemoveByTagAndValue_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -364,7 +364,7 @@ public class IptcProfileTests public void IptcProfile_GetValue_RetrievesAllEntries() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Caption, "test"); @@ -385,7 +385,7 @@ public class IptcProfileTests private static Image WriteAndReadJpeg(Image image) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.SaveAsJpeg(memStream); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index 5dc6ac6db..e121d24f9 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -111,10 +111,10 @@ public class XmpProfileTests public void WritingGif_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new GifEncoder(); + GifEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -129,10 +129,10 @@ public class XmpProfileTests public void WritingJpeg_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -147,10 +147,10 @@ public class XmpProfileTests public async Task WritingJpeg_PreservesExtendedXmpProfile() { // arrange - var provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); + TestImageProvider provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); using Image image = await provider.GetImageAsync(JpegDecoder.Instance); XmpProfile original = image.Metadata.XmpProfile; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -165,10 +165,10 @@ public class XmpProfileTests public void WritingPng_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -183,10 +183,10 @@ public class XmpProfileTests public void WritingTiff_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Frames.RootFrame.Metadata.XmpProfile = original; - var encoder = new TiffEncoder(); + TiffEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -201,10 +201,10 @@ public class XmpProfileTests public void WritingWebp_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new WebpEncoder(); + WebpEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -228,13 +228,13 @@ public class XmpProfileTests { string content = $" "; byte[] data = Encoding.UTF8.GetBytes(content); - var profile = new XmpProfile(data); + XmpProfile profile = new(data); return profile; } private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs index 04183571b..f194484c4 100644 --- a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs @@ -14,15 +14,15 @@ public class SignedRationalTests [Fact] public void AreEqual() { - var r1 = new SignedRational(3, 2); - var r2 = new SignedRational(3, 2); + SignedRational r1 = new(3, 2); + SignedRational r2 = new(3, 2); Assert.Equal(r1, r2); Assert.True(r1 == r2); - var r3 = new SignedRational(7.55); - var r4 = new SignedRational(755, 100); - var r5 = new SignedRational(151, 20); + SignedRational r3 = new(7.55); + SignedRational r4 = new(755, 100); + SignedRational r5 = new(151, 20); Assert.Equal(r3, r4); Assert.Equal(r4, r5); @@ -34,8 +34,8 @@ public class SignedRationalTests [Fact] public void AreNotEqual() { - var first = new SignedRational(0, 100); - var second = new SignedRational(100, 100); + SignedRational first = new(0, 100); + SignedRational second = new(100, 100); Assert.NotEqual(first, second); Assert.True(first != second); @@ -47,7 +47,7 @@ public class SignedRationalTests [Fact] public void ConstructorAssignsProperties() { - var rational = new SignedRational(7, -55); + SignedRational rational = new(7, -55); Assert.Equal(7, rational.Numerator); Assert.Equal(-55, rational.Denominator); @@ -75,15 +75,15 @@ public class SignedRationalTests [Fact] public void Fraction() { - var first = new SignedRational(1.0 / 1600); - var second = new SignedRational(1.0 / 1600, true); + SignedRational first = new(1.0 / 1600); + SignedRational second = new(1.0 / 1600, true); Assert.False(first.Equals(second)); } [Fact] public void ToDouble() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); rational = new SignedRational(2, 0); @@ -96,7 +96,7 @@ public class SignedRationalTests [Fact] public void ToStringRepresentation() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); rational = new SignedRational(double.PositiveInfinity); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index d375a74c6..2c97cbde0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -15,7 +15,7 @@ public class PorterDuffFunctionsTestsTPixel return new Span(new[] { value }); } - public static TheoryData NormalBlendFunctionData = new TheoryData + public static TheoryData NormalBlendFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) } @@ -46,12 +46,12 @@ public class PorterDuffFunctionsTestsTPixel public void NormalBlendFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.NormalSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData MultiplyFunctionData = new TheoryData + public static TheoryData MultiplyFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, @@ -86,12 +86,12 @@ public class PorterDuffFunctionsTestsTPixel public void MultiplyFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.MultiplySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData AddFunctionData = new TheoryData + public static TheoryData AddFunctionData = new() { { new TestPixel(1, 1, 1, 1), @@ -136,12 +136,12 @@ public class PorterDuffFunctionsTestsTPixel public void AddFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.AddSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData SubtractFunctionData = new TheoryData + public static TheoryData SubtractFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(0, 0, 0, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -176,12 +176,12 @@ public class PorterDuffFunctionsTestsTPixel public void SubtractFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.SubtractSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData ScreenFunctionData = new TheoryData + public static TheoryData ScreenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -216,12 +216,12 @@ public class PorterDuffFunctionsTestsTPixel public void ScreenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.ScreenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData DarkenFunctionData = new TheoryData + public static TheoryData DarkenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(.6f, .6f, .6f, 1f) }, @@ -256,12 +256,12 @@ public class PorterDuffFunctionsTestsTPixel public void DarkenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.DarkenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData LightenFunctionData = new TheoryData + public static TheoryData LightenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -296,12 +296,12 @@ public class PorterDuffFunctionsTestsTPixel public void LightenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.LightenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData OverlayFunctionData = new TheoryData + public static TheoryData OverlayFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -336,12 +336,12 @@ public class PorterDuffFunctionsTestsTPixel public void OverlayFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.OverlaySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData HardLightFunctionData = new TheoryData + public static TheoryData HardLightFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1f) }, @@ -376,7 +376,7 @@ public class PorterDuffFunctionsTestsTPixel public void HardLightFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.HardLightSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } diff --git a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs index 9c0e83a7f..0ea429a77 100644 --- a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs @@ -49,7 +49,7 @@ public class ColorMatrixTests ColorMatrix value1 = CreateAllTwos(); ColorMatrix value2 = CreateAllThrees(); - var m = default(ColorMatrix); + ColorMatrix m = default(ColorMatrix); // First row m.M11 = (value1.M11 * value2.M11) + (value1.M12 * value2.M21) + (value1.M13 * value2.M31) + (value1.M14 * value2.M41); diff --git a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs index ecc592326..f83ebc53c 100644 --- a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -38,7 +38,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixReturnsCorrectDimensions() { - var dense = new DenseMatrix(FloydSteinbergMatrix); + DenseMatrix dense = new(FloydSteinbergMatrix); Assert.True(dense.Columns == FloydSteinbergMatrix.GetLength(1)); Assert.True(dense.Rows == FloydSteinbergMatrix.GetLength(0)); Assert.Equal(3, dense.Columns); @@ -63,7 +63,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixGetSetReturnsCorrectResults() { - var dense = new DenseMatrix(4, 4); + DenseMatrix dense = new(4, 4); const int Val = 5; dense[3, 3] = Val; @@ -74,7 +74,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixCanFillAndClear() { - var dense = new DenseMatrix(9); + DenseMatrix dense = new(9); dense.Fill(4); for (int i = 0; i < dense.Data.Length; i++) @@ -100,7 +100,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixCanTranspose() { - var dense = new DenseMatrix(3, 1); + DenseMatrix dense = new(3, 1); dense[0, 0] = 1; dense[0, 1] = 2; dense[0, 2] = 3; @@ -117,9 +117,9 @@ public class DenseMatrixTests [Fact] public void DenseMatrixEquality() { - var dense = new DenseMatrix(3, 1); - var dense2 = new DenseMatrix(3, 1); - var dense3 = new DenseMatrix(1, 3); + DenseMatrix dense = new(3, 1); + DenseMatrix dense2 = new(3, 1); + DenseMatrix dense3 = new(1, 3); Assert.True(dense == dense2); Assert.False(dense != dense2); diff --git a/tests/ImageSharp.Tests/Primitives/PointFTests.cs b/tests/ImageSharp.Tests/Primitives/PointFTests.cs index c3d9e8176..8b574daf0 100644 --- a/tests/ImageSharp.Tests/Primitives/PointFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointFTests.cs @@ -9,13 +9,12 @@ namespace SixLabors.ImageSharp.Tests; public class PointFTests { - private static readonly ApproximateFloatComparer ApproximateFloatComparer = - new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer ApproximateFloatComparer = new(1e-6f); [Fact] public void CanReinterpretCastFromVector2() { - var vector = new Vector2(1, 2); + Vector2 vector = new(1, 2); PointF point = Unsafe.As(ref vector); @@ -37,7 +36,7 @@ public class PointFTests [InlineData(0.0, 0.0)] public void NonDefaultConstructorTest(float x, float y) { - var p1 = new PointF(x, y); + PointF p1 = new(x, y); Assert.Equal(x, p1.X); Assert.Equal(y, p1.Y); @@ -67,7 +66,7 @@ public class PointFTests [InlineData(0, 0)] public void CoordinatesTest(float x, float y) { - var p = new PointF(x, y); + PointF p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); @@ -84,11 +83,11 @@ public class PointFTests [InlineData(0, 0, 0, 0)] public void ArithmeticTestWithSize(float x, float y, int x1, int y1) { - var p = new PointF(x, y); - var s = new Size(x1, y1); + PointF p = new(x, y); + Size s = new(x1, y1); - var addExpected = new PointF(x + x1, y + y1); - var subExpected = new PointF(x - x1, y - y1); + PointF addExpected = new(x + x1, y + y1); + PointF subExpected = new(x - x1, y - y1); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -101,11 +100,11 @@ public class PointFTests [InlineData(0, 0)] public void ArithmeticTestWithSizeF(float x, float y) { - var p = new PointF(x, y); - var s = new SizeF(y, x); + PointF p = new(x, y); + SizeF s = new(y, x); - var addExpected = new PointF(x + y, y + x); - var subExpected = new PointF(x - y, y - x); + PointF addExpected = new(x + y, y + x); + PointF subExpected = new(x - y, y - x); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -115,10 +114,10 @@ public class PointFTests [Fact] public void RotateTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, PointF.Empty); - var pout = PointF.Transform(p, matrix); + PointF pout = PointF.Transform(p, matrix); Assert.Equal(-2.82842732F, pout.X, ApproximateFloatComparer); Assert.Equal(21.2132034F, pout.Y, ApproximateFloatComparer); @@ -127,10 +126,10 @@ public class PointFTests [Fact] public void SkewTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, PointF.Empty); - var pout = PointF.Transform(p, matrix); + PointF pout = PointF.Transform(p, matrix); Assert.Equal(new PointF(30, 30), pout); } @@ -142,8 +141,8 @@ public class PointFTests [InlineData(0, 0)] public void EqualityTest(float x, float y) { - var pLeft = new PointF(x, y); - var pRight = new PointF(y, x); + PointF pLeft = new(x, y); + PointF pRight = new(y, x); if (x == y) { @@ -164,7 +163,7 @@ public class PointFTests [Fact] public void EqualityTest_NotPointF() { - var point = new PointF(0, 0); + PointF point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); @@ -180,7 +179,7 @@ public class PointFTests [Fact] public void GetHashCodeTest() { - var point = new PointF(10, 10); + PointF point = new(10, 10); Assert.Equal(point.GetHashCode(), new PointF(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(10, 20).GetHashCode()); @@ -189,7 +188,7 @@ public class PointFTests [Fact] public void ToStringTest() { - var p = new PointF(5.1F, -5.123F); + PointF p = new(5.1F, -5.123F); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -200,7 +199,7 @@ public class PointFTests [InlineData(0, 0)] public void DeconstructTest(float x, float y) { - PointF p = new PointF(x, y); + PointF p = new(x, y); (float deconstructedX, float deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/PointTests.cs b/tests/ImageSharp.Tests/Primitives/PointTests.cs index f5c64abf5..3ad2a83b3 100644 --- a/tests/ImageSharp.Tests/Primitives/PointTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointTests.cs @@ -21,8 +21,8 @@ public class PointTests [InlineData(0, 0)] public void NonDefaultConstructorTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(new Size(x, y)); + Point p1 = new(x, y); + Point p2 = new(new Size(x, y)); Assert.Equal(p1, p2); } @@ -33,8 +33,8 @@ public class PointTests [InlineData(0)] public void SingleIntConstructorTest(int x) { - var p1 = new Point(x); - var p2 = new Point(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); + Point p1 = new(x); + Point p2 = new(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); Assert.Equal(p1, p2); } @@ -63,7 +63,7 @@ public class PointTests [InlineData(0, 0)] public void CoordinatesTest(int x, int y) { - var p = new Point(x, y); + Point p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); } @@ -86,7 +86,7 @@ public class PointTests [InlineData(0, 0)] public void SizeConversionTest(int x, int y) { - var sz = (Size)new Point(x, y); + Size sz = (Size)new Point(x, y); Assert.Equal(new Size(x, y), sz); } @@ -97,8 +97,8 @@ public class PointTests [InlineData(0, 0)] public void ArithmeticTest(int x, int y) { - Point addExpected, subExpected, p = new Point(x, y); - var s = new Size(y, x); + Point addExpected, subExpected, p = new(x, y); + Size s = new(y, x); unchecked { @@ -119,7 +119,7 @@ public class PointTests [InlineData(0, 0)] public void PointFMathematicalTest(float x, float y) { - var pf = new PointF(x, y); + PointF pf = new(x, y); Point pCeiling, pTruncate, pRound; unchecked @@ -141,8 +141,8 @@ public class PointTests [InlineData(0, 0)] public void OffsetTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(y, x); + Point p1 = new(x, y); + Point p2 = new(y, x); p1.Offset(p2); @@ -156,10 +156,10 @@ public class PointTests [Fact] public void RotateTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, Point.Empty); - var pout = Point.Transform(p, matrix); + Point pout = Point.Transform(p, matrix); Assert.Equal(new Point(-3, 21), pout); } @@ -167,10 +167,10 @@ public class PointTests [Fact] public void SkewTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, Point.Empty); - var pout = Point.Transform(p, matrix); + Point pout = Point.Transform(p, matrix); Assert.Equal(new Point(30, 30), pout); } @@ -181,9 +181,9 @@ public class PointTests [InlineData(0, 0)] public void EqualityTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point((x / 2) - 1, (y / 2) - 1); - var p3 = new Point(x, y); + Point p1 = new(x, y); + Point p2 = new((x / 2) - 1, (y / 2) - 1); + Point p3 = new(x, y); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -203,7 +203,7 @@ public class PointTests [Fact] public void EqualityTest_NotPoint() { - var point = new Point(0, 0); + Point point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); Assert.False(point.Equals(new PointF(0, 0))); @@ -212,7 +212,7 @@ public class PointTests [Fact] public void GetHashCodeTest() { - var point = new Point(10, 10); + Point point = new(10, 10); Assert.Equal(point.GetHashCode(), new Point(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(10, 20).GetHashCode()); @@ -223,7 +223,7 @@ public class PointTests [InlineData(1, -2, 3, -4)] public void ConversionTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); + Rectangle rect = new(x, y, width, height); RectangleF rectF = rect; Assert.Equal(x, rectF.X); Assert.Equal(y, rectF.Y); @@ -234,7 +234,7 @@ public class PointTests [Fact] public void ToStringTest() { - var p = new Point(5, -5); + Point p = new(5, -5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -245,7 +245,7 @@ public class PointTests [InlineData(0, 0)] public void DeconstructTest(int x, int y) { - Point p = new Point(x, y); + Point p = new(x, y); (int deconstructedX, int deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs index a9b3251ca..4122daaa5 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs @@ -23,10 +23,10 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void NonDefaultConstructorTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); - var rect2 = new RectangleF(p, s); + RectangleF rect1 = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); + RectangleF rect2 = new(p, s); Assert.Equal(rect1, rect2); } @@ -38,8 +38,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void FromLTRBTest(float left, float top, float right, float bottom) { - var expected = new RectangleF(left, top, right - left, bottom - top); - var actual = RectangleF.FromLTRB(left, top, right, bottom); + RectangleF expected = new(left, top, right - left, bottom - top); + RectangleF actual = RectangleF.FromLTRB(left, top, right, bottom); Assert.Equal(expected, actual); } @@ -51,9 +51,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void DimensionsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); + RectangleF rect = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); Assert.Equal(p, rect.Location); Assert.Equal(s, rect.Size); @@ -84,8 +84,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void LocationSetTest(float x, float y) { - var point = new PointF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Location = point }; + PointF point = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -96,8 +96,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void SizeSetTest(float x, float y) { - var size = new SizeF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Size = size }; + SizeF size = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -109,8 +109,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void EqualityTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(width, height, x, y); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(width, height, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -121,7 +121,7 @@ public class RectangleFTests [Fact] public void EqualityTestNotRectangleF() { - var rectangle = new RectangleF(0, 0, 0, 0); + RectangleF rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); @@ -137,8 +137,8 @@ public class RectangleFTests [Fact] public void GetHashCodeTest() { - var rect1 = new RectangleF(10, 10, 10, 10); - var rect2 = new RectangleF(10, 10, 10, 10); + RectangleF rect1 = new(10, 10, 10, 10); + RectangleF rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 20, 10, 10).GetHashCode()); @@ -151,11 +151,11 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void ContainsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); float x1 = (x + width) / 2; float y1 = (y + height) / 2; - var p = new PointF(x1, y1); - var r = new RectangleF(x1, y1, width / 2, height / 2); + PointF p = new(x1, y1); + RectangleF r = new(x1, y1, width / 2, height / 2); Assert.False(rect.Contains(x1, y1)); Assert.False(rect.Contains(p)); @@ -168,13 +168,13 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var inflatedRect = new RectangleF(x - width, y - height, width + (2 * width), height + (2 * height)); + RectangleF rect = new(x, y, width, height); + RectangleF inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new SizeF(x, y); + SizeF s = new(x, y); inflatedRect = RectangleF.Inflate(rect, x, y); rect.Inflate(s); @@ -186,9 +186,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(y, x, width, height); - var expectedRect = RectangleF.Intersect(rect1, rect2); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(y, x, width, height); + RectangleF expectedRect = RectangleF.Intersect(rect1, rect2); rect1.Intersect(rect2); Assert.Equal(expectedRect, rect1); Assert.False(rect1.IntersectsWith(expectedRect)); @@ -197,9 +197,9 @@ public class RectangleFTests [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new RectangleF(0, 0, 5, 5); - var rect2 = new RectangleF(1, 1, 3, 3); - var expected = new RectangleF(1, 1, 3, 3); + RectangleF rect1 = new(0, 0, 5, 5); + RectangleF rect2 = new(1, 1, 3, 3); + RectangleF expected = new(1, 1, 3, 3); Assert.Equal(expected, RectangleF.Intersect(rect1, rect2)); } @@ -211,15 +211,15 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void UnionTest(float x, float y, float width, float height) { - var a = new RectangleF(x, y, width, height); - var b = new RectangleF(width, height, x, y); + RectangleF a = new(x, y, width, height); + RectangleF b = new(width, height, x, y); float x1 = Math.Min(a.X, b.X); float x2 = Math.Max(a.X + a.Width, b.X + b.Width); float y1 = Math.Min(a.Y, b.Y); float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); + RectangleF expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, RectangleF.Union(a, b)); } @@ -231,9 +231,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void OffsetTest(float x, float y, float width, float height) { - var r1 = new RectangleF(x, y, width, height); - var expectedRect = new RectangleF(x + width, y + height, width, height); - var p = new PointF(width, height); + RectangleF r1 = new(x, y, width, height); + RectangleF expectedRect = new(x + width, y + height, width, height); + PointF p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -246,7 +246,7 @@ public class RectangleFTests [Fact] public void ToStringTest() { - var r = new RectangleF(5, 5.1F, 1.3F, 1); + RectangleF r = new(5, 5.1F, 1.3F, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -270,7 +270,7 @@ public class RectangleFTests [InlineData(0, 0, 0, 0)] public void DeconstructTest(float x, float y, float width, float height) { - RectangleF r = new RectangleF(x, y, width, height); + RectangleF r = new(x, y, width, height); (float dx, float dy, float dw, float dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs index 2ba3a7731..2800852af 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs @@ -23,8 +23,8 @@ public class RectangleTests [InlineData(0, int.MinValue, 0, int.MaxValue)] public void NonDefaultConstructorTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(new Point(x, y), new Size(width, height)); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(new Point(x, y), new Size(width, height)); Assert.Equal(rect1, rect2); } @@ -36,8 +36,8 @@ public class RectangleTests [InlineData(0, int.MinValue, 0, int.MaxValue)] public void FromLTRBTest(int left, int top, int right, int bottom) { - var rect1 = new Rectangle(left, top, unchecked(right - left), unchecked(bottom - top)); - var rect2 = Rectangle.FromLTRB(left, top, right, bottom); + Rectangle rect1 = new(left, top, unchecked(right - left), unchecked(bottom - top)); + Rectangle rect2 = Rectangle.FromLTRB(left, top, right, bottom); Assert.Equal(rect1, rect2); } @@ -68,7 +68,7 @@ public class RectangleTests [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void DimensionsTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); + Rectangle rect = new(x, y, width, height); Assert.Equal(new Point(x, y), rect.Location); Assert.Equal(new Size(width, height), rect.Size); @@ -81,8 +81,8 @@ public class RectangleTests Assert.Equal(unchecked(x + width), rect.Right); Assert.Equal(unchecked(y + height), rect.Bottom); - var p = new Point(width, height); - var s = new Size(x, y); + Point p = new(width, height); + Size s = new(x, y); rect.Location = p; rect.Size = s; @@ -104,8 +104,8 @@ public class RectangleTests [InlineData(int.MaxValue, int.MinValue)] public void LocationSetTest(int x, int y) { - var point = new Point(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Location = point }; + Point point = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -116,8 +116,8 @@ public class RectangleTests [InlineData(int.MaxValue, int.MinValue)] public void SizeSetTest(int x, int y) { - var size = new Size(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Size = size }; + Size size = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -130,8 +130,8 @@ public class RectangleTests [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void EqualityTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(width / 2, height / 2, x, y); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(width / 2, height / 2, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -142,7 +142,7 @@ public class RectangleTests [Fact] public void EqualityTestNotRectangle() { - var rectangle = new Rectangle(0, 0, 0, 0); + Rectangle rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); Assert.False(rectangle.Equals(new RectangleF(0, 0, 0, 0))); @@ -151,8 +151,8 @@ public class RectangleTests [Fact] public void GetHashCodeTest() { - var rect1 = new Rectangle(10, 10, 10, 10); - var rect2 = new Rectangle(10, 10, 10, 10); + Rectangle rect1 = new(10, 10, 10, 10); + Rectangle rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 20, 10, 10).GetHashCode()); @@ -166,7 +166,7 @@ public class RectangleTests [InlineData(0, 0, 0, 0)] public void RectangleFConversionTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); Rectangle rCeiling, rTruncate, rRound; unchecked @@ -196,9 +196,9 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void ContainsTest(int x, int y, int width, int height) { - var rect = new Rectangle(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); - var p = new Point(x, y); - var r = new Rectangle(x, y, width / 2, height / 2); + Rectangle rect = new(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); + Point p = new(x, y); + Rectangle r = new(x, y, width / 2, height / 2); Assert.False(rect.Contains(x, y)); Assert.False(rect.Contains(p)); @@ -211,7 +211,7 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void InflateTest(int x, int y, int width, int height) { - Rectangle inflatedRect, rect = new Rectangle(x, y, width, height); + Rectangle inflatedRect, rect = new(x, y, width, height); unchecked { inflatedRect = new Rectangle(x - width, y - height, width + (2 * width), height + (2 * height)); @@ -222,7 +222,7 @@ public class RectangleTests rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new Size(x, y); + Size s = new(x, y); unchecked { inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); @@ -238,8 +238,8 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void IntersectTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - var expectedRect = Rectangle.Intersect(rect, rect); + Rectangle rect = new(x, y, width, height); + Rectangle expectedRect = Rectangle.Intersect(rect, rect); rect.Intersect(rect); Assert.Equal(expectedRect, rect); Assert.False(rect.IntersectsWith(expectedRect)); @@ -248,9 +248,9 @@ public class RectangleTests [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new Rectangle(0, 0, 5, 5); - var rect2 = new Rectangle(1, 1, 3, 3); - var expected = new Rectangle(1, 1, 3, 3); + Rectangle rect1 = new(0, 0, 5, 5); + Rectangle rect2 = new(1, 1, 3, 3); + Rectangle expected = new(1, 1, 3, 3); Assert.Equal(expected, Rectangle.Intersect(rect1, rect2)); } @@ -262,15 +262,15 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void UnionTest(int x, int y, int width, int height) { - var a = new Rectangle(x, y, width, height); - var b = new Rectangle(width, height, x, y); + Rectangle a = new(x, y, width, height); + Rectangle b = new(width, height, x, y); int x1 = Math.Min(a.X, b.X); int x2 = Math.Max(a.X + a.Width, b.X + b.Width); int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new Rectangle(x1, y1, x2 - x1, y2 - y1); + Rectangle expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, Rectangle.Union(a, b)); } @@ -282,9 +282,9 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void OffsetTest(int x, int y, int width, int height) { - var r1 = new Rectangle(x, y, width, height); - var expectedRect = new Rectangle(x + width, y + height, width, height); - var p = new Point(width, height); + Rectangle r1 = new(x, y, width, height); + Rectangle expectedRect = new(x + width, y + height, width, height); + Point p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -297,7 +297,7 @@ public class RectangleTests [Fact] public void ToStringTest() { - var r = new Rectangle(5, -5, 0, 1); + Rectangle r = new(5, -5, 0, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -321,7 +321,7 @@ public class RectangleTests [InlineData(0, 0, 0, 0)] public void DeconstructTest(int x, int y, int width, int height) { - var r = new Rectangle(x, y, width, height); + Rectangle r = new(x, y, width, height); (int dx, int dy, int dw, int dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs index 1a36b4921..2893a7c71 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs @@ -20,9 +20,9 @@ public class SizeFTests [InlineData(0, 0)] public void NonDefaultConstructorAndDimensionsTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = new PointF(width, height); - var s2 = new SizeF(s1); + SizeF s1 = new(width, height); + PointF p1 = new(width, height); + SizeF s2 = new(s1); Assert.Equal(s1, s2); Assert.Equal(s1, new SizeF(p1)); @@ -62,10 +62,10 @@ public class SizeFTests [InlineData(0, 0)] public void ArithmeticTest(float width, float height) { - var s1 = new SizeF(width, height); - var s2 = new SizeF(height, width); - var addExpected = new SizeF(width + height, width + height); - var subExpected = new SizeF(width - height, height - width); + SizeF s1 = new(width, height); + SizeF s2 = new(height, width); + SizeF addExpected = new(width + height, width + height); + SizeF subExpected = new(width - height, height - width); Assert.Equal(addExpected, s1 + s2); Assert.Equal(addExpected, SizeF.Add(s1, s2)); @@ -81,8 +81,8 @@ public class SizeFTests [InlineData(0, 0)] public void EqualityTest(float width, float height) { - var sLeft = new SizeF(width, height); - var sRight = new SizeF(height, width); + SizeF sLeft = new(width, height); + SizeF sRight = new(height, width); if (width == height) { @@ -103,7 +103,7 @@ public class SizeFTests [Fact] public void EqualityTest_NotSizeF() { - var size = new SizeF(0, 0); + SizeF size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); @@ -119,7 +119,7 @@ public class SizeFTests [Fact] public void GetHashCodeTest() { - var size = new SizeF(10, 10); + SizeF size = new(10, 10); Assert.Equal(size.GetHashCode(), new SizeF(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(10, 20).GetHashCode()); @@ -132,9 +132,9 @@ public class SizeFTests [InlineData(0, 0)] public void ConversionTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = (PointF)s1; - var s2 = new Size(unchecked((int)width), unchecked((int)height)); + SizeF s1 = new(width, height); + PointF p1 = (PointF)s1; + Size s2 = new(unchecked((int)width), unchecked((int)height)); Assert.Equal(new PointF(width, height), p1); Assert.Equal(p1, (PointF)s1); @@ -144,7 +144,7 @@ public class SizeFTests [Fact] public void ToStringTest() { - var sz = new SizeF(10, 5); + SizeF sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "SizeF [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -172,7 +172,7 @@ public class SizeFTests [InlineData(float.MinValue, float.MinValue)] public void MultiplicationTest(float dimension, float multiplier) { - SizeF sz1 = new SizeF(dimension, dimension); + SizeF sz1 = new(dimension, dimension); SizeF mulExpected; mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); @@ -185,7 +185,7 @@ public class SizeFTests [InlineData(1111.1111f, 2222.2222f, 3333.3333f)] public void MultiplicationTestWidthHeightMultiplier(float width, float height, float multiplier) { - SizeF sz1 = new SizeF(width, height); + SizeF sz1 = new(width, height); SizeF mulExpected; mulExpected = new SizeF(width * multiplier, height * multiplier); @@ -215,8 +215,8 @@ public class SizeFTests [InlineData(-1.0f, float.MaxValue)] public void DivideTestSizeFloat(float dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); - SizeF expected = new SizeF(dimension / divisor, dimension / divisor); + SizeF size = new(dimension, dimension); + SizeF expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -224,8 +224,8 @@ public class SizeFTests [InlineData(-111.111f, 222.222f, 333.333f)] public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, float divisor) { - SizeF size = new SizeF(width, height); - SizeF expected = new SizeF(width / divisor, height / divisor); + SizeF size = new(width, height); + SizeF expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -236,7 +236,7 @@ public class SizeFTests [InlineData(0, 0)] public void DeconstructTest(float width, float height) { - SizeF s = new SizeF(width, height); + SizeF s = new(width, height); (float deconstructedWidth, float deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Primitives/SizeTests.cs b/tests/ImageSharp.Tests/Primitives/SizeTests.cs index eec1fb63b..63320796a 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeTests.cs @@ -23,8 +23,8 @@ public class SizeTests [InlineData(0, 0)] public void NonDefaultConstructorTest(int width, int height) { - var s1 = new Size(width, height); - var s2 = new Size(new Point(width, height)); + Size s1 = new(width, height); + Size s2 = new(new Point(width, height)); Assert.Equal(s1, s2); @@ -59,7 +59,7 @@ public class SizeTests [InlineData(0, 0)] public void DimensionsTest(int width, int height) { - var p = new Size(width, height); + Size p = new(width, height); Assert.Equal(width, p.Width); Assert.Equal(height, p.Height); } @@ -82,7 +82,7 @@ public class SizeTests [InlineData(0, 0)] public void SizeConversionTest(int width, int height) { - var sz = (Point)new Size(width, height); + Point sz = (Point)new Size(width, height); Assert.Equal(new Point(width, height), sz); } @@ -93,8 +93,8 @@ public class SizeTests [InlineData(0, 0)] public void ArithmeticTest(int width, int height) { - var sz1 = new Size(width, height); - var sz2 = new Size(height, width); + Size sz1 = new(width, height); + Size sz2 = new(height, width); Size addExpected, subExpected; unchecked @@ -116,7 +116,7 @@ public class SizeTests [InlineData(0, 0)] public void PointFMathematicalTest(float width, float height) { - var szF = new SizeF(width, height); + SizeF szF = new(width, height); Size pCeiling, pTruncate, pRound; unchecked @@ -138,9 +138,9 @@ public class SizeTests [InlineData(0, 0)] public void EqualityTest(int width, int height) { - var p1 = new Size(width, height); - var p2 = new Size(unchecked(width - 1), unchecked(height - 1)); - var p3 = new Size(width, height); + Size p1 = new(width, height); + Size p2 = new(unchecked(width - 1), unchecked(height - 1)); + Size p3 = new(width, height); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -160,7 +160,7 @@ public class SizeTests [Fact] public void EqualityTest_NotSize() { - var size = new Size(0, 0); + Size size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); Assert.False(size.Equals(new SizeF(0, 0))); @@ -169,7 +169,7 @@ public class SizeTests [Fact] public void GetHashCodeTest() { - var size = new Size(10, 10); + Size size = new(10, 10); Assert.Equal(size.GetHashCode(), new Size(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(10, 20).GetHashCode()); @@ -178,7 +178,7 @@ public class SizeTests [Fact] public void ToStringTest() { - var sz = new Size(10, 5); + Size sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Size [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -206,7 +206,7 @@ public class SizeTests [InlineData(int.MinValue, int.MinValue)] public void MultiplicationTestSizeInt(int dimension, int multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); Size mulExpected; unchecked @@ -222,7 +222,7 @@ public class SizeTests [InlineData(1000, 2000, 3000)] public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height, int multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); Size mulExpected; unchecked @@ -258,7 +258,7 @@ public class SizeTests [InlineData(int.MinValue, float.MinValue)] public void MultiplicationTestSizeFloat(int dimension, float multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); SizeF mulExpected; mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); @@ -271,7 +271,7 @@ public class SizeTests [InlineData(1000, 2000, 30.33f)] public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int height, float multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); SizeF mulExpected; mulExpected = new SizeF(width * multiplier, height * multiplier); @@ -283,10 +283,10 @@ public class SizeTests [Fact] public void DivideByZeroChecks() { - Size size = new Size(100, 100); + Size size = new(100, 100); Assert.Throws(() => size / 0); - SizeF expectedSizeF = new SizeF(float.PositiveInfinity, float.PositiveInfinity); + SizeF expectedSizeF = new(float.PositiveInfinity, float.PositiveInfinity); Assert.Equal(expectedSizeF, size / 0.0f); } @@ -305,7 +305,7 @@ public class SizeTests [InlineData(int.MaxValue, -1)] public void DivideTestSizeInt(int dimension, int divisor) { - Size size = new Size(dimension, dimension); + Size size = new(dimension, dimension); Size expected; expected = new Size(dimension / divisor, dimension / divisor); @@ -317,7 +317,7 @@ public class SizeTests [InlineData(1111, 2222, 3333)] public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divisor) { - Size size = new Size(width, height); + Size size = new(width, height); Size expected; expected = new Size(width / divisor, height / divisor); @@ -341,7 +341,7 @@ public class SizeTests [InlineData(int.MinValue, -1.0f)] public void DivideTestSizeFloat(int dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); + SizeF size = new(dimension, dimension); SizeF expected; expected = new SizeF(dimension / divisor, dimension / divisor); @@ -352,7 +352,7 @@ public class SizeTests [InlineData(1111, 2222, -333.33f)] public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float divisor) { - SizeF size = new SizeF(width, height); + SizeF size = new(width, height); SizeF expected; expected = new SizeF(width / divisor, height / divisor); @@ -366,7 +366,7 @@ public class SizeTests [InlineData(0, 0)] public void DeconstructTest(int width, int height) { - Size s = new Size(width, height); + Size s = new(width, height); (int deconstructedWidth, int deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs index c7eb95953..32b8bf276 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs @@ -10,14 +10,14 @@ public class OrderedDitherFactoryTests { #pragma warning disable SA1025 // Code should not contain multiple whitespace in a row - private static readonly DenseMatrix Expected2x2Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected2x2Matrix = new( new uint[2, 2] { { 0, 2 }, { 3, 1 } }); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new uint[3, 3] { { 0, 5, 2 }, @@ -25,7 +25,7 @@ public class OrderedDitherFactoryTests { 3, 6, 1 } }); - private static readonly DenseMatrix Expected4x4Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected4x4Matrix = new( new uint[4, 4] { { 0, 8, 2, 10 }, @@ -34,7 +34,7 @@ public class OrderedDitherFactoryTests { 15, 7, 13, 5 } }); - private static readonly DenseMatrix Expected8x8Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected8x8Matrix = new( new uint[8, 8] { { 0, 32, 8, 40, 2, 34, 10, 42 }, diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index da2bc465f..2337e4567 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -13,7 +13,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(7, processor.Radius); } @@ -22,7 +22,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_amount_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(34); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(34, processor.Radius); } @@ -31,7 +31,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_amount_rect_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(5, this.rect); - var processor = this.Verify(this.rect); + BoxBlurProcessor processor = this.Verify(this.rect); Assert.Equal(5, processor.Radius); } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs index 476e5b0a9..d90ccee41 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs @@ -11,9 +11,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 0, 0, 0, 1, 2, @@ -30,9 +30,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 2, 1, 0, 1, 2, @@ -49,9 +49,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 1, 0, 0, 1, 2, @@ -68,9 +68,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 5, 6, 0, 1, 2, @@ -87,9 +87,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 3, 2, 1, 2, 3, @@ -108,9 +108,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 2, 1, 1, 2, 3, @@ -129,9 +129,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 8, 9, 1, 2, 3, @@ -150,9 +150,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 2, 2, 2, 3, 4, @@ -169,9 +169,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 4, 3, 2, 3, 4, @@ -188,9 +188,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 3, 2, 2, 3, 4, @@ -207,9 +207,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 7, 8, 2, 3, 4, @@ -226,9 +226,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 0, 0, 1, @@ -245,9 +245,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7BounceBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 1, 0, 1, @@ -264,9 +264,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7MirrorBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 0, 0, 1, @@ -283,9 +283,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 6, 0, 1, @@ -302,9 +302,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 2, 2, 3, @@ -321,9 +321,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7BounceBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 3, 2, 3, @@ -340,9 +340,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7MirrorBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 2, 2, 3, @@ -359,9 +359,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 8, 2, 3, @@ -378,9 +378,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x5WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 5); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 5); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] xExpected = { 8, 2, 3, @@ -405,15 +405,15 @@ public class KernelSamplingMapTest private void AssertOffsets(Size kernelSize, Rectangle bounds, BorderWrappingMode xBorderMode, BorderWrappingMode yBorderMode, int[] xExpected, int[] yExpected) { // Arrange - var map = new KernelSamplingMap(Configuration.Default.MemoryAllocator); + KernelSamplingMap map = new(Configuration.Default.MemoryAllocator); // Act map.BuildSamplingOffsetMap(kernelSize.Height, kernelSize.Width, bounds, xBorderMode, yBorderMode); // Assert - var xOffsets = map.GetColumnOffsetSpan().ToArray(); + int[] xOffsets = map.GetColumnOffsetSpan().ToArray(); Assert.Equal(xExpected, xOffsets); - var yOffsets = map.GetRowOffsetSpan().ToArray(); + int[] yOffsets = map.GetRowOffsetSpan().ToArray(); Assert.Equal(yExpected, yOffsets); } } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs index 800cb06ac..6c6fa6b2b 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs @@ -7,9 +7,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution.Processors; public class LaplacianKernelFactoryTests { - private static readonly ApproximateFloatComparer ApproximateComparer = new ApproximateFloatComparer(0.0001F); + private static readonly ApproximateFloatComparer ApproximateComparer = new(0.0001F); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new float[,] { { -1, -1, -1 }, @@ -17,7 +17,7 @@ public class LaplacianKernelFactoryTests { -1, -1, -1 } }); - private static readonly DenseMatrix Expected5x5Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected5x5Matrix = new( new float[,] { { -1, -1, -1, -1, -1 }, diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 6d5973dbb..b24ab6c81 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -13,7 +13,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -23,7 +23,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -33,7 +33,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_Levels_Brush_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(34, 65); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(34, processor.Levels); Assert.Equal(65, processor.BrushSize); @@ -43,7 +43,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_Levels_Brush_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(54, 43, this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(54, processor.Levels); Assert.Equal(43, processor.BrushSize); diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 6531f7b44..f557183d6 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -13,7 +13,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_PixelateProcessorDefaultsSet() { this.operations.Pixelate(); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(4, processor.Size); } @@ -22,7 +22,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_Size_PixelateProcessorDefaultsSet() { this.operations.Pixelate(12); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(12, processor.Size); } @@ -31,7 +31,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_Size_rect_PixelateProcessorDefaultsSet() { this.operations.Pixelate(23, this.rect); - var processor = this.Verify(this.rect); + PixelateProcessor processor = this.Verify(this.rect); Assert.Equal(23, processor.Size); } diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 17f63384e..703a64333 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing; internal class FakeImageOperationsProvider : IImageProcessingContextFactory { - private readonly List imageOperators = new List(); + private readonly List imageOperators = new(); public bool HasCreated(Image source) where TPixel : unmanaged, IPixel @@ -35,7 +35,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) where TPixel : unmanaged, IPixel { - var op = new FakeImageOperations(configuration, source, mutate); + FakeImageOperations op = new(configuration, source, mutate); this.imageOperators.Add(op); return op; } @@ -51,7 +51,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public Image Source { get; } - public List Applied { get; } = new List(); + public List Applied { get; } = new(); public Configuration Configuration { get; } diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 87436e4a3..135212400 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -31,7 +31,7 @@ public class BrightnessTest : BaseImageOperationsExtensionTest [Fact] public void Brightness_scaled_vector() { - var rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); + Image rgbImage = new(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); @@ -43,7 +43,7 @@ public class BrightnessTest : BaseImageOperationsExtensionTest Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]); - var halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-1)); + Image halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-1)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index 0c197a96f..33deb715b 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs @@ -13,7 +13,7 @@ public class HueTest : BaseImageOperationsExtensionTest public void Hue_amount_HueProcessorDefaultsSet() { this.operations.Hue(34f); - var processor = this.Verify(); + HueProcessor processor = this.Verify(); Assert.Equal(34f, processor.Degrees); } @@ -22,7 +22,7 @@ public class HueTest : BaseImageOperationsExtensionTest public void Hue_amount_rect_HueProcessorDefaultsSet() { this.operations.Hue(5f, this.rect); - var processor = this.Verify(this.rect); + HueProcessor processor = this.Verify(this.rect); Assert.Equal(5f, processor.Degrees); } diff --git a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs index e84bd243e..f68ecef08 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs @@ -13,7 +13,7 @@ public class LomographTest : BaseImageOperationsExtensionTest public void Lomograph_amount_LomographProcessorDefaultsSet() { this.operations.Lomograph(); - var processor = this.Verify(); + LomographProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public class LomographTest : BaseImageOperationsExtensionTest public void Lomograph_amount_rect_LomographProcessorDefaultsSet() { this.operations.Lomograph(this.rect); - var processor = this.Verify(this.rect); + LomographProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs index 7d3e0aed0..89d8d47bc 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs @@ -13,7 +13,7 @@ public class PolaroidTest : BaseImageOperationsExtensionTest public void Polaroid_amount_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(); - var processor = this.Verify(); + PolaroidProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public class PolaroidTest : BaseImageOperationsExtensionTest public void Polaroid_amount_rect_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(this.rect); - var processor = this.Verify(this.rect); + PolaroidProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs index 744e26d8f..09fbcdc70 100644 --- a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs @@ -24,7 +24,7 @@ public class ImageOperationTests : IDisposable { this.provider = new FakeImageOperationsProvider(); - var processorMock = new Mock(); + Mock processorMock = new(); this.processorDefinition = processorMock.Object; this.image = new Image( @@ -103,7 +103,7 @@ public class ImageOperationTests : IDisposable [Fact] public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation() { - var operations = new FakeImageOperationsProvider.FakeImageOperations(Configuration.Default, null, false); + FakeImageOperationsProvider.FakeImageOperations operations = new(Configuration.Default, null, false); operations.ApplyProcessors(this.processorDefinition); Assert.Contains(this.processorDefinition, operations.Applied.Select(x => x.NonGenericProcessor)); } @@ -152,7 +152,7 @@ public class ImageOperationTests : IDisposable { try { - var img = new Image(1, 1); + Image img = new(1, 1); img.Dispose(); img.EnsureNotDisposed(); } diff --git a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs index 88707c60f..e39d8075b 100644 --- a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs @@ -23,7 +23,7 @@ public class ImageProcessingContextTests : IDisposable private readonly Mock> cloningProcessorImpl; - private static readonly Rectangle Bounds = new Rectangle(3, 3, 5, 5); + private static readonly Rectangle Bounds = new(3, 3, 5, 5); public ImageProcessingContextTests() { @@ -34,7 +34,7 @@ public class ImageProcessingContextTests : IDisposable } // bool throwException, bool useBounds - public static readonly TheoryData ProcessorTestData = new TheoryData() + public static readonly TheoryData ProcessorTestData = new() { { false, false }, { false, true }, diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index 60e33835a..5c5fd20e4 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -32,7 +32,7 @@ public class HistogramEqualizationTests 70, 87, 69, 68, 65, 73, 78, 90 }; - using (var image = new Image(8, 8)) + using (Image image = new(8, 8)) { for (int y = 0; y < 8; y++) { @@ -83,7 +83,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.Global, LuminanceLevels = 256, @@ -101,7 +101,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveSlidingWindow, LuminanceLevels = 256, @@ -121,7 +121,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -141,7 +141,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -160,7 +160,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -187,7 +187,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -214,7 +214,7 @@ public class HistogramEqualizationTests // https://github.com/SixLabors/ImageSharp/discussions/1640 // Test using isolated memory to ensure clean buffers for reference provider.Configuration = Configuration.CreateDefaultInstance(); - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 4096, diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 7eec6eb0c..c7881597a 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -45,7 +45,7 @@ public class GlowTest : BaseImageOperationsExtensionTest [Fact] public void Glow_Rect_GlowProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Glow(rect); GlowProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 1602b5c7a..e222c566f 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -48,7 +48,7 @@ public class VignetteTest : BaseImageOperationsExtensionTest [Fact] public void Vignette_Rect_VignetteProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Vignette(rect); VignetteProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 9694aeb22..64dd7a866 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -17,7 +17,7 @@ public class BinaryDitherTests TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; - public static readonly TheoryData OrderedDitherers = new TheoryData + public static readonly TheoryData OrderedDitherers = new() { { "Bayer8x8", KnownDitherings.Bayer8x8 }, { "Bayer4x4", KnownDitherings.Bayer4x4 }, @@ -25,7 +25,7 @@ public class BinaryDitherTests { "Bayer2x2", KnownDitherings.Bayer2x2 } }; - public static readonly TheoryData ErrorDiffusers = new TheoryData + public static readonly TheoryData ErrorDiffusers = new() { { "Atkinson", KnownDitherings.Atkinson }, { "Burks", KnownDitherings.Burks }, @@ -102,7 +102,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultDitherer, bounds)); image.DebugSave(provider); @@ -119,7 +119,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultErrorDiffuser, bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index ecbbb21ab..9c63d0f7c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization; public class BinaryThresholdTest { public static readonly TheoryData BinaryThresholdValues - = new TheoryData - { + = new() + { .25F, .75F }; @@ -46,7 +46,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, bounds)); image.DebugSave(provider, value); @@ -76,7 +76,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.Saturation, bounds)); image.DebugSave(provider, value); @@ -96,7 +96,7 @@ public class BinaryThresholdTest if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else @@ -114,14 +114,14 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.MaxChroma, bounds)); image.DebugSave(provider, value); if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs index 13ddf85c1..455aa48ae 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs @@ -12,7 +12,7 @@ public abstract class Basic1ParameterConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); - public static readonly TheoryData Values = new TheoryData { 3, 5 }; + public static readonly TheoryData Values = new() { 3, 5 }; public static readonly string[] InputImages = { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs index 0cb56b732..468965f1e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs @@ -12,7 +12,7 @@ public class ConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); - public static readonly TheoryData> Values = new TheoryData> + public static readonly TheoryData> Values = new() { // Sharpening kernel. new float[,] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index d51012f9e..04344e130 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -22,16 +22,16 @@ public class DetectEdgesTest public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; public static readonly TheoryData DetectEdgesFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Laplacian3x3, nameof(KnownEdgeDetectorKernels.Laplacian3x3) }, { KnownEdgeDetectorKernels.Laplacian5x5, nameof(KnownEdgeDetectorKernels.Laplacian5x5) }, { KnownEdgeDetectorKernels.LaplacianOfGaussian, nameof(KnownEdgeDetectorKernels.LaplacianOfGaussian) }, }; public static readonly TheoryData DetectEdges2DFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kayyali, nameof(KnownEdgeDetectorKernels.Kayyali) }, { KnownEdgeDetectorKernels.Prewitt, nameof(KnownEdgeDetectorKernels.Prewitt) }, { KnownEdgeDetectorKernels.RobertsCross, nameof(KnownEdgeDetectorKernels.RobertsCross) }, @@ -40,8 +40,8 @@ public class DetectEdgesTest }; public static readonly TheoryData DetectEdgesCompassFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kirsch, nameof(KnownEdgeDetectorKernels.Kirsch) }, { KnownEdgeDetectorKernels.Robinson, nameof(KnownEdgeDetectorKernels.Robinson) }, }; @@ -55,7 +55,7 @@ public class DetectEdgesTest ctx => { Size size = ctx.GetCurrentSize(); - var bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); + Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2); ctx.DetectEdges(bounds); }, comparer: OpaqueComparer, @@ -158,7 +158,7 @@ public class DetectEdgesTest { using (Image image = provider.GetImage()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.DetectEdges(bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index b8e968f73..3cc965334 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -17,7 +17,7 @@ public class DitherTests public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; public static readonly TheoryData ErrorDiffusers - = new TheoryData + = new() { { KnownDitherings.Atkinson, nameof(KnownDitherings.Atkinson) }, { KnownDitherings.Burks, nameof(KnownDitherings.Burks) }, @@ -31,7 +31,7 @@ public class DitherTests }; public static readonly TheoryData OrderedDitherers - = new TheoryData + = new() { { KnownDitherings.Bayer2x2, nameof(KnownDitherings.Bayer2x2) }, { KnownDitherings.Bayer4x4, nameof(KnownDitherings.Bayer4x4) }, @@ -41,7 +41,7 @@ public class DitherTests }; public static readonly TheoryData DefaultInstanceDitherers - = new TheoryData + = new() { default(ErrorDither), default(OrderedDither) @@ -101,7 +101,7 @@ public class DitherTests } // Increased tolerance because of compatibility issues on .NET 4.6.2: - var comparer = ImageComparer.TolerantPercentage(1f); + ImageComparer comparer = ImageComparer.TolerantPercentage(1f); provider.RunValidatingProcessorTest(x => x.Dither(DefaultErrorDiffuser), comparer: comparer); } @@ -186,7 +186,7 @@ public class DitherTests { void Command() { - using var image = new Image(10, 10); + using Image image = new(10, 10); image.Mutate(x => x.Dither(dither)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 10811a559..f3d8fd63a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -11,8 +11,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class OilPaintTest { - public static readonly TheoryData OilPaintValues = new TheoryData - { + public static readonly TheoryData OilPaintValues = new() + { { 15, 10 }, { 6, 5 } }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index fd732f570..b88ab37fe 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -71,7 +71,7 @@ public class PixelShaderTest Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } @@ -101,7 +101,7 @@ public class PixelShaderTest Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index 29b952403..fff7ba018 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class PixelateTest { - public static readonly TheoryData PixelateValues = new TheoryData { 4, 8 }; + public static readonly TheoryData PixelateValues = new() { 4, 8 }; [Theory] [WithFile(TestImages.Png.Ducky, nameof(PixelateValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 7da96d13d..4663aa868 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -14,7 +14,7 @@ public class BrightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData BrightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index 0727a5b97..1f2afb97f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -14,7 +14,7 @@ public class ColorBlindnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.03F); public static readonly TheoryData ColorBlindnessFilters - = new TheoryData + = new() { ColorBlindnessMode.Achromatomaly, ColorBlindnessMode.Achromatopsia, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index 5e2a7f55d..6ff10bbd8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class ContrastTest { public static readonly TheoryData ContrastValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index 50a262152..15ef7f7c3 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class GrayscaleTest { public static readonly TheoryData GrayscaleModeTypes - = new TheoryData + = new() { GrayscaleMode.Bt601, GrayscaleMode.Bt709 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index 65ac4245d..1838cc33d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class HueTest { public static readonly TheoryData HueValues - = new TheoryData + = new() { 180, -180 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs index 39e69aa4a..49e2c8546 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs @@ -14,7 +14,7 @@ public class LightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData LightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index 10ddf3a47..8a1bbfe3f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class OpacityTest { public static readonly TheoryData AlphaValues - = new TheoryData + = new() { 20 / 100F, 80 / 100F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 8632d4625..642c79819 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class SaturateTest { public static readonly TheoryData SaturationValues - = new TheoryData + = new() { .5F, 1.5F, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs index c6880d3a8..c9f3daf0f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs @@ -13,8 +13,8 @@ public class OctreeQuantizerTests [Fact] public void OctreeQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new OctreeQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + OctreeQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); @@ -38,7 +38,7 @@ public class OctreeQuantizerTests [Fact] public void OctreeQuantizerCanCreateFrameQuantizer() { - var quantizer = new OctreeQuantizer(); + OctreeQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index 91cf90bc4..d58a5280d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -15,8 +15,8 @@ public class PaletteQuantizerTests [Fact] public void PaletteQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new PaletteQuantizer(Palette, expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + PaletteQuantizer quantizer = new(Palette, expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); @@ -40,7 +40,7 @@ public class PaletteQuantizerTests [Fact] public void PaletteQuantizerCanCreateFrameQuantizer() { - var quantizer = new PaletteQuantizer(Palette); + PaletteQuantizer quantizer = new(Palette); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs index ab4304d89..2d270b2a4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs @@ -13,8 +13,8 @@ public class WuQuantizerTests [Fact] public void WuQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new WuQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + WuQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); @@ -38,7 +38,7 @@ public class WuQuantizerTests [Fact] public void WuQuantizerCanCreateFrameQuantizer() { - var quantizer = new WuQuantizer(); + WuQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 6a61538ea..984e3bc75 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -57,7 +57,7 @@ public class AutoOrientTests public void AutoOrient_WorksWithCorruptExifData(TestImageProvider provider, ExifDataType dataType, byte[] orientation) where TPixel : unmanaged, IPixel { - var profile = new ExifProfile(); + ExifProfile profile = new(); profile.SetValue(ExifTag.JPEGTables, orientation); byte[] bytes = profile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index ca4b00d8a..3e986f0cb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [GroupOutput("Transforms")] public class EntropyCropTest { - public static readonly TheoryData EntropyCropValues = new TheoryData { .25F, .75F }; + public static readonly TheoryData EntropyCropValues = new() { .25F, .75F }; public static readonly string[] InputImages = { @@ -35,8 +35,8 @@ public class EntropyCropTest { // arrange using Image image = provider.GetImage(); - var expectedHeight = image.Height; - var expectedWidth = image.Width; + int expectedHeight = image.Height; + int expectedWidth = image.Width; // act image.Mutate(img => img.EntropyCrop()); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs index 84d834cc5..e3e7118c0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs @@ -34,8 +34,8 @@ public class ResizeHelperTests [Fact] public void CalculateMinRectangleWhenSourceIsSmallerThanTarget() { - var sourceSize = new Size(200, 100); - var target = new Size(400, 200); + Size sourceSize = new(200, 100); + Size target = new(400, 200); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, @@ -52,11 +52,11 @@ public class ResizeHelperTests [Fact] public void MaxSizeAndRectangleAreCorrect() { - var sourceSize = new Size(5072, 6761); - var target = new Size(0, 450); + Size sourceSize = new(5072, 6761); + Size target = new(0, 450); - var expectedSize = new Size(338, 450); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(338, 450); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, @@ -73,11 +73,11 @@ public class ResizeHelperTests [Fact] public void CropSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(25, 50); + Size sourceSize = new(100, 100); + Size target = new(25, 50); - var expectedSize = new Size(25, 50); - var expectedRectangle = new Rectangle(-12, 0, 50, 50); + Size expectedSize = new(25, 50); + Rectangle expectedRectangle = new(-12, 0, 50, 50); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, @@ -94,11 +94,11 @@ public class ResizeHelperTests [Fact] public void BoxPadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(10, 5, 100, 100); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(10, 5, 100, 100); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, @@ -115,11 +115,11 @@ public class ResizeHelperTests [Fact] public void PadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(5, 0, 110, 110); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(5, 0, 110, 110); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, @@ -136,11 +136,11 @@ public class ResizeHelperTests [Fact] public void StretchSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(57, 32); + Size sourceSize = new(100, 100); + Size target = new(57, 32); - var expectedSize = new Size(57, 32); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(57, 32); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 290a3b37a..1a4610bf6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -39,7 +39,7 @@ public partial class ResizeKernelMapTests double radius = tolerantMath.Ceiling(scale * sampler.Radius); - var result = new List(); + List result = new(); for (int i = 0; i < destinationSize; i++) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index c6da46ee2..d6990782b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -22,8 +22,8 @@ public partial class ResizeKernelMapTests /// resamplerName, srcSize, destSize /// public static readonly TheoryData KernelMapData - = new TheoryData - { + = new() + { { KnownResamplers.Bicubic, 15, 10 }, { KnownResamplers.Bicubic, 10, 15 }, { KnownResamplers.Bicubic, 20, 20 }, @@ -88,7 +88,7 @@ public partial class ResizeKernelMapTests public void PrintNonNormalizedKernelMap(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); + ReferenceKernelMap kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); } @@ -116,15 +116,15 @@ public partial class ResizeKernelMapTests private void VerifyKernelMapContentIsCorrect(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); - var kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); + ReferenceKernelMap referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); + ResizeKernelMap kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); #if DEBUG this.Output.WriteLine(kernelMap.Info); this.Output.WriteLine($"Expected KernelMap:\n{PrintKernelMap(referenceMap)}\n"); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); #endif - var comparer = new ApproximateFloatComparer(1e-6f); + ApproximateFloatComparer comparer = new(1e-6f); for (int i = 0; i < kernelMap.DestinationLength; i++) { @@ -163,7 +163,7 @@ public partial class ResizeKernelMapTests Func getDestinationSize, Func getKernel) { - var bld = new StringBuilder(); + StringBuilder bld = new(); if (kernelMap is ResizeKernelMap actualMap) { @@ -193,7 +193,7 @@ public partial class ResizeKernelMapTests private static TheoryData GenerateImageResizeData() { - var result = new TheoryData(); + TheoryData result = new(); string[] resamplerNames = TestUtils.GetAllResamplerNames(false); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index f9cf10d22..1e0e66965 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -456,8 +456,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() - { Size = new Size(image.Width, image.Height / 2) }; + ResizeOptions options = new() { Size = new Size(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -471,8 +470,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() - { Size = new Size(image.Width / 2, image.Height) }; + ResizeOptions options = new() { Size = new Size(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -504,8 +502,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() - { Size = new Size(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() { Size = new Size(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index 55d26974a..cc3ea0322 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -12,8 +12,8 @@ public class RotateFlipTests public static readonly string[] FlipFiles = { TestImages.Bmp.F }; public static readonly TheoryData RotateFlipValues - = new TheoryData - { + = new() + { { RotateMode.None, FlipMode.Vertical }, { RotateMode.None, FlipMode.Horizontal }, { RotateMode.Rotate90, FlipMode.None }, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs index 1e217ae24..30dec4685 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs @@ -33,8 +33,8 @@ public class SkewTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData SkewValues = new TheoryData - { + public static readonly TheoryData SkewValues = new() + { { 20, 10 }, { -20, -10 } }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index 04f11644b..33e22d364 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -21,8 +21,7 @@ public class SwizzleTests public Size DestinationSize { get; } - public Point Transform(Point point) - => new(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs index 4b1ca92dd..232571d4d 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs @@ -8,8 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; public class AffineTransformBuilderTests : TransformBuilderTestBase { - protected override AffineTransformBuilder CreateBuilder() - => new AffineTransformBuilder(); + protected override AffineTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(AffineTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 30c89ec33..c56df3152 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -25,7 +25,7 @@ public class CropTest : BaseImageOperationsExtensionTest [InlineData(12, 123, 6, 2)] public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, int height) { - var cropRectangle = new Rectangle(x, y, width, height); + Rectangle cropRectangle = new(x, y, width, height); this.operations.Crop(cropRectangle); CropProcessor processor = this.Verify(); @@ -35,7 +35,7 @@ public class CropTest : BaseImageOperationsExtensionTest [Fact] public void CropRectangleWithInvalidBoundsThrowsException() { - var cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); + Rectangle cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); Assert.Throws(() => this.operations.Crop(cropRectangle)); } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs index 7d0c0dc58..a0380033f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs @@ -9,8 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public class ProjectiveTransformBuilderTests : TransformBuilderTestBase { - protected override ProjectiveTransformBuilder CreateBuilder() - => new ProjectiveTransformBuilder(); + protected override ProjectiveTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(ProjectiveTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index f6c93ffd0..1d445b980 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -64,7 +64,7 @@ public class ResizeTests : BaseImageOperationsExtensionTest bool compand = true; ResizeMode mode = ResizeMode.Stretch; - var resizeOptions = new ResizeOptions + ResizeOptions resizeOptions = new() { Size = new Size(width, height), Sampler = sampler, @@ -93,7 +93,7 @@ public class ResizeTests : BaseImageOperationsExtensionTest { static void RunTest() { - using var image = new Image(50, 50); + using Image image = new(50, 50); image.Mutate(img => img.Resize(25, 25)); Assert.Equal(25, image.Width); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs index 432bb5cac..8475ce5ab 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs @@ -18,8 +18,7 @@ public class SwizzleTests : BaseImageOperationsExtensionTest public Size DestinationSize { get; } - public Point Transform(Point point) - => new Point(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Fact] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index f046c2503..5caf071ac 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -10,11 +10,11 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public abstract class TransformBuilderTestBase { - private static readonly ApproximateFloatComparer Comparer = new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer Comparer = new(1e-6f); public static readonly TheoryData ScaleTranslate_Data = - new TheoryData - { + new() + { // scale, translate, source, expectedDest { Vector2.One, Vector2.Zero, Vector2.Zero, Vector2.Zero }, { Vector2.One, Vector2.Zero, new Vector2(10, 20), new Vector2(10, 20) }, @@ -29,7 +29,7 @@ public abstract class TransformBuilderTestBase #pragma warning restore SA1300 // Element should begin with upper-case letter { // These operations should be size-agnostic: - var size = new Size(123, 321); + Size size = new(123, 321); TBuilder builder = this.CreateBuilder(); this.AppendScale(builder, new SizeF(scale)); @@ -40,8 +40,8 @@ public abstract class TransformBuilderTestBase } public static readonly TheoryData TranslateScale_Data = - new TheoryData - { + new() + { // translate, scale, source, expectedDest { Vector2.Zero, Vector2.One, Vector2.Zero, Vector2.Zero }, { Vector2.Zero, Vector2.One, new Vector2(10, 20), new Vector2(10, 20) }, @@ -55,7 +55,7 @@ public abstract class TransformBuilderTestBase #pragma warning restore SA1300 // Element should begin with upper-case letter { // Translate ans scale are size-agnostic: - var size = new Size(456, 432); + Size size = new(456, 432); TBuilder builder = this.CreateBuilder(); this.AppendTranslation(builder, translate); @@ -70,7 +70,7 @@ public abstract class TransformBuilderTestBase [InlineData(-20, 10)] public void LocationOffsetIsPrepended(int locationX, int locationY) { - var rectangle = new Rectangle(locationX, locationY, 10, 10); + Rectangle rectangle = new(locationX, locationY, 10, 10); TBuilder builder = this.CreateBuilder(); this.AppendScale(builder, new SizeF(2, 2)); @@ -92,7 +92,7 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendRotationDegrees(builder, degrees); @@ -100,8 +100,8 @@ public abstract class TransformBuilderTestBase // TODO: We should also test CreateRotationMatrixDegrees() (and all TransformUtils stuff!) for correctness Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); @@ -120,16 +120,16 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendRotationDegrees(builder, degrees, centerPoint); - var matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); @@ -147,15 +147,15 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, degreesX, degreesY); Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -174,16 +174,16 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendSkewDegrees(builder, degreesX, degreesY, centerPoint); - var matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); @@ -192,7 +192,7 @@ public abstract class TransformBuilderTestBase [Fact] public void AppendPrependOpposite() { - var rectangle = new Rectangle(-1, -1, 3, 3); + Rectangle rectangle = new(-1, -1, 3, 3); TBuilder b1 = this.CreateBuilder(); TBuilder b2 = this.CreateBuilder(); @@ -226,7 +226,7 @@ public abstract class TransformBuilderTestBase [InlineData(-1, 0)] public void ThrowsForInvalidSizes(int width, int height) { - var size = new Size(width, height); + Size size = new(width, height); Assert.ThrowsAny( () => diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index a1d7e358b..209dd361e 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture [InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)] public void LoadResizeSave(string imagePath) { - var configuration = Configuration.CreateDefaultInstance(); + Configuration configuration = Configuration.CreateDefaultInstance(); configuration.MaxDegreeOfParallelism = 1; DecoderOptions options = new() @@ -28,12 +28,12 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture byte[] imageBytes = TestFile.Create(imagePath).Bytes; - using var ms = new MemoryStream(); + using MemoryStream ms = new(); this.Measure( 30, () => { - using (var image = Image.Load(options, imageBytes)) + using (Image image = Image.Load(options, imageBytes)) { image.Mutate(x => x.Resize(image.Size / 4)); image.SaveAsJpeg(ms); diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs index f20ca8ce1..bab11b0f9 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs @@ -28,7 +28,7 @@ public class ResizeProfilingBenchmarks : MeasureFixture this.ExecutionCount, () => { - using (var image = new Image(this.configuration, width, height)) + using (Image image = new(this.configuration, width, height)) { image.Mutate(x => x.Resize(width / 5, height / 5)); } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index b59542482..75c096b1f 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -106,7 +106,7 @@ public class QuantizedImageTests { using Image image = provider.GetImage(); OctreeQuantizer octreeQuantizer = new(); - IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new QuantizerOptions() { MaxColors = 128 }); + IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new QuantizerOptions { MaxColors = 128 }); ImageFrame frame = image.Frames[0]; quantizer.BuildPaletteAndQuantizeFrame(frame, frame.Bounds); } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index e4adba078..f79666e3e 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -48,13 +48,13 @@ public class IccConversionDataMultiProcessElement private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) { - var curve = new IccOneDimensionalCurve(new float[0], new[] { segment }); + IccOneDimensionalCurve curve = new(new float[0], new[] { segment }); return new IccCurveSetProcessElement(new[] { curve }); } private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) { - var curve = new IccOneDimensionalCurve(breakPoints, segments); + IccOneDimensionalCurve curve = new(breakPoints, segments); return new IccCurveSetProcessElement(new[] { curve }); } diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index a53e50806..1177152c0 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -117,7 +117,7 @@ public sealed class TestFile /// The . /// public Image CreateRgba32Image(IImageDecoder decoder) - => this.CreateRgba32Image(decoder, new()); + => this.CreateRgba32Image(decoder, new DecoderOptions()); /// /// Creates a new image. diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index 01b1faa45..d575489be 100644 --- a/tests/ImageSharp.Tests/TestFontUtilities.cs +++ b/tests/ImageSharp.Tests/TestFontUtilities.cs @@ -37,7 +37,7 @@ public static class TestFontUtilities /// private static string GetFontsDirectory() { - List directories = new List + List directories = new() { "TestFonts/", // Here for code coverage tests. "tests/ImageSharp.Tests/TestFonts/", // from travis/build script @@ -59,7 +59,7 @@ public static class TestFontUtilities return directory; } - throw new System.Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); + throw new Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); } /// diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index d30ce7846..92b74cde1 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -38,7 +38,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public MemoryStream CreateStream(byte[] marker = null) { - var ms = new MemoryStream(); + MemoryStream ms = new(); byte[] data = this.header; ms.Write(data, 0, data.Length); if (marker != null) @@ -54,7 +54,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat { byte[] buffer = new byte[size]; this.header.CopyTo(buffer, 0); - var semaphoreStream = new SemaphoreReadMemoryStream(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); + SemaphoreReadMemoryStream semaphoreStream = new(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); return seeakable ? semaphoreStream : new AsyncStreamWrapper(semaphoreStream, () => false); } @@ -205,7 +205,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 406283b97..021f02476 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -581,6 +581,7 @@ public static class TestImages public const string Issue2866 = "Gif/issues/issue_2866.gif"; public const string Issue2859_A = "Gif/issues/issue_2859_A.gif"; public const string Issue2859_B = "Gif/issues/issue_2859_B.gif"; + public const string Issue2953 = "Gif/issues/issue_2953.gif"; } public static readonly string[] Animated = diff --git a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs index 8ff2abd90..90a98d1c8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs @@ -13,7 +13,7 @@ public static class ArrayHelper /// The concatenated array public static T[] Concat(params T[][] arrays) { - var result = new T[arrays.Sum(t => t.Length)]; + T[] result = new T[arrays.Sum(t => t.Length)]; int offset = 0; for (int i = 0; i < arrays.Length; i++) { @@ -33,7 +33,7 @@ public static class ArrayHelper /// The created array filled with the given value public static T[] Fill(T value, int length) { - var result = new T[length]; + T[] result = new T[length]; for (int i = 0; i < length; i++) { result[i] = value; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs index 57949e7b1..87f6f0479 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs @@ -58,7 +58,7 @@ public class WithFileCollectionAttribute : ImageDataAttributeBase Func accessor = this.GetPropertyAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); accessor = accessor ?? this.GetFieldAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); - var files = (IEnumerable)accessor(); + IEnumerable files = (IEnumerable)accessor(); return files.Select(f => new object[] { f }); } diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs index 963c3c783..2fb75444e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs @@ -11,7 +11,7 @@ public static class ByteArrayUtility { if (isLittleEndian != BitConverter.IsLittleEndian) { - var reversedBytes = new byte[bytes.Length]; + byte[] reversedBytes = new byte[bytes.Length]; Array.Copy(bytes, reversedBytes, bytes.Length); Array.Reverse(reversedBytes); return reversedBytes; diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs index 45e1425c7..548354450 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; public class ByteBuffer { - private readonly List bytes = new List(); + private readonly List bytes = new(); private readonly bool isLittleEndian; public ByteBuffer(bool isLittleEndian) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 92fc06eff..1d35a6200 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; public class ExactImageComparer : ImageComparer { - public static ExactImageComparer Instance { get; } = new ExactImageComparer(); + public static ExactImageComparer Instance { get; } = new(); public override ImageSimilarityReport CompareImagesOrFrames( int index, @@ -23,10 +23,10 @@ public class ExactImageComparer : ImageComparer int width = actual.Width; // TODO: Comparing through Rgba64 may not be robust enough because of the existence of super high precision pixel types. - var aBuffer = new Rgba64[width]; - var bBuffer = new Rgba64[width]; + Rgba64[] aBuffer = new Rgba64[width]; + Rgba64[] bBuffer = new Rgba64[width]; - var differences = new List(); + List differences = new(); Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -46,7 +46,7 @@ public class ExactImageComparer : ImageComparer if (aPixel != bPixel) { - var diff = new PixelDifference(new Point(x, y), aPixel, bPixel); + PixelDifference diff = new(new Point(x, y), aPixel, bPixel); differences.Add(diff); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 7153674e6..c8e11e69c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -147,7 +147,7 @@ public static class ImageComparerExtensions IEnumerable> reports = comparer.CompareImages(expected, actual); if (reports.Any()) { - var cleanedReports = new List>(reports.Count()); + List> cleanedReports = new(reports.Count()); foreach (ImageSimilarityReport r in reports) { IEnumerable outsideChanges = r.Differences.Where( diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index c50ae5e21..1594258e0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs @@ -61,7 +61,7 @@ public class ImageSimilarityReport private string PrintDifference() { - var sb = new StringBuilder(); + StringBuilder sb = new(); if (this.TotalNormalizedDifference.HasValue) { sb.AppendLine(); @@ -103,7 +103,7 @@ public class ImageSimilarityReport : ImageSimilarityReport } public static ImageSimilarityReport Empty => - new ImageSimilarityReport(0, null, null, Enumerable.Empty(), 0f); + new(0, null, null, Enumerable.Empty(), 0f); public new ImageFrame ExpectedImage => (ImageFrame)base.ExpectedImage; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index d057267da..c9f13ca2f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -65,12 +65,12 @@ public class TolerantImageComparer : ImageComparer int width = actual.Width; // TODO: Comparing through Rgba64 may not robust enough because of the existence of super high precision pixel types. - var aBuffer = new Rgba64[width]; - var bBuffer = new Rgba64[width]; + Rgba64[] aBuffer = new Rgba64[width]; + Rgba64[] bBuffer = new Rgba64[width]; float totalDifference = 0F; - var differences = new List(); + List differences = new(); Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -89,7 +89,7 @@ public class TolerantImageComparer : ImageComparer if (d > this.PerPixelManhattanThreshold) { - var diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new(new Point(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); totalDifference += d; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index 5a31707bf..c8c3e09c3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -33,7 +33,7 @@ public abstract partial class TestImageProvider : IXunitSerializable protected int Width { get; private set; } - public override Image GetImage() => new Image(this.Configuration, this.Width, this.Height); + public override Image GetImage() => new(this.Configuration, this.Width, this.Height); public override void Deserialize(IXunitSerializationInfo info) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 3652d77a1..3f6e78a34 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -45,7 +45,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { Type type = options.GetType(); - var data = new Dictionary(); + Dictionary data = new(); while (type != null && type != typeof(object)) { @@ -196,7 +196,7 @@ public abstract partial class TestImageProvider : IXunitSerializable return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options, null); + Key key = new(this.PixelType, this.FilePath, decoder, options, null); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -233,7 +233,7 @@ public abstract partial class TestImageProvider : IXunitSerializable return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); + Key key = new(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -270,7 +270,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { options.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -280,7 +280,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { options.GeneralOptions.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -288,7 +288,7 @@ public abstract partial class TestImageProvider : IXunitSerializable public static string GetFilePathOrNull(ITestImageProvider provider) { - var fileProvider = provider as FileProvider; + FileProvider fileProvider = provider as FileProvider; return fileProvider?.FilePath; } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs index 390195274..6da5b75f0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs @@ -54,7 +54,7 @@ public abstract partial class TestImageProvider : IXunitSerializable private Func> GetFactory() { - var declaringType = Type.GetType(this.declaringTypeName); + Type declaringType = Type.GetType(this.declaringTypeName); MethodInfo m = declaringType.GetMethod(this.methodName); Type pixelType = typeof(TPixel); Type imgType = typeof(Image<>).MakeGenericType(pixelType); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 8f22fb2b2..ab624126b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -88,10 +88,10 @@ public abstract partial class TestImageProvider : ITestImageProvider, IX public abstract Image GetImage(); public Image GetImage(IImageDecoder decoder) - => this.GetImage(decoder, new()); + => this.GetImage(decoder, new DecoderOptions()); public Task> GetImageAsync(IImageDecoder decoder) - => this.GetImageAsync(decoder, new()); + => this.GetImageAsync(decoder, new DecoderOptions()); public virtual Image GetImage(IImageDecoder decoder, DecoderOptions options) => throw new NotSupportedException($"Decoder specific GetImage() is not supported with {this.GetType().Name}!"); diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index de42ba0cc..81f16cf6b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs +++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs @@ -30,7 +30,7 @@ public class MeasureFixture this.Output?.WriteLine($"{operationName} X {times} ..."); } - var sw = Stopwatch.StartNew(); + Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < times; i++) { @@ -60,7 +60,7 @@ public class MeasureGuard : IDisposable { private readonly string operation; - private readonly Stopwatch stopwatch = new Stopwatch(); + private readonly Stopwatch stopwatch = new(); public MeasureGuard(ITestOutputHelper output, string operation) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs index bdc78f3f5..862d4b64d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs @@ -32,15 +32,15 @@ public class MagickReferenceDecoder : ImageDecoder this.validate = validate; } - public static MagickReferenceDecoder Png { get; } = new MagickReferenceDecoder(PngFormat.Instance); + public static MagickReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static MagickReferenceDecoder Bmp { get; } = new MagickReferenceDecoder(BmpFormat.Instance); + public static MagickReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); - public static MagickReferenceDecoder Jpeg { get; } = new MagickReferenceDecoder(JpegFormat.Instance); + public static MagickReferenceDecoder Jpeg { get; } = new(JpegFormat.Instance); - public static MagickReferenceDecoder Tiff { get; } = new MagickReferenceDecoder(TiffFormat.Instance); + public static MagickReferenceDecoder Tiff { get; } = new(TiffFormat.Instance); - public static MagickReferenceDecoder WebP { get; } = new MagickReferenceDecoder(WebpFormat.Instance); + public static MagickReferenceDecoder WebP { get; } = new(WebpFormat.Instance); protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { @@ -103,7 +103,7 @@ public class MagickReferenceDecoder : ImageDecoder } } - return ReferenceCodecUtilities.EnsureDecodedMetadata(new(configuration, metadata, framesList), this.imageFormat); + return ReferenceCodecUtilities.EnsureDecodedMetadata(new Image(configuration, metadata, framesList), this.imageFormat); } protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -113,7 +113,7 @@ public class MagickReferenceDecoder : ImageDecoder { using Image image = this.Decode(options, stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 04f59979f..84be9e3a9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -27,7 +27,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format32bppArgb) { @@ -37,7 +37,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -86,7 +86,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format24bppRgb) { @@ -96,7 +96,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -138,8 +138,8 @@ public static class SystemDrawingBridge int w = image.Width; int h = image.Height; - var resultBitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb); - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + Bitmap resultBitmap = new(w, h, PixelFormat.Format32bppArgb); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); BitmapData data = resultBitmap.LockBits(fullRect, ImageLockMode.ReadWrite, resultBitmap.PixelFormat); try { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs index 14a655823..fce2da05f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs @@ -18,15 +18,15 @@ public class SystemDrawingReferenceDecoder : ImageDecoder public SystemDrawingReferenceDecoder(IImageFormat imageFormat) => this.imageFormat = imageFormat; - public static SystemDrawingReferenceDecoder Png { get; } = new SystemDrawingReferenceDecoder(PngFormat.Instance); + public static SystemDrawingReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static SystemDrawingReferenceDecoder Bmp { get; } = new SystemDrawingReferenceDecoder(BmpFormat.Instance); + public static SystemDrawingReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { using Image image = this.Decode(options, stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs index 0789ab263..f9769b891 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs @@ -15,9 +15,9 @@ public class SystemDrawingReferenceEncoder : IImageEncoder public SystemDrawingReferenceEncoder(ImageFormat imageFormat) => this.imageFormat = imageFormat; - public static SystemDrawingReferenceEncoder Png { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Png); + public static SystemDrawingReferenceEncoder Png { get; } = new(ImageFormat.Png); - public static SystemDrawingReferenceEncoder Bmp { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Bmp); + public static SystemDrawingReferenceEncoder Bmp { get; } = new(ImageFormat.Bmp); public bool SkipMetadata { get; init; } diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index edae08ce1..d8b0ff785 100644 --- a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs +++ b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs @@ -18,7 +18,7 @@ public class SixLaborsXunitTestFramework : XunitTestFramework public SixLaborsXunitTestFramework(IMessageSink messageSink) : base(messageSink) { - var message = new DiagnosticMessage(HostEnvironmentInfo.GetInformation()); + DiagnosticMessage message = new(HostEnvironmentInfo.GetInformation()); messageSink.OnMessage(message); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs index 31de3909e..53f0f0648 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs @@ -20,7 +20,7 @@ internal static class TestDataGenerator /// The . public static float[] GenerateRandomFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; RandomFill(rnd, values, minVal, maxVal); @@ -45,7 +45,7 @@ internal static class TestDataGenerator /// The . public static Vector4[] GenerateRandomVectorArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new Vector4[length]; + Vector4[] values = new Vector4[length]; for (int i = 0; i < length; i++) { @@ -69,7 +69,7 @@ internal static class TestDataGenerator /// The . public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; for (int i = 0; i < length; i++) { @@ -87,14 +87,14 @@ internal static class TestDataGenerator /// The . public static byte[] GenerateRandomByteArray(this Random rnd, int length) { - var values = new byte[length]; + byte[] values = new byte[length]; rnd.NextBytes(values); return values; } public static short[] GenerateRandomInt16Array(this Random rnd, int length, short minVal, short maxVal) { - var values = new short[length]; + short[] values = new short[length]; for (int i = 0; i < values.Length; i++) { values[i] = (short)rnd.Next(minVal, maxVal); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 881883035..8eed0a1c1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -19,9 +19,9 @@ public static partial class TestEnvironment private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools"; - private static readonly Lazy SolutionDirectoryFullPathLazy = new Lazy(GetSolutionDirectoryFullPathImpl); + private static readonly Lazy SolutionDirectoryFullPathLazy = new(GetSolutionDirectoryFullPathImpl); - private static readonly Lazy NetCoreVersionLazy = new Lazy(GetNetCoreVersion); + private static readonly Lazy NetCoreVersionLazy = new(GetNetCoreVersion); static TestEnvironment() => PrepareRemoteExecutor(); @@ -52,8 +52,7 @@ public static partial class TestEnvironment internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; - private static readonly FileInfo TestAssemblyFile = - new FileInfo(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); + private static readonly FileInfo TestAssemblyFile = new(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); private static string GetSolutionDirectoryFullPathImpl() { @@ -215,7 +214,7 @@ public static partial class TestEnvironment string args = $"{remoteExecutorTmpPath} /32Bit+ /Force"; - var si = new ProcessStartInfo() + ProcessStartInfo si = new() { FileName = corFlagsFile.FullName, Arguments = args, @@ -224,7 +223,7 @@ public static partial class TestEnvironment RedirectStandardError = true }; - using var proc = Process.Start(si); + using Process proc = Process.Start(si); proc.WaitForExit(); string standardOutput = proc.StandardOutput.ReadToEnd(); string standardError = proc.StandardError.ReadToEnd(); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs index fe94cffc4..a0ff4a466 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs @@ -46,7 +46,7 @@ internal class TestMemoryAllocator : MemoryAllocator private T[] AllocateArray(int length, AllocationOptions options) where T : struct { - var array = new T[length + 42]; + T[] array = new T[length + 42]; this.allocationLog?.Add(AllocationRequest.Create(options, length, array)); if (options == AllocationOptions.None) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs index 50e086d57..7f25fd5aa 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs @@ -34,7 +34,7 @@ public class TestMemoryManager : MemoryManager public static TestMemoryManager CreateAsCopyOf(Span copyThisBuffer) { - var pixelArray = new T[copyThisBuffer.Length]; + T[] pixelArray = new T[copyThisBuffer.Length]; copyThisBuffer.CopyTo(pixelArray); return new TestMemoryManager(pixelArray); } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index 52447b6c2..1b5b43f03 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs @@ -51,7 +51,7 @@ public class BasicSerializerTests [Fact] public void SerializeDeserialize_ShouldPreserveValues() { - var obj = new DerivedObj() { 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/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 4c1a740e2..349dd258e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -31,7 +31,7 @@ public class ImageComparerTests { using (Image clone = image.Clone()) { - var comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); + ImageComparer comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); comparer.VerifySimilarity(image, clone); } } @@ -48,7 +48,7 @@ public class ImageComparerTests { ImagingTestCaseUtility.ModifyPixel(clone, 0, 0, 1); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); comparer.VerifySimilarity(image, clone); } } @@ -66,7 +66,7 @@ public class ImageComparerTests byte perChannelChange = 20; ImagingTestCaseUtility.ModifyPixel(clone, 3, 1, perChannelChange); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); ImageDifferenceIsOverThresholdException ex = Assert.ThrowsAny( () => comparer.VerifySimilarity(image, clone)); @@ -90,7 +90,7 @@ public class ImageComparerTests ImagingTestCaseUtility.ModifyPixel(clone, 1, 0, 1); ImagingTestCaseUtility.ModifyPixel(clone, 2, 0, 1); - var comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); + ImageComparer comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); comparer.VerifySimilarity(image, clone); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 6e1eba28e..4329a6be3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -76,7 +76,7 @@ public class ReferenceDecoderBenchmarks private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) { - var measure = new MeasureFixture(this.Output); + MeasureFixture measure = new(this.Output); measure.Measure( times, () => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs index e080bda9b..f0a5f4eb4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs @@ -5,8 +5,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; public class SemaphoreReadMemoryStreamTests { - private readonly SemaphoreSlim continueSemaphore = new SemaphoreSlim(0); - private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim continueSemaphore = new(0); + private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new(0); private readonly byte[] buffer = new byte[128]; [Fact] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 460858379..555041890 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Drawing; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.PixelFormats; @@ -35,7 +36,7 @@ public class SystemDrawingReferenceCodecTests { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image image = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); image.DebugSave(dummyProvider); } @@ -49,7 +50,7 @@ public class SystemDrawingReferenceCodecTests sourceImage.Mutate(c => c.MakeOpaque()); } - var encoder = new PngEncoder { ColorType = pngColorType }; + PngEncoder encoder = new() { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } @@ -65,7 +66,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.RgbWithAlpha); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image original = provider.GetImage(); using Image resaved = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; @@ -80,7 +81,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.Rgb); using Image original = provider.GetImage(); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image resaved = SystemDrawingBridge.From24bppRgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; comparer.VerifySimilarity(original, resaved); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index f33811206..72ed27e8e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -368,7 +368,7 @@ public class TestImageProviderTests { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; @@ -415,7 +415,7 @@ public class TestImageProviderTests { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/Images/Input/Gif/issues/issue_2953.gif b/tests/Images/Input/Gif/issues/issue_2953.gif new file mode 100644 index 000000000..98c06e5c5 --- /dev/null +++ b/tests/Images/Input/Gif/issues/issue_2953.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fa4a002b264a41677cc10f115f3572111852993a53ee8cea5f4ec0bf8dec195 +size 40