diff --git a/.editorconfig b/.editorconfig index af1e5b44c1..4aaab02c1a 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 +# Collection expression preferences +# dotnet_style_prefer_collection_expression = true:error + # "Null" checking preferences csharp_style_throw_expression = true:warning csharp_style_conditional_delegate_call = true:warning @@ -175,6 +178,11 @@ csharp_prefer_static_local_function = true:warning # Primary constructor preferences csharp_style_prefer_primary_constructors = false:none +# ReSharper inspection severities +resharper_arrange_object_creation_when_type_evident_highlighting = error +resharper_arrange_object_creation_when_type_not_evident_highlighting = error +# resharper_use_collection_expression_highlighting = error + ########################################## # Unnecessary Code Rules # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules diff --git a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs index fd9692f9ae..f295ddb1b0 100644 --- a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs +++ b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs @@ -79,7 +79,7 @@ public readonly struct ParallelExecutionSettings { Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier)); - return new ParallelExecutionSettings( + return new( this.MaxDegreeOfParallelism, this.MinimumPixelsProcessedPerTask * multiplier, this.MemoryAllocator); @@ -92,6 +92,6 @@ public readonly struct ParallelExecutionSettings /// The . public static ParallelExecutionSettings FromConfiguration(Configuration configuration) { - return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); + return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); } } diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs index a959faa3b6..b76f2948f1 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 RowInterval(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 RowInterval(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 1284a3a898..b878f9ec0a 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 feb4a8659d..b805d63f97 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/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs index ca72dd745a..c1f53c1622 100644 --- a/src/ImageSharp/ColorProfiles/CieLab.cs +++ b/src/ImageSharp/ColorProfiles/CieLab.cs @@ -88,7 +88,7 @@ public readonly struct CieLab : IProfileConnectingSpace v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -97,7 +97,7 @@ public readonly struct CieLab : IProfileConnectingSpace Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new CieLab(v3); + return new(v3); } /// @@ -145,7 +145,7 @@ public readonly struct CieLab : IProfileConnectingSpace float a = 500F * (fx - fy); float b = 200F * (fy - fz); - return new CieLab(l, a, b); + return new(l, a, b); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLch.cs b/src/ImageSharp/ColorProfiles/CieLch.cs index e62aa2ba23..53afc0053b 100644 --- a/src/ImageSharp/ColorProfiles/CieLch.cs +++ b/src/ImageSharp/ColorProfiles/CieLch.cs @@ -25,7 +25,7 @@ public readonly struct CieLch : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLch(float l, float c, float h) - : this(new Vector3(l, c, h)) + : this(new(l, c, h)) { } @@ -100,7 +100,7 @@ public readonly struct CieLch : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -109,7 +109,7 @@ public readonly struct CieLch : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new CieLch(v3, true); + return new(v3, true); } /// @@ -155,7 +155,7 @@ public readonly struct CieLch : IColorProfile hDegrees += 360; } - return new CieLch(l, c, hDegrees); + return new(l, c, hDegrees); } /// @@ -181,7 +181,7 @@ public readonly struct CieLch : IColorProfile float a = c * MathF.Cos(hRadians); float b = c * MathF.Sin(hRadians); - return new CieLab(l, a, b); + return new(l, a, b); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLchuv.cs b/src/ImageSharp/ColorProfiles/CieLchuv.cs index 5478752ddc..c08d6cc40c 100644 --- a/src/ImageSharp/ColorProfiles/CieLchuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLchuv.cs @@ -25,7 +25,7 @@ public readonly struct CieLchuv : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLchuv(float l, float c, float h) - : this(new Vector3(l, c, h)) + : this(new(l, c, h)) { } @@ -97,7 +97,7 @@ public readonly struct CieLchuv : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -106,7 +106,7 @@ public readonly struct CieLchuv : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new CieLchuv(v3, true); + return new(v3, true); } /// @@ -154,7 +154,7 @@ public readonly struct CieLchuv : IColorProfile hDegrees += 360; } - return new CieLchuv(l, c, hDegrees); + return new(l, c, hDegrees); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLuv.cs b/src/ImageSharp/ColorProfiles/CieLuv.cs index b17c433313..58ec9048c0 100644 --- a/src/ImageSharp/ColorProfiles/CieLuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLuv.cs @@ -134,7 +134,7 @@ public readonly struct CieLuv : IColorProfile v = 0; } - return new CieLuv((float)l, (float)u, (float)v); + return new((float)l, (float)u, (float)v); } /// @@ -188,7 +188,7 @@ public readonly struct CieLuv : IColorProfile z = 0; } - return new CieXyz((float)x, (float)y, (float)z); + return new((float)x, (float)y, (float)z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyy.cs b/src/ImageSharp/ColorProfiles/CieXyy.cs index 744b6195e9..ef45f352df 100644 --- a/src/ImageSharp/ColorProfiles/CieXyy.cs +++ b/src/ImageSharp/ColorProfiles/CieXyy.cs @@ -122,10 +122,10 @@ public readonly struct CieXyy : IColorProfile if (float.IsNaN(x) || float.IsNaN(y)) { - return new CieXyy(0, 0, source.Y); + return new(0, 0, source.Y); } - return new CieXyy(x, y, source.Y); + return new(x, y, source.Y); } /// @@ -144,14 +144,14 @@ public readonly struct CieXyy : IColorProfile { if (MathF.Abs(this.Y) < Constants.Epsilon) { - return new CieXyz(0, 0, this.Yl); + return new(0, 0, this.Yl); } float x = (this.X * this.Yl) / this.Y; float y = this.Yl; float z = ((1 - this.X - this.Y) * y) / this.Y; - return new CieXyz(x, y, z); + return new(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyz.cs b/src/ImageSharp/ColorProfiles/CieXyz.cs index 94fcfb21bb..b14f014695 100644 --- a/src/ImageSharp/ColorProfiles/CieXyz.cs +++ b/src/ImageSharp/ColorProfiles/CieXyz.cs @@ -88,7 +88,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -97,13 +97,13 @@ public readonly struct CieXyz : IProfileConnectingSpace Vector3 v3 = default; v3 += this.AsVector3Unsafe(); v3 *= 32768F / 65535; - return new Vector4(v3, 1F); + return new(v3, 1F); } internal static CieXyz FromVector4(Vector4 source) { Vector3 v3 = source.AsVector3(); - return new CieXyz(v3); + return new(v3); } /// @@ -111,7 +111,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = source.AsVector3(); v3 *= 65535 / 32768F; - return new CieXyz(v3); + return new(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs index ee81ff9f7e..3a2ffd6fb6 100644 --- a/src/ImageSharp/ColorProfiles/Cmyk.cs +++ b/src/ImageSharp/ColorProfiles/Cmyk.cs @@ -26,7 +26,7 @@ public readonly struct Cmyk : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Cmyk(float c, float m, float y, float k) - : this(new Vector4(c, m, y, k)) + : this(new(c, m, y, k)) { } @@ -138,12 +138,12 @@ public readonly struct Cmyk : IColorProfile if (k.X >= 1F - Constants.Epsilon) { - return new Cmyk(0, 0, 0, 1F); + return new(0, 0, 0, 1F); } cmy = (cmy - k) / (Vector3.One - k); - return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X); + return new(cmy.X, cmy.Y, cmy.Z, k.X); } /// diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs index c33f40001a..b00ff8200b 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs @@ -57,11 +57,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new ColorConversionOptions + ColorProfileConverter pcsConverter = new(new() { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); // Normalize the source, then convert to the PCS space. @@ -101,11 +101,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new ColorConversionOptions + ColorProfileConverter pcsConverter = new(new() { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); using IMemoryOwner pcsBuffer = converter.Options.MemoryAllocator.Allocate(source.Length); @@ -355,7 +355,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new CieXyz(AdjustPcsFromV2BlackPoint(vector)); + xyz = new(AdjustPcsFromV2BlackPoint(vector)); } // when converting from PCS to device with v2 perceptual intent @@ -371,7 +371,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new CieXyz(vector); + xyz = new(vector); } switch (targetParams.PcsType) diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs index 7a9365fb75..2735b55137 100644 --- a/src/ImageSharp/ColorProfiles/Hsl.cs +++ b/src/ImageSharp/ColorProfiles/Hsl.cs @@ -24,7 +24,7 @@ public readonly struct Hsl : IColorProfile /// The l value (lightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsl(float h, float s, float l) - : this(new Vector3(h, s, l)) + : this(new(h, s, l)) { } @@ -141,7 +141,7 @@ public readonly struct Hsl : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new Hsl(0F, s, l); + return new(0F, s, l); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -172,7 +172,7 @@ public readonly struct Hsl : IColorProfile s = chroma / (2F - max - min); } - return new Hsl(h, s, l); + return new(h, s, l); } /// @@ -213,7 +213,7 @@ public readonly struct Hsl : IColorProfile } } - return new Rgb(r, g, b); + return new(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/Hsv.cs b/src/ImageSharp/ColorProfiles/Hsv.cs index 1e013fe1fb..d29b3023e7 100644 --- a/src/ImageSharp/ColorProfiles/Hsv.cs +++ b/src/ImageSharp/ColorProfiles/Hsv.cs @@ -24,7 +24,7 @@ public readonly struct Hsv : IColorProfile /// The v value (brightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsv(float h, float s, float v) - : this(new Vector3(h, s, v)) + : this(new(h, s, v)) { } @@ -139,7 +139,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new Hsv(0, s, v); + return new(0, s, v); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -163,7 +163,7 @@ public readonly struct Hsv : IColorProfile s = chroma / v; - return new Hsv(h, s, v); + return new(h, s, v); } /// @@ -185,7 +185,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(s) < Constants.Epsilon) { - return new Rgb(v, v, v); + return new(v, v, v); } float h = (MathF.Abs(this.H - 360) < Constants.Epsilon) ? 0 : this.H / 60; @@ -236,7 +236,7 @@ public readonly struct Hsv : IColorProfile break; } - return new Rgb(r, g, b); + return new(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/HunterLab.cs b/src/ImageSharp/ColorProfiles/HunterLab.cs index e978c6de22..341360b12e 100644 --- a/src/ImageSharp/ColorProfiles/HunterLab.cs +++ b/src/ImageSharp/ColorProfiles/HunterLab.cs @@ -87,7 +87,7 @@ public readonly struct HunterLab : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -96,7 +96,7 @@ public readonly struct HunterLab : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new HunterLab(v3); + return new(v3); } /// @@ -151,7 +151,7 @@ public readonly struct HunterLab : IColorProfile b = 0; } - return new HunterLab(l, a, b); + return new(l, a, b); } /// @@ -184,7 +184,7 @@ public readonly struct HunterLab : IColorProfile float x = (((a / ka) * sqrtPow) + pow) * xn; float z = (((b / kb) * sqrtPow) - pow) * (-zn); - return new CieXyz(x, y, z); + return new(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs index 3604642c95..e5d95d5134 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs @@ -23,12 +23,12 @@ internal class ColorTrcCalculator : IVector4Calculator bool toPcs) { this.toPcs = toPcs; - this.curveCalculator = new TrcCalculator([redTrc, greenTrc, blueTrc], !toPcs); + this.curveCalculator = new([redTrc, greenTrc, blueTrc], !toPcs); Vector3 mr = redMatrixColumn.Data[0]; Vector3 mg = greenMatrixColumn.Data[0]; Vector3 mb = blueMatrixColumn.Data[0]; - this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); + this.matrix = new(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); if (!toPcs) { diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs index c39eaf958f..9c7a18ae8c 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs @@ -31,7 +31,7 @@ internal partial class CurveCalculator : ISingleCalculator } else { - this.lutCalculator = new LutCalculator(entry.CurveData, inverted); + this.lutCalculator = new(entry.CurveData, inverted); this.type = CalculationType.Lut; } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs index 8d823c1e95..f39f4da52a 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs @@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator private readonly TrcCalculator calculator; public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) - => this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); + => this.calculator = new(new IccTagDataEntry[] { grayTrc }, !toPcs); [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value); diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs index 172d806394..e0d1ad8d41 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs @@ -109,27 +109,27 @@ internal partial class LutABCalculator : IVector4Calculator if (hasACurve) { - this.curveACalculator = new TrcCalculator(curveA, false); + this.curveACalculator = new(curveA, false); } if (hasBCurve) { - this.curveBCalculator = new TrcCalculator(curveB, false); + this.curveBCalculator = new(curveB, false); } if (hasMCurve) { - this.curveMCalculator = new TrcCalculator(curveM, false); + this.curveMCalculator = new(curveM, false); } if (hasMatrix) { - this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); + this.matrixCalculator = new(matrix3x3.Value, matrix3x1.Value); } if (hasClut) { - this.clutCalculator = new ClutCalculator(clut); + this.clutCalculator = new(clut); } } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs index c97578ee3f..fbeae88f8e 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs @@ -61,7 +61,7 @@ internal class LutEntryCalculator : IVector4Calculator { this.inputCurve = InitLut(inputCurve); this.outputCurve = InitLut(outputCurve); - this.clutCalculator = new ClutCalculator(clut); + this.clutCalculator = new(clut); this.matrix = matrix; this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; @@ -72,7 +72,7 @@ internal class LutEntryCalculator : IVector4Calculator LutCalculator[] calculators = new LutCalculator[curves.Length]; for (int i = 0; i < curves.Length; i++) { - calculators[i] = new LutCalculator(curves[i].Values, false); + calculators[i] = new(curves[i].Values, false); } return calculators; diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs index 6be1fdbf95..5eade1fc8e 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs @@ -14,7 +14,7 @@ internal class MatrixCalculator : IVector4Calculator public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) { this.matrix2D = matrix3x3; - this.matrix1D = new Vector4(matrix3x1, 0); + this.matrix1D = new(matrix3x1, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs index 29e30b53e2..f0ee4ba580 100644 --- a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs +++ b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs @@ -37,6 +37,6 @@ internal static class CompactSrgbV4Profile { byte[] buffer = new byte[Data.Length]; Data.CopyTo(buffer); - return new IccProfile(buffer); + return new(buffer); } } diff --git a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs index 20df08e378..917be020b5 100644 --- a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs @@ -91,7 +91,7 @@ internal abstract partial class IccConverterBase throw new InvalidIccProfileException("Missing matrix column or channel."); } - return new ColorTrcCalculator( + return new( redMatrixColumn, greenMatrixColumn, blueMatrixColumn, @@ -104,6 +104,6 @@ internal abstract partial class IccConverterBase private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs) { IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); - return new GrayTrcCalculator(entry, toPcs); + return new(entry, toPcs); } } diff --git a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs index 71d565f87f..a5486580fd 100644 --- a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs @@ -24,7 +24,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65) /// public static readonly Matrix4x4 VonKriesHPEAdjusted - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.40024F, M12 = 0.7076F, @@ -42,7 +42,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy) /// public static readonly Matrix4x4 VonKriesHPE - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.3897F, M12 = 0.6890F, @@ -65,7 +65,7 @@ public static class KnownChromaticAdaptationMatrices /// Bradford chromatic adaptation transform matrix (used in CMCCAT97) /// public static readonly Matrix4x4 Bradford - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.8951F, M12 = 0.2664F, @@ -83,7 +83,7 @@ public static class KnownChromaticAdaptationMatrices /// Spectral sharpening and the Bradford transform /// public static readonly Matrix4x4 BradfordSharp - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 1.2694F, M12 = -0.0988F, @@ -101,7 +101,7 @@ public static class KnownChromaticAdaptationMatrices /// CMCCAT2000 (fitted from all available color data sets) /// public static readonly Matrix4x4 CMCCAT2000 - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.7982F, M12 = 0.3389F, @@ -119,7 +119,7 @@ public static class KnownChromaticAdaptationMatrices /// CAT02 (optimized for minimizing CIELAB differences) /// public static readonly Matrix4x4 CAT02 - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.7328F, M12 = 0.4296F, diff --git a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs index 9163839363..1c5f1664c9 100644 --- a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs +++ b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs @@ -18,96 +18,96 @@ public static class KnownRgbWorkingSpaces /// Uses proper companding function, according to: /// /// - public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); /// /// Simplified sRgb working space (uses gamma companding instead of ). /// See also . /// - public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); /// /// Rec. 709 (ITU-R Recommendation BT.709) working space. /// - public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.64F, 0.33F), new CieXyChromaticityCoordinates(0.30F, 0.60F), new CieXyChromaticityCoordinates(0.15F, 0.06F))); + public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new(new(0.64F, 0.33F), new(0.30F, 0.60F), new(0.15F, 0.06F))); /// /// Rec. 2020 (ITU-R Recommendation BT.2020F) working space. /// - public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.708F, 0.292F), new CieXyChromaticityCoordinates(0.170F, 0.797F), new CieXyChromaticityCoordinates(0.131F, 0.046F))); + public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new(new(0.708F, 0.292F), new(0.170F, 0.797F), new(0.131F, 0.046F))); /// /// ECI Rgb v2 working space. /// - public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); /// /// Adobe Rgb (1998) working space. /// - public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2100F, 0.7100F), new(0.1500F, 0.0600F))); /// /// Apple sRgb working space. /// - public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6250F, 0.3400F), new CieXyChromaticityCoordinates(0.2800F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new(new(0.6250F, 0.3400F), new(0.2800F, 0.5950F), new(0.1550F, 0.0700F))); /// /// Best Rgb working space. /// - public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.2150F, 0.7750F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.2150F, 0.7750F), new(0.1300F, 0.0350F))); /// /// Beta Rgb working space. /// - public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6888F, 0.3112F), new CieXyChromaticityCoordinates(0.1986F, 0.7551F), new CieXyChromaticityCoordinates(0.1265F, 0.0352F))); + public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6888F, 0.3112F), new(0.1986F, 0.7551F), new(0.1265F, 0.0352F))); /// /// Bruce Rgb working space. /// - public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2800F, 0.6500F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2800F, 0.6500F), new(0.1500F, 0.0600F))); /// /// CIE Rgb working space. /// - public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.2740F, 0.7170F), new CieXyChromaticityCoordinates(0.1670F, 0.0090F))); + public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new(new(0.7350F, 0.2650F), new(0.2740F, 0.7170F), new(0.1670F, 0.0090F))); /// /// ColorMatch Rgb working space. /// - public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.2950F, 0.6050F), new CieXyChromaticityCoordinates(0.1500F, 0.0750F))); + public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.6300F, 0.3400F), new(0.2950F, 0.6050F), new(0.1500F, 0.0750F))); /// /// Don Rgb 4 working space. /// - public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6960F, 0.3000F), new CieXyChromaticityCoordinates(0.2150F, 0.7650F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6960F, 0.3000F), new(0.2150F, 0.7650F), new(0.1300F, 0.0350F))); /// /// Ekta Space PS5 working space. /// - public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6950F, 0.3050F), new CieXyChromaticityCoordinates(0.2600F, 0.7000F), new CieXyChromaticityCoordinates(0.1100F, 0.0050F))); + public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6950F, 0.3050F), new(0.2600F, 0.7000F), new(0.1100F, 0.0050F))); /// /// NTSC Rgb working space. /// - public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); /// /// PAL/SECAM Rgb working space. /// - public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2900F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2900F, 0.6000F), new(0.1500F, 0.0600F))); /// /// ProPhoto Rgb working space. /// - public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.1596F, 0.8404F), new CieXyChromaticityCoordinates(0.0366F, 0.0001F))); + public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.1596F, 0.8404F), new(0.0366F, 0.0001F))); /// /// SMPTE-C Rgb working space. /// - public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.3100F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6300F, 0.3400F), new(0.3100F, 0.5950F), new(0.1550F, 0.0700F))); /// /// Wide Gamut Rgb working space. /// - public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.1150F, 0.8260F), new CieXyChromaticityCoordinates(0.1570F, 0.0180F))); + public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7350F, 0.2650F), new(0.1150F, 0.8260F), new(0.1570F, 0.0180F))); } diff --git a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs index d32833a382..b838f9ddc9 100644 --- a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs @@ -16,47 +16,47 @@ public static class KnownYCbCrMatrices /// ITU-R BT.601 (SD video standard). /// public static readonly YCbCrTransform BT601 = new( - new Matrix4x4( + new( 0.299000F, 0.587000F, 0.114000F, 0F, -0.168736F, -0.331264F, 0.500000F, 0F, 0.500000F, -0.418688F, -0.081312F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.402000F, 0F, 1.000000F, -0.344136F, -0.714136F, 0F, 1.000000F, 1.772000F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); /// /// ITU-R BT.709 (HD video, sRGB standard). /// public static readonly YCbCrTransform BT709 = new( - new Matrix4x4( + new( 0.212600F, 0.715200F, 0.072200F, 0F, -0.114572F, -0.385428F, 0.500000F, 0F, 0.500000F, -0.454153F, -0.045847F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.574800F, 0F, 1.000000F, -0.187324F, -0.468124F, 0F, 1.000000F, 1.855600F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); /// /// ITU-R BT.2020 (UHD/4K video standard). /// public static readonly YCbCrTransform BT2020 = new( - new Matrix4x4( + new( 0.262700F, 0.678000F, 0.059300F, 0F, -0.139630F, -0.360370F, 0.500000F, 0F, 0.500000F, -0.459786F, -0.040214F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.474600F, 0F, 1.000000F, -0.164553F, -0.571353F, 0F, 1.000000F, 1.881400F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); } diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs index 3aa3d72557..86cb7956bf 100644 --- a/src/ImageSharp/ColorProfiles/Lms.cs +++ b/src/ImageSharp/ColorProfiles/Lms.cs @@ -89,7 +89,7 @@ public readonly struct Lms : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(1F); v3 /= 2F; - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -98,7 +98,7 @@ public readonly struct Lms : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= 2F; v3 -= new Vector3(1F); - return new Lms(v3); + return new(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 42e502592c..4d7788fcfb 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -154,7 +154,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(this.ToScaledVector4())); // Then convert to xyz - return new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); + return new(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); } /// @@ -171,7 +171,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(rgb.ToScaledVector4())); // Then convert to xyz - destination[i] = new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); + destination[i] = new(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); } } @@ -274,7 +274,7 @@ public readonly struct Rgb : IProfileConnectingSpace Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.AsVector3Unsafe(), inverseXyzMatrix); // Use transposed Rows/Columns - return new Matrix4x4 + return new() { M11 = vector.X * mXr, M21 = vector.Y * mXg, diff --git a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs index ec25d0e1c4..6f06ccf27a 100644 --- a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs @@ -42,7 +42,7 @@ public static class VonKriesChromaticAdaptation Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); Matrix4x4.Invert(matrix, out Matrix4x4 inverseMatrix); - return new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); + return new(Vector3.Transform(targetColorLms, inverseMatrix)); } /// @@ -89,7 +89,7 @@ public static class VonKriesChromaticAdaptation Vector3 sourceColorLms = Vector3.Transform(sp.AsVector3Unsafe(), matrix); Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); - dp = new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); + dp = new(Vector3.Transform(targetColorLms, inverseMatrix)); } } } diff --git a/src/ImageSharp/ColorProfiles/Y.cs b/src/ImageSharp/ColorProfiles/Y.cs index 83321a0851..62cef78146 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(Vector3.Dot(source.AsVector3Unsafe(), new(m.M11, m.M12, m.M13)) + offset); } /// diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs index 22d629373b..e112ef7992 100644 --- a/src/ImageSharp/ColorProfiles/YCbCr.cs +++ b/src/ImageSharp/ColorProfiles/YCbCr.cs @@ -24,7 +24,7 @@ public readonly struct YCbCr : IColorProfile /// The cr chroma component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YCbCr(float y, float cb, float cr) - : this(new Vector3(y, cb, cr)) + : this(new(y, cb, cr)) { } @@ -95,7 +95,7 @@ public readonly struct YCbCr : IColorProfile { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -133,7 +133,7 @@ public readonly struct YCbCr : IColorProfile Matrix4x4 m = options.TransposedYCbCrTransform.Forward; Vector3 offset = options.TransposedYCbCrTransform.Offset; - return new YCbCr(Vector3.Transform(rgb, m) + offset, true); + return new(Vector3.Transform(rgb, m) + offset, true); } /// diff --git a/src/ImageSharp/ColorProfiles/YccK.cs b/src/ImageSharp/ColorProfiles/YccK.cs index df5eb48947..d0966a6d12 100644 --- a/src/ImageSharp/ColorProfiles/YccK.cs +++ b/src/ImageSharp/ColorProfiles/YccK.cs @@ -27,7 +27,7 @@ public readonly struct YccK : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YccK(float y, float cb, float cr, float k) - : this(new Vector4(y, cb, cr, k)) + : this(new(y, cb, cr, k)) { } @@ -149,11 +149,11 @@ public readonly struct YccK : IColorProfile if (k >= 1F - Constants.Epsilon) { - return new YccK(new Vector4(0F, 0.5F, 0.5F, 1F), true); + return new(new(0F, 0.5F, 0.5F, 1F), true); } rgb /= 1F - k; - return new YccK(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); + return new(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); } /// diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs index 6ed83a0d8a..c20c6e9c93 100644 --- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs +++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs @@ -14,6 +14,6 @@ internal static class ConfigurationExtensions /// public static ParallelOptions GetParallelOptions(this Configuration configuration) { - return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + return new() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 5f91dcd998..0aa8e4a418 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); @@ -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/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs index f471d0231b..80bfa29ca2 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs @@ -134,7 +134,7 @@ internal static partial class SimdUtils ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); nuint count = (uint)redChannel.Length / 4; - destination.Fill(new Rgba32(0, 0, 0, 255)); + destination.Fill(new(0, 0, 0, 255)); for (nuint i = 0; i < count; i++) { ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 7f98c83754..883e18ae73 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -29,7 +29,7 @@ internal static partial class SimdUtils [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Vector4 PseudoRound(this Vector4 v) { - Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1)); + Vector4 sign = Numerics.Clamp(v, new(-1), new(1)); return v + (sign * 0.5f); } diff --git a/src/ImageSharp/Common/Helpers/UnitConverter.cs b/src/ImageSharp/Common/Helpers/UnitConverter.cs index 45dbe41cb9..c50766ec20 100644 --- a/src/ImageSharp/Common/Helpers/UnitConverter.cs +++ b/src/ImageSharp/Common/Helpers/UnitConverter.cs @@ -131,9 +131,9 @@ internal static class UnitConverter ushort exifUnit = (ushort)(unit + 1); if (unit == PixelResolutionUnit.AspectRatio) { - return new ExifResolutionValues(exifUnit, null, null); + return new(exifUnit, null, null); } - return new ExifResolutionValues(exifUnit, horizontal, vertical); + return new(exifUnit, horizontal, vertical); } } diff --git a/src/ImageSharp/Compression/Zlib/Deflater.cs b/src/ImageSharp/Compression/Zlib/Deflater.cs index f642ec85a7..2e39d435d6 100644 --- a/src/ImageSharp/Compression/Zlib/Deflater.cs +++ b/src/ImageSharp/Compression/Zlib/Deflater.cs @@ -79,7 +79,7 @@ internal sealed class Deflater : IDisposable } // TODO: Possibly provide DeflateStrategy as an option. - this.engine = new DeflaterEngine(memoryAllocator, DeflateStrategy.Default); + this.engine = new(memoryAllocator, DeflateStrategy.Default); this.SetLevel(level); this.Reset(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs index 6009fdfbc0..c9613610d8 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs @@ -147,7 +147,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable /// The deflate strategy to use. public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy) { - this.huffman = new DeflaterHuffman(memoryAllocator); + this.huffman = new(memoryAllocator); this.Pending = this.huffman.Pending; this.strategy = strategy; diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index e4dc1945a8..a05320a09e 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -58,11 +58,11 @@ internal sealed unsafe class DeflaterHuffman : IDisposable /// The memory allocator to use for buffer allocations. public DeflaterHuffman(MemoryAllocator memoryAllocator) { - this.Pending = new DeflaterPendingBuffer(memoryAllocator); + this.Pending = new(memoryAllocator); - this.literalTree = new Tree(memoryAllocator, LiteralNumber, 257, 15); - this.distTree = new Tree(memoryAllocator, DistanceNumber, 1, 15); - this.blTree = new Tree(memoryAllocator, BitLengthNumber, 4, 7); + this.literalTree = new(memoryAllocator, LiteralNumber, 257, 15); + this.distTree = new(memoryAllocator, DistanceNumber, 1, 15); + this.blTree = new(memoryAllocator, BitLengthNumber, 4, 7); this.distanceMemoryOwner = memoryAllocator.Allocate(BufferSize); this.distanceBufferHandle = this.distanceMemoryOwner.Memory.Pin(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs index de818fd8f5..76a5a045ee 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs @@ -30,7 +30,7 @@ internal sealed class DeflaterOutputStream : Stream this.rawStream = rawStream; this.memoryOwner = memoryAllocator.Allocate(BufferLength); this.buffer = this.memoryOwner.Memory; - this.deflater = new Deflater(memoryAllocator, compressionLevel); + this.deflater = new(memoryAllocator, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs index 2e52f84d7b..9364444065 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs @@ -101,7 +101,7 @@ internal sealed class ZlibDeflateStream : Stream this.rawStream.WriteByte(Cmf); this.rawStream.WriteByte((byte)flg); - this.deflateStream = new DeflaterOutputStream(memoryAllocator, this.rawStream, compressionLevel); + this.deflateStream = new(memoryAllocator, this.rawStream, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs index 1d743bf3a5..aa4beba18c 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs @@ -270,7 +270,7 @@ internal sealed class ZlibInflateStream : Stream } // Initialize the deflate BufferedReadStream. - this.CompressedStream = new DeflateStream(this, CompressionMode.Decompress, true); + this.CompressedStream = new(this, CompressionMode.Decompress, true); return true; } diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index b9b32dede7..acf69529aa 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -132,7 +132,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore { int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette); - image = new Image(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); + image = new(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); @@ -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(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata); } /// @@ -343,7 +343,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -404,7 +404,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -1332,7 +1332,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore long infoHeaderStart = stream.Position; // Resolution is stored in PPM. - this.metadata = new ImageMetadata + this.metadata = new() { ResolutionUnits = PixelResolutionUnit.PixelsPerMeter }; @@ -1426,7 +1426,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore byte[] iccProfileData = new byte[this.infoHeader.ProfileSize]; stream.Position = infoHeaderStart + this.infoHeader.ProfileData; stream.Read(iccProfileData); - this.metadata.IccProfile = new IccProfile(iccProfileData); + this.metadata.IccProfile = new(iccProfileData); stream.Position = streamPosition; } } diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 46da463455..ba9a0dc232 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() { 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() { 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() { MaxColors = 2, Dither = this.quantizer.Options.Dither, diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs index 1dac74ba3a..3514a7ed56 100644 --- a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs +++ b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs @@ -54,21 +54,21 @@ public class BmpMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit1 }, - 2 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit2 }, - <= 4 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit4 }, - <= 8 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit8 }, - <= 16 => new BmpMetadata + 1 => new() { BitsPerPixel = BmpBitsPerPixel.Bit1 }, + 2 => new() { BitsPerPixel = BmpBitsPerPixel.Bit2 }, + <= 4 => new() { BitsPerPixel = BmpBitsPerPixel.Bit4 }, + <= 8 => new() { BitsPerPixel = BmpBitsPerPixel.Bit8 }, + <= 16 => new() { BitsPerPixel = BmpBitsPerPixel.Bit16, InfoHeaderType = BmpInfoHeaderType.WinVersion3 }, - <= 24 => new BmpMetadata + <= 24 => new() { BitsPerPixel = BmpBitsPerPixel.Bit24, InfoHeaderType = BmpInfoHeaderType.WinVersion4 }, - _ => new BmpMetadata + _ => new() { BitsPerPixel = BmpBitsPerPixel.Bit32, InfoHeaderType = BmpInfoHeaderType.WinVersion5 @@ -131,7 +131,7 @@ public class BmpMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs index 9854854aad..454f15b862 100644 --- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs @@ -73,7 +73,7 @@ public class CurFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new CurFrameMetadata + return new() { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -98,7 +98,7 @@ public class CurFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new CurFrameMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression, @@ -210,7 +210,7 @@ public class CurFrameMetadata : IFormatFrameMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurMetadata.cs b/src/ImageSharp/Formats/Cur/CurMetadata.cs index d8fdb32902..6499c5b422 100644 --- a/src/ImageSharp/Formats/Cur/CurMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurMetadata.cs @@ -68,7 +68,7 @@ public class CurMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new CurMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class CurMetadata : IFormatMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index f6e3643d58..e749cb1a3b 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -266,7 +266,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowNoHeader(); } - return new ImageInfo( + return new( new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), this.metadata, framesMetadata); @@ -344,7 +344,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifXmpApplicationExtension extension = GifXmpApplicationExtension.Read(stream, this.memoryAllocator); if (extension.Data.Length > 0) { - this.metadata!.XmpProfile = new XmpProfile(extension.Data); + this.metadata!.XmpProfile = new(extension.Data); } else { @@ -549,7 +549,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (previousFrame is null && previousDisposalMode is null) { image = transFlag - ? new Image(this.configuration, imageWidth, imageHeight, this.metadata) + ? new(this.configuration, imageWidth, imageHeight, this.metadata) : new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata); this.SetFrameMetadata(image.Frames.RootFrame.Metadata); diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs index 77f600633b..d6e9c780bd 100644 --- a/src/ImageSharp/Formats/Gif/GifMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs @@ -87,7 +87,7 @@ public class GifMetadata : IFormatMetadata ? Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.GlobalColorTable.Value.Length), 1, 8) : 8; - return new PixelTypeInfo(bpp) + return new(bpp) { ColorType = PixelColorType.Indexed, ComponentInfo = PixelComponentInfo.Create(1, bpp, bpp), diff --git a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs index e413896751..4c2ffbe4d1 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs @@ -22,7 +22,7 @@ internal readonly struct GifNetscapeLoopingApplicationExtension : IGifExtension public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan buffer) { ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer[..2]); - return new GifNetscapeLoopingApplicationExtension(repeatCount); + return new(repeatCount); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs index 1c1127c3be..b32f91205e 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs @@ -42,7 +42,7 @@ internal readonly struct GifXmpApplicationExtension : IGifExtension stream.Skip(1); // Skip the terminator. } - return new GifXmpApplicationExtension(buffer); + return new(buffer); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs index 31f65133e6..3afb02456a 100644 --- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs @@ -66,7 +66,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new IcoFrameMetadata + return new() { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -91,7 +91,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new IcoFrameMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression, @@ -205,7 +205,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Ico/IcoMetadata.cs b/src/ImageSharp/Formats/Ico/IcoMetadata.cs index f8c2ff40f2..4436dce855 100644 --- a/src/ImageSharp/Formats/Ico/IcoMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoMetadata.cs @@ -68,7 +68,7 @@ public class IcoMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new IcoMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class IcoMetadata : IFormatMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 731ad0f765..754f1f8b49 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 StringBuilder(); 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 efc1dbd729..1c0615ef52 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 Vector4(sLeft.X); xyLeft.Z = sLeft.Y; xyLeft.W = sLeft.Y; - var zwLeft = new Vector4(sLeft.Z); + Vector4 zwLeft = new Vector4(sLeft.Z); zwLeft.Z = sLeft.W; zwLeft.W = sLeft.W; - var xyRight = new Vector4(sRight.X); + Vector4 xyRight = new Vector4(sRight.X); xyRight.Z = sRight.Y; xyRight.W = sRight.Y; - var zwRight = new Vector4(sRight.Z); + Vector4 zwRight = new Vector4(sRight.Z); zwRight.Z = sRight.W; zwRight.W = sRight.W; diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs index 74227c7a6e..7d236eeae9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs @@ -514,7 +514,7 @@ internal abstract partial class JpegColorConverterBase Span c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : []; Span c3 = this.Component3.Length > 0 ? this.Component3.Slice(start, length) : []; - return new ComponentValues(this.ComponentCount, c0, c1, c2, c3); + return new(this.ComponentCount, c0, c1, c2, c3); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs index cf2369b2cb..5109b1862b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs @@ -71,7 +71,7 @@ internal readonly struct AdobeMarker : IEquatable short app14Flags1 = (short)((bytes[9] << 8) | bytes[10]); byte colorTransform = bytes[11]; - marker = new AdobeMarker(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); + marker = new(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 6e83f5b2b4..ba6276a5c8 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -242,7 +242,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index 9ee43a2c83..b43df4d974 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -116,7 +116,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); @@ -784,6 +784,6 @@ internal class HuffmanScanDecoder : IJpegScanDecoder public void BuildHuffmanTable(int type, int index, ReadOnlySpan codeLengths, ReadOnlySpan values, Span workspace) { HuffmanTable[] tables = type == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[index] = new HuffmanTable(codeLengths, values, workspace); + tables[index] = new(codeLengths, values, workspace); } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs index 7e25e945a5..b31376992f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs @@ -80,7 +80,7 @@ internal readonly struct JFifMarker : IEquatable byte densityUnits = bytes[7]; short xDensity = (short)((bytes[8] << 8) | bytes[9]); short yDensity = (short)((bytes[10] << 8) | bytes[11]); - marker = new JFifMarker(majorVersion, minorVersion, densityUnits, xDensity, yDensity); + marker = new(majorVersion, minorVersion, densityUnits, xDensity, yDensity); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs index b2debf3938..7e4a06d41a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs @@ -21,7 +21,7 @@ internal class JpegComponent : IDisposable, IJpegComponent this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); + this.SamplingFactors = new(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); this.QuantizationTableIndex = quantizationTableIndex; this.Index = index; @@ -109,7 +109,7 @@ internal class JpegComponent : IDisposable, IJpegComponent int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs index 0703e4d9e0..5b77ab1534 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs @@ -121,7 +121,7 @@ internal abstract class SpectralConverter if (scaledWidth >= tSize.Width && scaledHeight >= tSize.Height) { blockPixelSize = blockSize; - return new Size(scaledWidth, scaledHeight); + return new(scaledWidth, scaledHeight); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs index cc565c4d84..7398e97a01 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs @@ -19,7 +19,7 @@ internal class Component : IDisposable this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(horizontalFactor, verticalFactor); + this.SamplingFactors = new(horizontalFactor, verticalFactor); this.QuantizationTableIndex = quantizationTableIndex; } @@ -95,7 +95,7 @@ internal class Component : IDisposable int blocksPerLineForMcu = frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index c33a8a1968..1704ae1e74 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 Vector(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 90e16f6dff..857f2a1fe5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -134,7 +134,7 @@ internal class HuffmanScanEncoder public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig) { HuffmanLut[] tables = tableConfig.Class == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[tableConfig.DestinationIndex] = new HuffmanLut(tableConfig.Table); + tables[tableConfig.DestinationIndex] = new(tableConfig.Table); } /// @@ -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/JpegFrame.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs index 6ba0b82723..f8a3d6dd2d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs @@ -27,7 +27,7 @@ internal sealed class JpegFrame : IDisposable for (int i = 0; i < this.Components.Length; i++) { JpegComponentConfig componentConfig = componentConfigs[i]; - this.Components[i] = new Component(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) + this.Components[i] = new(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) { DcTableId = componentConfig.DcTableSelector, AcTableId = componentConfig.AcTableSelector, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs index baaa7213ad..e97c57cd95 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs @@ -46,12 +46,12 @@ 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++) { Component component = frame.Components[i]; - this.componentProcessors[i] = new ComponentProcessor( + this.componentProcessors[i] = new( allocator, component, postProcessorBufferSize, @@ -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 c7212fc2df..c92c2e7bd9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs @@ -14,25 +14,25 @@ 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); - return new Size((int)sizeVect.X, (int)sizeVect.Y); + return new((int)sizeVect.X, (int)sizeVect.Y); } /// diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 0b2d3d67ea..c9ac1e6bb1 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -167,7 +167,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData int b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } // Found a marker. @@ -179,14 +179,14 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } } // Found a valid marker. Exit loop if (b is not 0 and (< JpegConstants.Markers.RST0 or > JpegConstants.Markers.RST7)) { - return new JpegFileMarker((byte)(uint)b, stream.Position - 2); + return new((byte)(uint)b, stream.Position - 2); } } } @@ -205,7 +205,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData _ = this.Options.TryGetIccProfileForColorConversion(this.Metadata.IccProfile, out IccProfile profile); - return new Image( + return new( this.configuration, spectralConverter.GetPixelBuffer(profile, cancellationToken), this.Metadata); @@ -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(new(pixelSize.Width, pixelSize.Height), this.Metadata); } /// @@ -233,7 +233,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The scan decoder. public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) { - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); this.QuantizationTables = new Block8x8F[4]; this.scanDecoder = scanDecoder; if (tableBytes.Length < 4) @@ -256,7 +256,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData // Read next marker. bytesRead = stream.Read(markerBuffer); - fileMarker = new JpegFileMarker(markerBuffer[1], (int)stream.Position - 2); + fileMarker = new(markerBuffer[1], (int)stream.Position - 2); while (fileMarker.Marker != JpegConstants.Markers.EOI || (fileMarker.Marker == JpegConstants.Markers.EOI && fileMarker.Invalid)) { @@ -300,7 +300,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowInvalidImageContentException("Not enough data to read marker"); } - fileMarker = new JpegFileMarker(markerBuffer[1], 0); + fileMarker = new(markerBuffer[1], 0); } } @@ -316,7 +316,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.scanDecoder ??= new HuffmanScanDecoder(stream, spectralConverter, cancellationToken); - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); Span markerBuffer = stackalloc byte[2]; @@ -529,7 +529,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData chars[i] = (char)read; } - metadata.Comments.Add(new JpegComData(chars)); + metadata.Comments.Add(new(chars)); } /// @@ -661,7 +661,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasExif) { - this.Metadata.ExifProfile = new ExifProfile(this.exifData); + this.Metadata.ExifProfile = new(this.exifData); } } @@ -685,7 +685,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData if (!this.skipMetadata && profile?.CheckIsValid() == true) { this.hasIcc = true; - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); this.Metadata.IccProfile = profile; } } @@ -697,7 +697,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasIptc) { - this.Metadata.IptcProfile = new IptcProfile(this.iptcData); + this.Metadata.IptcProfile = new(this.iptcData); } } @@ -708,7 +708,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasXmp) { - this.Metadata.XmpProfile = new XmpProfile(this.xmpData); + this.Metadata.XmpProfile = new(this.xmpData); } } @@ -992,7 +992,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The remaining bytes in the segment block. private void ProcessArithmeticTable(BufferedReadStream stream, int remaining) { - this.arithmeticDecodingTables ??= new List(4); + this.arithmeticDecodingTables ??= new(4); while (remaining > 0) { @@ -1242,7 +1242,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowNotSupportedComponentCount(componentCount); } - this.Frame = new JpegFrame(frameMarker, precision, frameWidth, frameHeight, componentCount); + this.Frame = new(frameMarker, precision, frameWidth, frameHeight, componentCount); this.Dimensions = new(frameWidth, frameHeight); this.Metadata.GetJpegMetadata().Progressive = this.Frame.Progressive; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs index 71f852a092..9a89eced28 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 JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); + JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); + JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); + JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); - var defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); - var defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); + JpegQuantizationTableConfig defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); + JpegQuantizationTableConfig defaultChrominanceQuantTable = new JpegQuantizationTableConfig(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, diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs index fe4855dc77..88bea3dc9f 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs @@ -139,7 +139,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new JpegMetadata + return new() { ColorType = color, ChrominanceQuality = metadata.Quality, @@ -182,7 +182,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index 9d3dd3ea4c..d2a2f661f3 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -79,7 +79,7 @@ internal sealed class PbmDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ProcessHeader(stream); - return new ImageInfo( + return new( new(this.pixelSize.Width, this.pixelSize.Height), this.metadata); } @@ -171,9 +171,9 @@ internal sealed class PbmDecoderCore : ImageDecoderCore this.componentType = PbmComponentType.Bit; } - this.pixelSize = new Size(width, height); + this.pixelSize = new(width, height); this.Dimensions = this.pixelSize; - this.metadata = new ImageMetadata(); + this.metadata = new(); PbmMetadata meta = this.metadata.GetPbmMetadata(); meta.Encoding = this.encoding; meta.ColorType = this.colorType; diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index d852f3c8eb..9045671fb0 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -77,7 +77,7 @@ public class PbmMetadata : IFormatMetadata _ => PbmComponentType.Short }; - return new PbmMetadata + return new() { ColorType = color, ComponentType = componentType @@ -114,7 +114,7 @@ public class PbmMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index 8748d90fa8..4ffd824c5f 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -71,7 +71,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L8((byte)value); + rowSpan[x] = new((byte)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -107,7 +107,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L16((ushort)value); + rowSpan[x] = new((ushort)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -154,7 +154,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new Rgb24((byte)red, (byte)green, (byte)blue); + rowSpan[x] = new((byte)red, (byte)green, (byte)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -201,7 +201,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new Rgb48((ushort)red, (ushort)green, (ushort)blue); + rowSpan[x] = new((ushort)red, (ushort)green, (ushort)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { diff --git a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs index 8af0ac8ca7..a68b1cab45 100644 --- a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs +++ b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs @@ -50,7 +50,7 @@ internal readonly struct PngPhysical uint vResolution = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(4, 4)); byte unit = data[8]; - return new PngPhysical(hResolution, vResolution, unit); + return new(hResolution, vResolution, unit); } /// @@ -92,7 +92,7 @@ internal readonly struct PngPhysical break; } - return new PngPhysical(x, y, unitSpecifier); + return new(x, y, unitSpecifier); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index cfea0e6020..b0adbe6c55 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() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 0971c3ecfc..577c15272b 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -297,7 +297,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -497,7 +497,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -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(new(this.header.Width, this.header.Height), metadata, framesMetadata); } finally { @@ -626,7 +626,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void InitializeImage(ImageMetadata metadata, FrameControl frameControl, out Image image) where TPixel : unmanaged, IPixel { - image = new Image(this.configuration, this.header.Width, this.header.Height, metadata); + image = new(this.configuration, this.header.Width, this.header.Height, metadata); PngFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetPngMetadata(); frameMetadata.FromChunk(in frameControl); @@ -1377,7 +1377,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (!TryReadTextChunkMetadata(baseMetadata, name, value)) { - metadata.TextData.Add(new PngTextData(name, value, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, value, string.Empty, string.Empty)); } } @@ -1418,7 +1418,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.Encoding, out string? uncompressed) && !TryReadTextChunkMetadata(baseMetadata, name, uncompressed)) { - metadata.TextData.Add(new PngTextData(name, uncompressed, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, uncompressed, string.Empty, string.Empty)); } } @@ -1476,7 +1476,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore fullRange = null; } - metadata.CicpProfile = new CicpProfile(colorPrimaries, transferFunction, matrixCoefficients, fullRange); + metadata.CicpProfile = new(colorPrimaries, transferFunction, matrixCoefficients, fullRange); } /// @@ -1560,7 +1560,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore return false; } - MergeOrSetExifProfile(metadata, new ExifProfile(exifBlob), replaceExistingKeys: false); + MergeOrSetExifProfile(metadata, new(exifBlob), replaceExistingKeys: false); return true; } @@ -1594,7 +1594,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressZlibData(compressedData, this.maxUncompressedLength, out byte[] iccpProfileBytes)) { - metadata.IccProfile = new IccProfile(iccpProfileBytes); + metadata.IccProfile = new(iccpProfileBytes); } } @@ -1750,17 +1750,17 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.TranslatedEncoding, out string? uncompressed)) { - pngMetadata.TextData.Add(new PngTextData(keyword, uncompressed, language, translatedKeyword)); + pngMetadata.TextData.Add(new(keyword, uncompressed, language, translatedKeyword)); } } else if (IsXmpTextData(keywordBytes)) { - metadata.XmpProfile = new XmpProfile(data[dataStartIdx..].ToArray()); + metadata.XmpProfile = new(data[dataStartIdx..].ToArray()); } else { string value = PngConstants.TranslatedEncoding.GetString(data[dataStartIdx..]); - pngMetadata.TextData.Add(new PngTextData(keyword, value, language, translatedKeyword)); + pngMetadata.TextData.Add(new(keyword, value, language, translatedKeyword)); } } @@ -1950,14 +1950,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore type != PngChunkType.AnimationControl && type != PngChunkType.FrameControl) { - chunk = new PngChunk(length, type); + chunk = new(length, type); return true; } // A chunk might report a length that exceeds the length of the stream. // Take the minimum of the two values to ensure we don't read past the end of the stream. position = this.currentStream.Position; - chunk = new PngChunk( + chunk = new( length: (int)Math.Min(length, this.currentStream.Length - position), type: type, data: this.ReadChunkData(length)); diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index b8086cd6d1..dd642cf6de 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -53,7 +53,7 @@ public class PngFrameMetadata : IFormatFrameMetadata /// The chunk to create an instance from. internal void FromChunk(in FrameControl frameControl) { - this.FrameDelay = new Rational(frameControl.DelayNumerator, frameControl.DelayDenominator); + this.FrameDelay = new(frameControl.DelayNumerator, frameControl.DelayDenominator); this.DisposalMode = frameControl.DisposalMode; this.BlendMode = frameControl.BlendMode; } diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 59ca3b17a0..fcbb93bf0a 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -209,7 +209,7 @@ public class PngMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs index 85fac7ea26..45f79c040f 100644 --- a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs +++ b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs @@ -68,7 +68,7 @@ internal class QoiDecoderCore : ImageDecoderCore qoiMetadata.Channels = this.header.Channels; qoiMetadata.ColorSpace = this.header.ColorSpace; - return new ImageInfo(size, metadata); + return new(size, metadata); } /// @@ -124,7 +124,7 @@ internal class QoiDecoderCore : ImageDecoderCore ThrowInvalidImageContentException(); } - this.header = new QoiHeader(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); + this.header = new(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); } [DoesNotReturn] diff --git a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs index e463d511d2..8f71ebeee8 100644 --- a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs +++ b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs @@ -44,10 +44,10 @@ public class QoiMetadata : IFormatMetadata if (color.HasFlag(PixelColorType.Alpha)) { - return new QoiMetadata { Channels = QoiChannels.Rgba }; + return new() { Channels = QoiChannels.Rgba }; } - return new QoiMetadata { Channels = QoiChannels.Rgb }; + return new() { Channels = QoiChannels.Rgb }; } /// @@ -73,7 +73,7 @@ public class QoiMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index dc6b33422f..59977ecbcb 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -622,7 +622,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore else { byte alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; - color = TPixel.FromBgra32(new Bgra32(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); + color = TPixel.FromBgra32(new(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); } break; @@ -638,7 +638,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadFileHeader(stream); - return new ImageInfo( + return new( new(this.fileHeader.Width, this.fileHeader.Height), this.metadata); } @@ -705,7 +705,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore Guard.NotNull(this.tgaMetadata); byte alpha = this.tgaMetadata.AlphaChannelBits == 0 ? byte.MaxValue : scratchBuffer[3]; - pixelRow[x] = TPixel.FromBgra32(new Bgra32(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); + pixelRow[x] = TPixel.FromBgra32(new(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -907,9 +907,9 @@ internal sealed class TgaDecoderCore : ImageDecoderCore stream.Read(buffer, 0, TgaFileHeader.Size); this.fileHeader = TgaFileHeader.Parse(buffer); - this.Dimensions = new Size(this.fileHeader.Width, this.fileHeader.Height); + this.Dimensions = new(this.fileHeader.Width, this.fileHeader.Height); - this.metadata = new ImageMetadata(); + this.metadata = new(); this.tgaMetadata = this.metadata.GetTgaMetadata(); this.tgaMetadata.BitsPerPixel = (TgaBitsPerPixel)this.fileHeader.PixelDepth; diff --git a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs index ad76bc3fbd..50d9920302 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/Tga/TgaMetadata.cs b/src/ImageSharp/Formats/Tga/TgaMetadata.cs index 8d40f86464..a7be538ec8 100644 --- a/src/ImageSharp/Formats/Tga/TgaMetadata.cs +++ b/src/ImageSharp/Formats/Tga/TgaMetadata.cs @@ -41,10 +41,10 @@ public class TgaMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - <= 8 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit8 }, - <= 16 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit16 }, - <= 24 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit24 }, - _ => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit32 } + <= 8 => new() { BitsPerPixel = TgaBitsPerPixel.Bit8 }, + <= 16 => new() { BitsPerPixel = TgaBitsPerPixel.Bit16 }, + <= 24 => new() { BitsPerPixel = TgaBitsPerPixel.Bit24 }, + _ => new() { BitsPerPixel = TgaBitsPerPixel.Bit32 } }; } @@ -79,7 +79,7 @@ public class TgaMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs index 6881e3a7b3..1d7de583f7 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs @@ -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 ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) { if (this.Predictor == TiffPredictor.Horizontal) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs index a6242114ef..7dfb60bad8 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs @@ -20,7 +20,7 @@ internal sealed class LzwCompressor : TiffBaseCompressor public override TiffCompression Method => TiffCompression.Lzw; /// - public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new TiffLzwEncoder(this.Allocator); + public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new(this.Allocator); /// public override void CompressStrip(Span rows, int height) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs index 1c0a473659..4229cfada5 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 08faa539a8..a2a83be0a6 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 MemoryStream(); + 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 64e702f1be..39c3928150 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 ZlibInflateStream( stream, () => { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index 5f18fc2d73..cad46e987b 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; @@ -50,10 +50,10 @@ public class LzwString { if (this == Empty) { - return new LzwString(other); + return new(other); } - return new LzwString(other, this.FirstChar, this.Length + 1, this); + return new(other, this.FirstChar, this.Length + 1, this); } /// diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs index 2402927186..beb22a2bb6 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 TiffLzwDecoder(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 d2dbedc9cb..f0ed12c411 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 ModifiedHuffmanBitReader(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 6bdcad2b81..4d09f7b4e0 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 T4BitReader(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 c868fec626..c0ec49d8e7 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++) { @@ -69,7 +69,7 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor bitsWritten = this.WriteScanLine(buffer, scanLine, bitsWritten); scanLine.CopyTo(referenceScanLineSpan); - referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, referenceScanLineSpan); + referenceScanLine = new(this.isWhiteZero, referenceScanLineSpan); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs index a53e1bc74c..40278dca20 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs @@ -103,7 +103,7 @@ internal sealed class TiffLzwDecoder this.table = new LzwString[TableSize]; for (int i = 0; i < 256; i++) { - this.table[i] = new LzwString((byte)i); + this.table[i] = new((byte)i); } this.Init(); diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs index 76d0bb6418..5f4ca12bda 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() { 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/HorizontalPredictor.cs b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs index 706e6a38c1..ebf4042e2b 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs @@ -222,7 +222,7 @@ internal static class HorizontalPredictor byte r = (byte)(rowRgb[x].R - rowRgb[x - 1].R); byte g = (byte)(rowRgb[x].G - rowRgb[x - 1].G); byte b = (byte)(rowRgb[x].B - rowRgb[x - 1].B); - rowRgb[x] = new Rgb24(r, g, b); + rowRgb[x] = new(r, g, b); } } } @@ -429,7 +429,7 @@ internal static class HorizontalPredictor r += pixel.R; g += pixel.G; b += pixel.B; - pixel = new Rgb24(r, g, b); + pixel = new(r, g, b); } } @@ -462,7 +462,7 @@ internal static class HorizontalPredictor g += pixel.G; b += pixel.B; a += pixel.A; - pixel = new Rgba32(r, g, b, a); + pixel = new(r, g, b, a); } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs index ac316459d8..b30700adb3 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ internal class BlackIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder : TiffBaseColorDecoder Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); for (int x = 0; x < pixelRow.Length; x++) { - pixelRow[x] = TPixel.FromVector4(new Vector4(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); + pixelRow[x] = TPixel.FromVector4(new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); offset += 3; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs index 3c205d1476..2b85c2fd6f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs @@ -52,7 +52,7 @@ internal class RgbTiffColor : TiffBaseColorDecoder float g = bitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs index 7d31f23abd..0db555cbbd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs @@ -50,7 +50,7 @@ internal class WhiteIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = 1f - (value / this.factor); - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 0a1cf6ab98..754cbd0059 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -45,10 +45,10 @@ internal class YCbCrConverter TiffThrowHelper.ThrowImageFormatException("luma coefficients array should have 6 entry's"); } - this.yExpander = new CodingRangeExpander(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); - this.cbExpander = new CodingRangeExpander(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); - this.crExpander = new CodingRangeExpander(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); - this.converter = new YCbCrToRgbConverter(coefficients[0], coefficients[1], coefficients[2]); + this.yExpander = new(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); + this.cbExpander = new(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); + this.crExpander = new(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); + this.converter = new(coefficients[0], coefficients[1], coefficients[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -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/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs index 768177bfc0..ebae824303 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs @@ -20,7 +20,7 @@ internal class YCbCrPlanarTiffColor : TiffBasePlanarColorDecoder public YCbCrPlanarTiffColor(Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs index 5a13890356..3bf550fe55 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs @@ -24,7 +24,7 @@ internal class YCbCrTiffColor : TiffBaseColorDecoder public YCbCrTiffColor(MemoryAllocator memoryAllocator, Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { this.memoryAllocator = memoryAllocator; - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs index 2bfd9a626f..e9b620ea29 100644 --- a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs +++ b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs @@ -120,7 +120,7 @@ public readonly struct TiffBitsPerSample : IEquatable break; } - sample = new TiffBitsPerSample(c0, c1, c2, c3); + sample = new(c0, c1, c2, c3); return true; } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index e594ee8121..73f66a062a 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -191,7 +191,7 @@ internal class TiffDecoderCore : ImageDecoderCore this.Dimensions = frames[0].Size; ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new Image(this.configuration, metadata, frames); + return new(this.configuration, metadata, frames); } catch { @@ -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(new(width, height), metadata, framesMetadata); } /// @@ -285,7 +285,7 @@ internal class TiffDecoderCore : ImageDecoderCore // We resolve the ICC profile early so that we can use it for color conversion if needed. if (tags.TryGetValue(ExifTag.IccProfile, out IExifValue iccProfileBytes)) { - imageFrameMetaData.IccProfile = new IccProfile(iccProfileBytes.Value); + imageFrameMetaData.IccProfile = new(iccProfileBytes.Value); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs index ebf407f9b5..db27854a17 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs @@ -33,12 +33,12 @@ internal static class TiffDecoderMetadataCreator ImageFrameMetadata frameMetaData = frames[i]; if (TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes)) { - frameMetaData.IptcProfile = new IptcProfile(iptcBytes); + frameMetaData.IptcProfile = new(iptcBytes); } if (frameMetaData.ExifProfile.TryGetValue(ExifTag.XMP, out IExifValue xmpProfileBytes)) { - frameMetaData.XmpProfile = new XmpProfile(xmpProfileBytes.Value); + frameMetaData.XmpProfile = new(xmpProfileBytes.Value); } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 7519871b74..9583994543 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -531,7 +531,7 @@ internal static class TiffDecoderOptionsParser // Some encoders do not set the BitsPerSample correctly, so we set those values here to the required values: // https://github.com/SixLabors/ImageSharp/issues/2587 - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -549,7 +549,7 @@ internal static class TiffDecoderOptionsParser options.FaxCompressionOptions = FaxCompressionOptions.None; } - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -557,7 +557,7 @@ internal static class TiffDecoderOptionsParser case TiffCompression.Ccitt1D: options.CompressionType = TiffDecoderCompressionType.HuffmanRle; - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index 803b77fb0a..8890c61a59 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); @@ -298,12 +298,12 @@ internal class TiffEncoderEntriesCollector { this.Collector.AddOrReplace(new ExifRational(ExifTagValue.XResolution) { - Value = new Rational(resolution.HorizontalResolution.Value) + Value = new(resolution.HorizontalResolution.Value) }); this.Collector.AddOrReplace(new ExifRational(ExifTagValue.YResolution) { - Value = new Rational(resolution.VerticalResolution.Value) + Value = new(resolution.VerticalResolution.Value) }); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs index e965fcb4f6..7d20564694 100644 --- a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs @@ -75,7 +75,7 @@ public class TiffMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new TiffMetadata + 1 => new() { BitsPerPixel = TiffBitsPerPixel.Bit1, BitsPerSample = TiffConstants.BitsPerSample1Bit, @@ -83,7 +83,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.CcittGroup4Fax, Predictor = TiffPredictor.None }, - <= 4 => new TiffMetadata + <= 4 => new() { BitsPerPixel = TiffBitsPerPixel.Bit4, BitsPerSample = TiffConstants.BitsPerSample4Bit, @@ -91,7 +91,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.None // Best match for low bit depth }, - 8 => new TiffMetadata + 8 => new() { BitsPerPixel = TiffBitsPerPixel.Bit8, BitsPerSample = TiffConstants.BitsPerSample8Bit, @@ -99,7 +99,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 16 => new TiffMetadata + 16 => new() { BitsPerPixel = TiffBitsPerPixel.Bit16, BitsPerSample = TiffConstants.BitsPerSample16Bit, @@ -107,7 +107,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 32 or 64 => new TiffMetadata + 32 or 64 => new() { BitsPerPixel = TiffBitsPerPixel.Bit32, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -115,7 +115,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - _ => new TiffMetadata + _ => new() { BitsPerPixel = TiffBitsPerPixel.Bit24, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -165,7 +165,7 @@ public class TiffMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { ColorType = colorType, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs index 647ff8a1a3..8ede732793 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs @@ -30,7 +30,7 @@ internal sealed class TiffBiColorWriter : TiffBaseColorWriter : base(image, encodingSize, memoryAllocator, configuration, entriesCollector) { // Convert image to black and white. - this.imageBlackWhite = new Image(configuration, new ImageMetadata(), [image.Clone()]); + this.imageBlackWhite = new(configuration, new(), [image.Clone()]); this.imageBlackWhite.Mutate(img => img.BinaryDither(KnownDitherings.FloydSteinberg)); } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs index da66373631..a6106ae855 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs @@ -44,13 +44,13 @@ internal sealed class TiffPaletteWriter : TiffBaseColorWriter this.colorPaletteBytes = this.colorPaletteSize * 2; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer( this.Configuration, - new QuantizerOptions() + new() { MaxColors = this.maxColors }); frameQuantizer.BuildPalette(pixelSamplingStrategy, frame); - this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new Rectangle(Point.Empty, encodingSize)); + this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new(Point.Empty, encodingSize)); this.AddColorMapTag(); } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index c7ce12fc7b..f374daba4f 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -56,12 +56,12 @@ internal class AlphaDecoder : IDisposable this.Alpha = memoryAllocator.Allocate(totalPixels); this.AlphaFilterType = (WebpAlphaFilterType)filter; - this.Vp8LDec = new Vp8LDecoder(width, height, memoryAllocator); + this.Vp8LDec = new(width, height, memoryAllocator); if (this.Compressed) { - Vp8LBitReader bitReader = new Vp8LBitReader(data); - this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration); + Vp8LBitReader bitReader = new(data); + this.LosslessDecoder = new(bitReader, memoryAllocator, configuration); this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true); // Special case: if alpha data uses only the color indexing transform and diff --git a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs index fd6f508e4a..56587da187 100644 --- a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs @@ -92,7 +92,7 @@ internal static class AlphaEncoder for (int x = 0; x < width; x++) { // Leave A/R/B channels zero'd. - pixelRow[x] = new Bgra32(0, alphaRow[x], 0, 0); + pixelRow[x] = new(0, alphaRow[x], 0, 0); } } diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs index dc867fa85e..0b71a3ed0c 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs @@ -102,7 +102,7 @@ internal class Vp8LBitWriter : BitWriterBase { byte[] clonedBuffer = new byte[this.Buffer.Length]; System.Buffer.BlockCopy(this.Buffer, 0, clonedBuffer, 0, this.cur); - return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur); + return new(clonedBuffer, this.bits, this.used, this.cur); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 274d4426f9..bac6d5167c 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -72,7 +72,7 @@ internal static class BackwardReferenceEncoder BackwardReferencesLz77(width, height, bgra, 0, hashChain, worst); break; case Vp8LLz77Type.Lz77Box: - hashChainBox = new Vp8LHashChain(memoryAllocator, width * height); + hashChainBox = new(memoryAllocator, width * height); BackwardReferencesLz77Box(width, height, bgra, 0, hashChain, hashChainBox, worst); break; } @@ -145,7 +145,7 @@ internal static class BackwardReferenceEncoder for (int i = 0; i < colorCache.Length; i++) { histos[i].PaletteCodeBits = i; - colorCache[i] = new ColorCache(i); + colorCache[i] = new(i); } // Find the cacheBits giving the lowest entropy. @@ -281,7 +281,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } costModel.Build(xSize, cacheBits, refs); @@ -383,7 +383,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } backwardRefs.Clear(); @@ -475,7 +475,7 @@ internal static class BackwardReferenceEncoder ColorCache? colorCache = null; if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } refs.Clear(); @@ -730,7 +730,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } refs.Clear(); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs index 63ce9dbec6..2b2286e044 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs @@ -17,21 +17,21 @@ 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) { int costCacheSize = pixCount > BackwardReferenceEncoder.MaxLength ? BackwardReferenceEncoder.MaxLength : pixCount; - this.CacheIntervals = new List(); - this.CostCache = new List(); + this.CacheIntervals = new(); + this.CostCache = new(); this.Costs = memoryAllocator.Allocate(pixCount); this.DistArray = distArray; this.Count = 0; for (int i = 0; i < FreeIntervalsStartCount; i++) { - this.freeIntervals.Push(new CostInterval()); + this.freeIntervals.Push(new()); } // Fill in the cost cache. @@ -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() { 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() { Cost = cost, Start = start, End = end, Index = position }; } this.PositionOrphanInterval(intervalNew, intervalIn); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs index 5806ee5b5c..1375218da9 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs @@ -15,7 +15,7 @@ internal struct HTreeGroup { public HTreeGroup(uint packedTableSize) { - this.HTrees = new List(WebpConstants.HuffmanCodesPerMetaCode); + this.HTrees = new(WebpConstants.HuffmanCodesPerMetaCode); this.PackedTable = new HuffmanCode[packedTableSize]; this.IsTrivialCode = false; this.IsTrivialLiteral = false; diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index 027d4f7ee9..fd5d1dd940 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -425,7 +425,7 @@ internal static class HuffmanUtils tableSize = 1 << tableBits; totalSize += tableSize; low = key & mask; - table[low] = new HuffmanCode + table[low] = new() { BitsUsed = tableBits + rootBits, Value = (uint)(tablePos - low) diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 736070a1c9..19dc08fc5b 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/Vp8LDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs index 374465cf79..c22abd83e2 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs @@ -22,7 +22,7 @@ internal class Vp8LDecoder : IDisposable { this.Width = width; this.Height = height; - this.Metadata = new Vp8LMetadata(); + this.Metadata = new(); this.Pixels = memoryAllocator.Allocate(width * height, AllocationOptions.Clean); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index b398554eb1..2cbe4bbb61 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -124,16 +124,16 @@ internal class Vp8LEncoder : IDisposable this.transparentColorMode = transparentColorMode; this.nearLossless = nearLossless; this.nearLosslessQuality = Numerics.Clamp(nearLosslessQuality, 0, 100); - this.bitWriter = new Vp8LBitWriter(initialSize); + this.bitWriter = new(initialSize); this.Bgra = memoryAllocator.Allocate(pixelCount); this.EncodedData = memoryAllocator.Allocate(pixelCount); this.Palette = memoryAllocator.Allocate(WebpConstants.MaxPaletteSize); this.Refs = new Vp8LBackwardRefs[3]; - this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); + this.HashChain = new(memoryAllocator, pixelCount); for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount); + this.Refs[i] = new(memoryAllocator, pixelCount); } } @@ -549,14 +549,14 @@ internal class Vp8LEncoder : IDisposable // We can only apply kPalette or kPaletteAndSpatial if we can indeed use a palette. if ((entropyIx != EntropyIx.Palette && entropyIx != EntropyIx.PaletteAndSpatial) || usePalette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIx }); } } } else { // Only choose the guessed best transform. - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIdx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIdx }); if (this.quality >= 75 && this.method == WebpEncodingMethod.Level5) { // Test with and without color cache. @@ -565,7 +565,7 @@ internal class Vp8LEncoder : IDisposable // If we have a palette, also check in combination with spatial. if (entropyIdx == EntropyIx.Palette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = EntropyIx.PaletteAndSpatial }); + crunchConfigs.Add(new() { EntropyIdx = EntropyIx.PaletteAndSpatial }); } } } @@ -575,7 +575,7 @@ internal class Vp8LEncoder : IDisposable { for (int j = 0; j < nlz77s; j++) { - crunchConfig.SubConfigs.Add(new CrunchSubConfig + crunchConfig.SubConfigs.Add(new() { Lz77 = j == 0 ? (int)Vp8LLz77Type.Lz77Standard | (int)Vp8LLz77Type.Lz77Rle : (int)Vp8LLz77Type.Lz77Box, DoNotCache = doNotCache @@ -712,7 +712,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } for (int i = 0; i < 5 * histogramImageSize; i++) @@ -858,7 +858,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } // Store Huffman codes. diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 03bedfe672..5b3ecc7f57 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -613,7 +613,7 @@ internal sealed unsafe class OwnedVp8LHistogram : Vp8LHistogram, IDisposable { IMemoryOwner bufferOwner = memoryAllocator.Allocate(BufferSize, AllocationOptions.Clean); MemoryHandle bufferHandle = bufferOwner.Memory.Pin(); - return new OwnedVp8LHistogram(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); + return new(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs index a46838ee67..68b52f22bf 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs @@ -25,7 +25,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), cacheBits)); @@ -41,7 +41,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), refs, cacheBits)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index 6de3ae7497..af26616ccb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -108,7 +108,7 @@ internal sealed class WebpLosslessDecoder int numberOfTransformsPresent = 0; if (isLevel0) { - decoder.Transforms = new List(WebpConstants.MaxNumberOfTransforms); + decoder.Transforms = new(WebpConstants.MaxNumberOfTransforms); // Next bit indicates, if a transformation is present. while (this.bitReader.ReadBit()) @@ -129,7 +129,7 @@ internal sealed class WebpLosslessDecoder } else { - decoder.Metadata = new Vp8LMetadata(); + decoder.Metadata = new(); } // Color cache. @@ -156,7 +156,7 @@ internal sealed class WebpLosslessDecoder // Finish setting up the color-cache. if (isColorCachePresent) { - decoder.Metadata.ColorCache = new ColorCache(colorCacheBits); + decoder.Metadata.ColorCache = new(colorCacheBits); colorCacheSize = 1 << colorCacheBits; decoder.Metadata.ColorCacheSize = colorCacheSize; } @@ -416,7 +416,7 @@ internal sealed class WebpLosslessDecoder int[] codeLengths = new int[maxAlphabetSize]; for (int i = 0; i < numHTreeGroupsMax; i++) { - hTreeGroups[i] = new HTreeGroup(HuffmanUtils.HuffmanPackedTableSize); + hTreeGroups[i] = new(HuffmanUtils.HuffmanPackedTableSize); HTreeGroup hTreeGroup = hTreeGroups[i]; int totalSize = 0; bool isTrivialLiteral = true; diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index e9eb1110b0..31030adb03 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 Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); 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 Vp8ModeScore(); 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(); + Vp8ModeScore rdTmp = new Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); 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(); + Vp8ModeScore rdUv = new Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); 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/Vp8BandProbas.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs index 90506efb81..0c25fb4e47 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs @@ -16,7 +16,7 @@ internal class Vp8BandProbas this.Probabilities = new Vp8ProbaArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Probabilities[i] = new Vp8ProbaArray(); + this.Probabilities[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs index eee22159e1..a0fe034864 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs @@ -13,7 +13,7 @@ internal class Vp8Costs this.Costs = new Vp8CostArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Costs[i] = new Vp8CostArray(); + this.Costs[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs index 3c8bafa1b2..cd9a0dea2a 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs @@ -25,7 +25,7 @@ internal class Vp8Decoder : IDisposable /// Used for allocating memory for the pixel data output and the temporary buffers. public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities, MemoryAllocator memoryAllocator) { - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); this.FrameHeader = frameHeader; this.PictureHeader = pictureHeader; this.SegmentHeader = segmentHeader; @@ -41,22 +41,22 @@ internal class Vp8Decoder : IDisposable this.FilterInfo = new Vp8FilterInfo[this.MbWidth]; for (int i = 0; i < this.MbWidth; i++) { - this.MacroBlockInfo[i] = new Vp8MacroBlock(); - this.MacroBlockData[i] = new Vp8MacroBlockData(); - this.YuvTopSamples[i] = new Vp8TopSamples(); - this.FilterInfo[i] = new Vp8FilterInfo(); + this.MacroBlockInfo[i] = new(); + this.MacroBlockData[i] = new(); + this.YuvTopSamples[i] = new(); + this.FilterInfo[i] = new(); } - this.MacroBlockInfo[this.MbWidth] = new Vp8MacroBlock(); + this.MacroBlockInfo[this.MbWidth] = new(); this.DeQuantMatrices = new Vp8QuantMatrix[WebpConstants.NumMbSegments]; this.FilterStrength = new Vp8FilterInfo[WebpConstants.NumMbSegments, 2]; for (int i = 0; i < WebpConstants.NumMbSegments; i++) { - this.DeQuantMatrices[i] = new Vp8QuantMatrix(); + this.DeQuantMatrices[i] = new(); for (int j = 0; j < 2; j++) { - this.FilterStrength[i, j] = new Vp8FilterInfo(); + this.FilterStrength[i, j] = new(); } } @@ -245,7 +245,7 @@ internal class Vp8Decoder : IDisposable public Vp8MacroBlock CurrentMacroBlock => this.MacroBlockInfo[this.MbX]; - public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new Vp8MacroBlock(); + public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new(); public Vp8MacroBlockData CurrentBlockData => this.MacroBlockData[this.MbX]; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index 52c7e9703b..7f57c81f84 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 @@ -427,7 +427,7 @@ internal class Vp8EncIterator this.MakeIntra4Preds(); for (mode = 0; mode < maxMode; ++mode) { - histos[curHisto] = new Vp8Histogram(); + histos[curHisto] = new(); histos[curHisto].CollectHistogram(src, this.YuvP.AsSpan(Vp8Encoding.Vp8I4ModeOffsets[mode]), 0, 1); int alpha = histos[curHisto].GetAlpha(); @@ -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/Vp8EncProba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs index 070e705747..a6faddc04d 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs @@ -29,7 +29,7 @@ internal class Vp8EncProba this.Coeffs[i] = new Vp8BandProbas[WebpConstants.NumBands]; for (int j = 0; j < this.Coeffs[i].Length; j++) { - this.Coeffs[i][j] = new Vp8BandProbas(); + this.Coeffs[i][j] = new(); } } @@ -39,7 +39,7 @@ internal class Vp8EncProba this.Stats[i] = new Vp8Stats[WebpConstants.NumBands]; for (int j = 0; j < this.Stats[i].Length; j++) { - this.Stats[i][j] = new Vp8Stats(); + this.Stats[i][j] = new(); } } @@ -49,7 +49,7 @@ internal class Vp8EncProba this.LevelCost[i] = new Vp8Costs[WebpConstants.NumBands]; for (int j = 0; j < this.LevelCost[i].Length; j++) { - this.LevelCost[i][j] = new Vp8Costs(); + this.LevelCost[i][j] = new(); } } @@ -59,7 +59,7 @@ internal class Vp8EncProba this.RemappedCosts[i] = new Vp8Costs[16]; for (int j = 0; j < this.RemappedCosts[i].Length; j++) { - this.RemappedCosts[i][j] = new Vp8Costs(); + this.RemappedCosts[i][j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index e4ebe14731..608c5391b3 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -172,19 +172,19 @@ internal class Vp8Encoder : IDisposable this.MbInfo = new Vp8MacroBlockInfo[this.Mbw * this.Mbh]; for (int i = 0; i < this.MbInfo.Length; i++) { - this.MbInfo[i] = new Vp8MacroBlockInfo(); + this.MbInfo[i] = new(); } this.SegmentInfos = new Vp8SegmentInfo[4]; for (int i = 0; i < 4; i++) { - this.SegmentInfos[i] = new Vp8SegmentInfo(); + this.SegmentInfos[i] = new(); } - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); int predSize = (((4 * this.Mbw) + 1) * ((4 * this.Mbh) + 1)) + this.PredsWidth + 1; this.PredsWidth = (4 * this.Mbw) + 1; - this.Proba = new Vp8EncProba(); + this.Proba = new(); this.Preds = new byte[predSize + this.PredsWidth + this.Mbw]; // Initialize with default values, which the reference c implementation uses, @@ -424,14 +424,14 @@ internal class Vp8Encoder : IDisposable this.uvAlpha /= totalMb; // Analysis is done, proceed to actual encoding. - this.SegmentHeader = new Vp8EncSegmentHeader(4); + this.SegmentHeader = new(4); this.AssignSegments(alphas); this.SetLoopParams(this.quality); // Initialize the bitwriter. int averageBytesPerMacroBlock = AverageBytesPerMb[this.BaseQuant >> 4]; int expectedSize = this.Mbw * this.Mbh * averageBytesPerMacroBlock; - this.bitWriter = new Vp8BitWriter(expectedSize, this); + this.bitWriter = new(expectedSize, this); // Stats-collection loop. this.StatLoop(width, height, yStride, uvStride); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs index 0da6dfcad4..de03f3c93c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs @@ -23,7 +23,7 @@ internal class Vp8Proba { for (int j = 0; j < WebpConstants.NumBands; j++) { - this.Bands[i, j] = new Vp8BandProbas(); + this.Bands[i, j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs index dda921a7c7..bd335f2985 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs @@ -13,7 +13,7 @@ internal class Vp8Stats this.Stats = new Vp8StatsArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Stats[i] = new Vp8StatsArray(); + this.Stats[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 65d5b65e88..bd87b385c6 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -1173,13 +1173,13 @@ internal sealed class WebpLossyDecoder pSize = sizeLeft; } - dec.Vp8BitReaders[p] = new Vp8BitReader(this.bitReader.Data, (uint)pSize, partStart); + dec.Vp8BitReaders[p] = new(this.bitReader.Data, (uint)pSize, partStart); partStart += pSize; sizeLeft -= pSize; sz = sz[3..]; } - dec.Vp8BitReaders[lastPart] = new Vp8BitReader(this.bitReader.Data, (uint)sizeLeft, partStart); + dec.Vp8BitReaders[lastPart] = new(this.bitReader.Data, (uint)sizeLeft, partStart); } private void ParseDequantizationIndices(Vp8Decoder decoder) diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 173d9436dd..d19efec3b1 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -93,7 +93,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame? previousFrame = null; WebpFrameData? prevFrameData = null; - this.metadata = new ImageMetadata(); + this.metadata = new(); this.webpMetadata = this.metadata.GetWebpMetadata(); this.webpMetadata.RepeatCount = features.AnimationLoopCount; @@ -204,7 +204,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame currentFrame; if (previousFrame is null) { - image = new Image(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); + image = new(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); currentFrame = image.Frames.RootFrame; SetFrameMetadata(currentFrame.Metadata, frameData); diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 4ccaf65031..a4e88e2271 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -358,7 +358,7 @@ internal static class WebpChunkParsingUtils if (metadata.ExifProfile != null) { - metadata.ExifProfile = new ExifProfile(exifData); + metadata.ExifProfile = new(exifData); } break; @@ -372,7 +372,7 @@ internal static class WebpChunkParsingUtils if (metadata.XmpProfile != null) { - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } break; diff --git a/src/ImageSharp/Formats/Webp/WebpDecoder.cs b/src/ImageSharp/Formats/Webp/WebpDecoder.cs index dfbf4ef0e6..41c5d60f73 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() { 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/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 51379a32ae..dfd80c8380 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -93,7 +93,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } - image = new Image(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); + image = new(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.webImageInfo.IsLossless) { @@ -136,8 +136,8 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable ImageMetadata metadata = new(); using (this.webImageInfo = this.ReadVp8Info(stream, metadata, true)) { - return new ImageInfo( - new Size((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), + return new( + new((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), metadata); } } @@ -229,7 +229,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable default: WebpThrowHelper.ThrowImageFormatException("Unrecognized VP8 header"); return - new WebpImageInfo(); // this return will never be reached, because throw helper will throw an exception. + new(); // this return will never be reached, because throw helper will throw an exception. } } @@ -389,7 +389,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return; } - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index db57bd8f27..817addac5b 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -126,7 +126,7 @@ public class WebpMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs index 4220b3df77..aa0590619a 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 GraphicsOptions(); // 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/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index d2ee0f9061..7e61e50950 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -36,7 +36,7 @@ public abstract partial class Image width, height, configuration.PreferContiguousImageBuffers); - return new Image(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); + return new(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); } /// diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 03bec8bc6a..ab2718f6c5 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -53,7 +53,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemory.Length >= (long)width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -87,7 +87,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemory, width, height, new()); /// /// @@ -148,7 +148,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -171,7 +171,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -235,7 +235,7 @@ public abstract partial class Image Guard.IsTrue(memoryManager.Memory.Length >= (long)width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -269,7 +269,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemory, width, height, new()); /// /// @@ -333,7 +333,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -356,7 +356,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -429,7 +429,7 @@ public abstract partial class Image Guard.MustBeGreaterThanOrEqualTo(bufferSizeInBytes / sizeof(TPixel), memoryManager.Memory.Span.Length, nameof(bufferSizeInBytes)); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -470,7 +470,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new ImageMetadata()); + => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new()); /// /// diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 07b40a41a1..693b58db64 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -47,7 +47,7 @@ public abstract partial class Image : IDisposable, IConfigurationProvider ImageMetadata metadata, int width, int height) - : this(configuration, pixelType, metadata, new Size(width, height)) + : this(configuration, pixelType, metadata, new(width, height)) { } diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 61f4c0ea9d..90fe16bad9 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 ImageFrame(configuration, width, height); data = data[..count]; data.CopyTo(image.PixelBuffer.FastMemoryGroup); diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index ad7d719744..da76aa4ab1 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -23,7 +23,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, backgroundColor)); + this.frames.Add(new(parent.Configuration, width, height, backgroundColor)); } internal ImageFrameCollection(Image parent, int width, int height, MemoryGroup memorySource) @@ -31,7 +31,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, memorySource)); + this.frames.Add(new(parent.Configuration, width, height, memorySource)); } internal ImageFrameCollection(Image parent, IEnumerable> frames) @@ -269,7 +269,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.frames.Remove(frame); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); } /// @@ -284,7 +284,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer ImageFrame frame = this[index]; ImageFrame clonedFrame = frame.Clone(); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); } /// diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index de71e77ca0..ce673ba400 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -81,7 +81,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The color to clear the image with. internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageFrameMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -114,7 +114,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The memory source. internal ImageFrame(Configuration configuration, int width, int height, MemoryGroup memorySource) - : this(configuration, width, height, memorySource, new ImageFrameMetadata()) + : this(configuration, width, height, memorySource, new()) { } @@ -132,7 +132,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - this.PixelBuffer = new Buffer2D(memorySource, width, height); + this.PixelBuffer = new(memorySource, width, height); } /// diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 7ec7918381..543d6ab43d 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -41,7 +41,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -53,7 +53,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(int width, int height, TPixel backgroundColor) - : this(Configuration.Default, width, height, backgroundColor, new ImageMetadata()) + : this(Configuration.Default, width, height, backgroundColor, new()) { } @@ -78,7 +78,7 @@ public sealed class Image : Image /// The images metadata. internal Image(Configuration configuration, int width, int height, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); + => this.frames = new(this, width, height, default(TPixel)); /// /// Initializes a new instance of the class @@ -111,7 +111,7 @@ public sealed class Image : Image int height, ImageMetadata metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, width, height) - => this.frames = new ImageFrameCollection(this, width, height, memoryGroup); + => this.frames = new(this, width, height, memoryGroup); /// /// Initializes a new instance of the class @@ -129,7 +129,7 @@ public sealed class Image : Image TPixel backgroundColor, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, backgroundColor); + => this.frames = new(this, width, height, backgroundColor); /// /// Initializes a new instance of the class @@ -140,7 +140,7 @@ public sealed class Image : Image /// The frames that will be owned by this image instance. internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable> frames) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, ValidateFramesAndGetSize(frames)) - => this.frames = new ImageFrameCollection(this, frames); + => this.frames = new(this, frames); /// protected override ImageFrameCollection NonGenericFrameCollection => this.Frames; @@ -344,7 +344,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].Clone(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// @@ -363,7 +363,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].CloneAs(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs index a6ed797d6d..cbf64e6a16 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs @@ -27,7 +27,7 @@ internal abstract class ManagedBufferBase : MemoryManager void* ptr = Unsafe.Add((void*)this.pinHandle.AddrOfPinnedObject(), elementIndex); // We should only pass pinnable:this, when GCHandle lifetime is managed by the MemoryManager instance. - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs index 02bdf0f48d..364aa05afc 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs @@ -19,7 +19,7 @@ internal class SharedArrayPoolBuffer : ManagedBufferBase, IRefCounted { this.lengthInBytes = lengthInElements * Unsafe.SizeOf(); this.Array = ArrayPool.Shared.Rent(this.lengthInBytes); - this.lifetimeGuard = new LifetimeGuard(this.Array); + this.lifetimeGuard = new(this.Array); } public byte[]? Array { get; private set; } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs index 24bf52b1f9..a505548d2a 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 UnmanagedBuffer(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 aa8bcd3859..d7212a41f3 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -214,14 +214,14 @@ internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedEx { lock (AllPools) { - AllPools.Add(new WeakReference(pool)); + AllPools.Add(new(pool)); // Invoke the timer callback more frequently, than trimSettings.TrimPeriodMilliseconds. // We are checking in the callback if enough time passed since the last trimming. If not, we do nothing. int period = settings.TrimPeriodMilliseconds / 4; if (trimTimer == null) { - trimTimer = new Timer(_ => TimerCallback(), null, period, period); + trimTimer = new(_ => TimerCallback(), null, period, period); } else if (settings.TrimPeriodMilliseconds < minTrimPeriodMilliseconds) { @@ -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 de09647261..5e7f386fd7 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs @@ -48,7 +48,7 @@ internal sealed unsafe class UnmanagedBuffer : MemoryManager, IRefCounted this.lifetimeGuard.AddRef(); void* pbData = Unsafe.Add(this.Pointer, elementIndex); - return new MemoryHandle(pbData, pinnable: this); + return new(pbData, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs index 6b31cadf4f..0fc5d2dea4 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs @@ -64,7 +64,7 @@ internal struct UnmanagedMemoryHandle : IEquatable public static UnmanagedMemoryHandle Allocate(int lengthInBytes) { IntPtr handle = AllocateHandle(lengthInBytes); - return new UnmanagedMemoryHandle(handle, lengthInBytes); + return new(handle, lengthInBytes); } private static IntPtr AllocateHandle(int lengthInBytes) @@ -84,7 +84,7 @@ internal struct UnmanagedMemoryHandle : IEquatable counter++; Interlocked.Increment(ref totalOomRetries); - Interlocked.CompareExchange(ref lowMemoryMonitor, new object(), null); + Interlocked.CompareExchange(ref lowMemoryMonitor, new(), null); Monitor.Enter(lowMemoryMonitor); Monitor.Wait(lowMemoryMonitor, millisecondsTimeout: 1); Monitor.Exit(lowMemoryMonitor); diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 621073a3db..203a5df695 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -67,8 +67,8 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato this.poolBufferSizeInBytes = poolBufferSizeInBytes; this.poolCapacity = (int)(maxPoolSizeInBytes / poolBufferSizeInBytes); this.trimSettings = trimSettings; - this.pool = new UniformUnmanagedMemoryPool(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); - this.nonPoolAllocator = new UnmanagedMemoryAllocator(unmanagedBufferSizeInBytes); + this.pool = new(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); + this.nonPoolAllocator = new(unmanagedBufferSizeInBytes); } // This delegate allows overriding the method returning the available system memory, @@ -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 da202aa596..daf1a79925 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/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index f0fa1438dd..b8ac5a5846 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -126,7 +126,7 @@ public static class Buffer2DExtensions internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height) where T : unmanaged => - new(buffer, new Rectangle(x, y, width, height)); + new(buffer, new(x, y, width, height)); /// /// Return a to the whole area of 'buffer' diff --git a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs index f4b257b587..c628bfd856 100644 --- a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs +++ b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs @@ -124,8 +124,8 @@ public readonly struct Buffer2DRegion int x = this.Rectangle.X + rectangle.X; int y = this.Rectangle.Y + rectangle.Y; - rectangle = new Rectangle(x, y, rectangle.Width, rectangle.Height); - return new Buffer2DRegion(this.Buffer, rectangle); + rectangle = new(x, y, rectangle.Width, rectangle.Height); + return new(this.Buffer, rectangle); } /// diff --git a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs index bc71751412..91525e5ade 100644 --- a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs +++ b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs @@ -24,7 +24,7 @@ internal sealed class ByteMemoryOwner : IMemoryOwner public ByteMemoryOwner(IMemoryOwner memoryOwner) { this.memoryOwner = memoryOwner; - this.memoryManager = new ByteMemoryManager(memoryOwner.Memory); + this.memoryManager = new(memoryOwner.Memory); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs index e2e933f3cc..d2e4d00fb0 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 MemoryGroupCursor(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 MemoryGroupCursor(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 MemoryGroupCursor(source); + MemoryGroupCursor trgCur = new MemoryGroupCursor(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 MemoryGroupCursor(source); + MemoryGroupCursor trgCur = new MemoryGroupCursor(target); while (position < source.TotalLength) { diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs index 76371e6744..a3f45c8cfd 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs @@ -31,7 +31,7 @@ internal class MemoryGroupView : IMemoryGroup for (int i = 0; i < owner.Count; i++) { - this.memoryWrappers[i] = new MemoryOwnerWrapper(this, i); + this.memoryWrappers[i] = new(this, i); } } @@ -79,7 +79,7 @@ internal class MemoryGroupView : IMemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs index 950e2a019e..783ab53a54 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs @@ -18,7 +18,7 @@ internal abstract partial class MemoryGroup : base(bufferLength, totalLength) { this.source = source; - this.View = new MemoryGroupView(this); + this.View = new(this); } public override int Count @@ -33,7 +33,7 @@ internal abstract partial class MemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public override MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs index 9da0139e6e..937a1a32b9 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs @@ -23,7 +23,7 @@ internal abstract partial class MemoryGroup { this.memoryOwners = memoryOwners; this.Swappable = swappable; - this.View = new MemoryGroupView(this); + this.View = new(this); this.memoryGroupSpanCache = MemoryGroupSpanCache.Create(memoryOwners); } @@ -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; } @@ -124,7 +124,7 @@ internal abstract partial class MemoryGroup public override void RecreateViewAfterSwap() { this.View.Invalidate(); - this.View = new MemoryGroupView(this); + this.View = new(this); } /// @@ -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(); @@ -212,7 +212,7 @@ internal abstract partial class MemoryGroup public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* pbData = Unsafe.Add(this.handle.Pointer, elementIndex); - return new MemoryHandle(pbData); + return new(pbData); } public override void Unpin() diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index 03c29a7231..8e4c881048 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); } @@ -260,14 +260,14 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable case SpanCacheMode.SinglePointer: { void* start = Unsafe.Add(this.memoryGroupSpanCache.SinglePointer, y * width); - return new Span(start, width); + return new(start, width); } case SpanCacheMode.MultiPointer: { this.GetMultiBufferPosition(y, width, out int bufferIdx, out int bufferStart); void* start = Unsafe.Add(this.memoryGroupSpanCache.MultiPointer[bufferIdx], bufferStart); - return new Span(start, width); + return new(start, width); } default: diff --git a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs index ff306e1e45..8178ca818d 100644 --- a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs +++ b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs @@ -41,7 +41,7 @@ public static class MemoryAllocatorExtensions memoryGroup = memoryAllocator.AllocateGroup(groupLength, width, options); } - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// @@ -109,7 +109,7 @@ public static class MemoryAllocatorExtensions groupLength, width * alignmentMultiplier, options); - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// diff --git a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs index 7f3163af3d..df845dd7a8 100644 --- a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs +++ b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs @@ -42,13 +42,13 @@ internal sealed unsafe class UnmanagedMemoryManager : MemoryManager /// public override Span GetSpan() { - return new Span(this.pointer, this.length); + return new(this.pointer, this.length); } /// public override MemoryHandle Pin(int elementIndex = 0) { - return new MemoryHandle(((T*)this.pointer) + elementIndex, pinnable: this); + return new(((T*)this.pointer) + elementIndex, pinnable: this); } /// diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index d2b88cbfff..a58e22869e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -71,7 +71,7 @@ internal static class ExifEncodedStringHelpers { // Little-endian BOM string text = Encoding.Unicode.GetString(textBuffer[2..]); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } @@ -79,14 +79,14 @@ internal static class ExifEncodedStringHelpers { // Big-endian BOM string text = Encoding.BigEndianUnicode.GetString(textBuffer[2..]); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } } { string text = GetEncoding(code, order).GetString(textBuffer); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index aa987bbe75..f67395165c 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -82,7 +82,7 @@ public sealed class ExifProfile : IDeepCloneable if (other.values != null) { - this.values = new List(other.Values.Count); + this.values = new(other.Values.Count); foreach (IExifValue value in other.Values) { diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index 4cd4b4aac9..c04a6f78e5 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -669,7 +669,7 @@ internal abstract class BaseExifReader uint numerator = this.ConvertToUInt32(buffer[..4]); uint denominator = this.ConvertToUInt32(buffer.Slice(4, 4)); - return new Rational(numerator, denominator, false); + return new(numerator, denominator, false); } private sbyte ConvertToSignedByte(ReadOnlySpan buffer) => unchecked((sbyte)buffer[0]); @@ -696,7 +696,7 @@ internal abstract class BaseExifReader int numerator = this.ConvertToInt32(buffer[..4]); int denominator = this.ConvertToInt32(buffer.Slice(4, 4)); - return new SignedRational(numerator, denominator, false); + return new(numerator, denominator, false); } private short ConvertToSignedShort(ReadOnlySpan buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs index 14b097f816..a7b9d44ae5 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs @@ -33,7 +33,7 @@ internal sealed class ExifEncodedString : ExifValue if (value is string stringValue) { - this.Value = new EncodedString(stringValue); + this.Value = new(stringValue); return true; } else if (value is byte[] buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs index c25f0f5dc1..e5c27f60a8 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs @@ -39,7 +39,7 @@ internal sealed class ExifRational : ExifValue if (signed.Numerator >= uint.MinValue && signed.Denominator >= uint.MinValue) { - this.Value = new Rational((uint)signed.Numerator, (uint)signed.Denominator); + this.Value = new((uint)signed.Numerator, (uint)signed.Denominator); } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs index e8b2006df1..4ae2850a12 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs @@ -38,7 +38,7 @@ internal sealed class ExifRationalArray : ExifArrayValue { if (signed.Numerator >= 0 && signed.Denominator >= 0) { - this.Value = [new Rational((uint)signed.Numerator, (uint)signed.Denominator)]; + this.Value = [new((uint)signed.Numerator, (uint)signed.Denominator)]; } return true; @@ -60,7 +60,7 @@ internal sealed class ExifRationalArray : ExifArrayValue for (int i = 0; i < signed.Length; i++) { SignedRational s = signed[i]; - unsigned[i] = new Rational((uint)s.Numerator, (uint)s.Denominator); + unsigned[i] = new((uint)s.Numerator, (uint)s.Denominator); } this.Value = unsigned; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 3cf66c0c16..3e061c9d84 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -18,19 +18,19 @@ 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(); } - return new IccOneDimensionalCurve(breakPoints, segments); + return new(breakPoints, segments); } /// @@ -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]]; @@ -63,7 +63,7 @@ internal sealed partial class IccDataReader } } - return new IccResponseCurve(type, xyzValues, response); + return new(type, xyzValues, response); } /// @@ -106,11 +106,11 @@ internal sealed partial class IccDataReader switch (type) { - case 0: return new IccParametricCurve(gamma); - case 1: return new IccParametricCurve(gamma, a, b); - case 2: return new IccParametricCurve(gamma, a, b, c); - case 3: return new IccParametricCurve(gamma, a, b, c, d); - case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f); + case 0: return new(gamma); + case 1: return new(gamma, a, b); + case 2: return new(gamma, a, b, c); + case 3: return new(gamma, a, b, c, d); + case 4: return new(gamma, a, b, c, d, e, f); default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}"); } } @@ -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; @@ -165,7 +165,7 @@ internal sealed partial class IccDataReader e = this.ReadSingle(); } - return new IccFormulaCurveElement(type, gamma, a, b, c, d, e); + return new(type, gamma, a, b, c, d, e); } /// @@ -175,13 +175,13 @@ 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(); } - return new IccSampledCurveElement(entries); + return new(entries); } /// @@ -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 f3ce6cd79c..ff65125c36 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -21,13 +21,13 @@ 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(); } - return new IccLut(values); + return new(values); } /// @@ -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) @@ -92,7 +92,7 @@ internal sealed partial class IccDataReader } } - return new IccClut(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); + return new(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); } /// @@ -126,7 +126,7 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChannelCount * 2); - return new IccClut(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); + return new(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); } /// @@ -158,6 +158,6 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChCount * 4); - return new IccClut(values, gridPointCount, IccClutDataType.Float, outChCount); + return new(values, gridPointCount, IccClutDataType.Float, outChCount); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index 5baa904048..bff5e31bc5 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -48,14 +48,14 @@ 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(); this.AddPadding(); } - return new IccCurveSetProcessElement(curves); + return new(curves); } /// @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// The read public IccMatrixProcessElement ReadMatrixProcessElement(int inChannelCount, int outChannelCount) { - return new IccMatrixProcessElement( + return new( this.ReadMatrix(inChannelCount, outChannelCount, true), this.ReadMatrix(outChannelCount, true)); } @@ -79,6 +79,6 @@ internal sealed partial class IccDataReader /// The read public IccClutProcessElement ReadClutProcessElement(int inChannelCount, int outChannelCount) { - return new IccClutProcessElement(this.ReadClut(inChannelCount, outChannelCount, true)); + return new(this.ReadClut(inChannelCount, outChannelCount, true)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index d5369e5fc4..ea969b7eca 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -18,7 +18,7 @@ internal sealed partial class IccDataReader { try { - return new DateTime( + return new( year: this.ReadUInt16(), month: this.ReadUInt16(), day: this.ReadUInt16(), @@ -45,7 +45,7 @@ internal sealed partial class IccDataReader int minor = (version >> 20) & 0x0F; int bugfix = (version >> 16) & 0x0F; - return new IccVersion(major, minor, bugfix); + return new(major, minor, bugfix); } /// @@ -54,7 +54,7 @@ internal sealed partial class IccDataReader /// the XYZ number public Vector3 ReadXyzNumber() { - return new Vector3( + return new( x: this.ReadFix16(), y: this.ReadFix16(), z: this.ReadFix16()); @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// the profile ID public IccProfileId ReadProfileId() { - return new IccProfileId( + return new( p1: this.ReadUInt32(), p2: this.ReadUInt32(), p3: this.ReadUInt32(), @@ -79,7 +79,7 @@ internal sealed partial class IccDataReader /// the position number public IccPositionNumber ReadPositionNumber() { - return new IccPositionNumber( + return new( offset: this.ReadUInt32(), size: this.ReadUInt32()); } @@ -90,7 +90,7 @@ internal sealed partial class IccDataReader /// the response number public IccResponseNumber ReadResponseNumber() { - return new IccResponseNumber( + return new( deviceCode: this.ReadUInt16(), measurementValue: this.ReadFix16()); } @@ -104,14 +104,14 @@ 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++) { deviceCoord[i] = this.ReadUInt16(); } - return new IccNamedColor(name, pcsCoord, deviceCoord); + return new(name, pcsCoord, deviceCoord); } /// @@ -122,13 +122,13 @@ 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(); - return new IccProfileDescription( + return new( manufacturer, model, attributes, @@ -158,7 +158,7 @@ internal sealed partial class IccDataReader /// the profile description public IccColorantTableEntry ReadColorantTableEntry() { - return new IccColorantTableEntry( + return new( name: this.ReadAsciiString(32), pcs1: this.ReadUInt16(), pcs2: this.ReadUInt16(), @@ -171,7 +171,7 @@ internal sealed partial class IccDataReader /// the screening channel public IccScreeningChannel ReadScreeningChannel() { - return new IccScreeningChannel( + return new( frequency: this.ReadFix16(), angle: this.ReadFix16(), spotShape: (IccScreeningSpotType)this.ReadInt32()); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 7a526ef1af..99dc3ce3c2 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 c1b22e82bf..591e08c6f4 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -130,7 +130,7 @@ internal sealed partial class IccDataReader public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size - return new IccUnknownTagDataEntry(this.ReadBytes(count)); + return new(this.ReadBytes(count)); } /// @@ -140,13 +140,13 @@ 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) { // The type is known and so are the values (they are constant) // channelCount should always be 3 but it doesn't really matter if it's not - return new IccChromaticityTagDataEntry(colorant); + return new(colorant); } else { @@ -157,7 +157,7 @@ internal sealed partial class IccDataReader values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; } - return new IccChromaticityTagDataEntry(values); + return new(values); } } @@ -169,7 +169,7 @@ internal sealed partial class IccDataReader { uint colorantCount = this.ReadUInt32(); byte[] number = this.ReadBytes((int)colorantCount); - return new IccColorantOrderTagDataEntry(number); + return new(number); } /// @@ -179,13 +179,13 @@ 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(); } - return new IccColorantTableTagDataEntry(cdata); + return new(cdata); } /// @@ -198,12 +198,12 @@ internal sealed partial class IccDataReader if (pointCount == 0) { - return new IccCurveTagDataEntry(); + return new(); } if (pointCount == 1) { - return new IccCurveTagDataEntry(this.ReadUFix8()); + return new(this.ReadUFix8()); } float[] cdata = new float[pointCount]; @@ -212,7 +212,7 @@ internal sealed partial class IccDataReader cdata[i] = this.ReadUInt16() / 65535f; } - return new IccCurveTagDataEntry(cdata); + return new(cdata); // TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768). } @@ -232,14 +232,14 @@ internal sealed partial class IccDataReader int length = (int)size - 12; byte[] cdata = this.ReadBytes(length); - return new IccDataTagDataEntry(cdata, ascii); + return new(cdata, ascii); } /// /// 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,13 +270,13 @@ 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); } - return new IccLut16TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -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,13 +305,13 @@ 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(); } - return new IccLut8TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -370,7 +370,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutAToBTagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -429,7 +429,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutBToATagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -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]; @@ -472,10 +472,10 @@ internal sealed partial class IccDataReader for (int i = 0; i < recordCount; i++) { this.currentIndex = (int)(start + offset[i]); - text[i] = new IccLocalizedString(culture[i], this.ReadUnicodeString((int)length[i])); + text[i] = new(culture[i], this.ReadUnicodeString((int)length[i])); } - return new IccMultiLocalizedUnicodeTagDataEntry(text); + return new(text); CultureInfo ReadCulture(string language, string country) { @@ -487,7 +487,7 @@ internal sealed partial class IccDataReader { try { - return new CultureInfo(language); + return new(language); } catch (CultureNotFoundException) { @@ -498,7 +498,7 @@ internal sealed partial class IccDataReader { try { - return new CultureInfo($"{language}-{country}"); + return new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -520,20 +520,20 @@ 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; elements[i] = this.ReadMultiProcessElement(); } - return new IccMultiProcessElementsTagDataEntry(elements); + return new(elements); } /// @@ -548,13 +548,13 @@ 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); } - return new IccNamedColor2TagDataEntry(vendorFlag, prefix, suffix, colors); + return new(vendorFlag, prefix, suffix, colors); } /// @@ -570,13 +570,13 @@ 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(); } - return new IccProfileSequenceDescTagDataEntry(description); + return new(description); } /// @@ -587,23 +587,23 @@ 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); IccProfileId id = this.ReadProfileId(); this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode); IccMultiLocalizedUnicodeTagDataEntry description = this.ReadMultiLocalizedUnicodeTagDataEntry(); - entries[i] = new IccProfileSequenceIdentifier(id, description.Texts); + entries[i] = new(id, description.Texts); } - return new IccProfileSequenceIdentifierTagDataEntry(entries); + return new(entries); } /// @@ -622,14 +622,14 @@ 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]); curves[i] = this.ReadResponseCurve(channelCount); } - return new IccResponseCurveSet16TagDataEntry(curves); + return new(curves); } /// @@ -646,7 +646,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadFix16() / 256f; } - return new IccFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -676,7 +676,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUFix16(); } - return new IccUFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -693,7 +693,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt16(); } - return new IccUInt16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -710,7 +710,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt32(); } - return new IccUInt32ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -727,7 +727,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt64(); } - return new IccUInt64ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -740,7 +740,7 @@ internal sealed partial class IccDataReader int count = (int)size - 8; // 8 is the tag header size byte[] adata = this.ReadBytes(count); - return new IccUInt8ArrayTagDataEntry(adata); + return new(adata); } /// @@ -760,13 +760,13 @@ 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(); } - return new IccXyzTagDataEntry(arrayData); + return new(arrayData); } /// @@ -801,7 +801,7 @@ internal sealed partial class IccDataReader this.AddIndex(1); // Null terminator } - return new IccTextDescriptionTagDataEntry( + return new( asciiValue, unicodeValue, scriptcodeValue, @@ -830,7 +830,7 @@ internal sealed partial class IccDataReader uint crd3Count = this.ReadUInt32(); string crd3Name = this.ReadAsciiString((int)crd3Count); - return new IccCrdInfoTagDataEntry(productName, crd0Name, crd1Name, crd2Name, crd3Name); + return new(productName, crd0Name, crd1Name, crd2Name, crd3Name); } /// @@ -839,15 +839,15 @@ 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(); } - return new IccScreeningTagDataEntry(flags, channels); + return new(flags, channels); } /// @@ -876,6 +876,6 @@ internal sealed partial class IccDataReader int descriptionLength = (int)(size - 8 - dataSize); // 8 is the tag header size string description = this.ReadAsciiString(descriptionLength); - return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description); + return new(ucrCurve, bgCurve, description); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs index db199b4381..8ad81415d9 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs @@ -111,9 +111,9 @@ internal sealed partial class IccDataWriter + this.WriteInt64((long)value.DeviceAttributes) + this.WriteUInt32((uint)value.TechnologyInformation) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceManufacturerInfo)) + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceManufacturerInfo)) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceModelInfo)); + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceModelInfo)); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 6019a0bff7..1233beda76 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -20,7 +20,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)this.dataStream.Position; int count = this.WriteTagDataEntry(data); this.WritePadding(); - table = new IccTagTableEntry(data.TagSignature, offset, (uint)count); + table = new(data.TagSignature, offset, (uint)count); return count; } @@ -546,7 +546,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteMultiProcessElement(value.Data[i]); count += this.WritePadding(); - posTable[i] = new IccPositionNumber(offset, (uint)size); + posTable[i] = new(offset, (uint)size); count += size; } @@ -634,7 +634,7 @@ internal sealed partial class IccDataWriter int size = this.WriteProfileId(sequenceIdentifier.Id); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description)); size += this.WritePadding(); - table[i] = new IccPositionNumber(offset, (uint)size); + table[i] = new(offset, (uint)size); count += size; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs index ce53325442..941d3bb658 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs @@ -23,7 +23,7 @@ internal sealed partial class IccDataWriter : IDisposable /// public IccDataWriter() { - this.dataStream = new MemoryStream(); + this.dataStream = new(); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index 392ccb3062..b33c98432c 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -186,7 +186,7 @@ public sealed class IccProfile : IDeepCloneable if (this.data is null) { - this.header = new IccProfileHeader(); + this.header = new(); return; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 074712d302..da35665145 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -22,7 +22,7 @@ internal sealed class IccReader IccProfileHeader header = ReadHeader(reader); IccTagDataEntry[] tagData = ReadTagData(reader); - return new IccProfile(header, tagData); + return new(header, tagData); } /// @@ -57,7 +57,7 @@ internal sealed class IccReader { reader.SetIndex(0); - return new IccProfileHeader + return new() { Size = reader.ReadUInt32(), CmmType = reader.ReadAsciiString(4), @@ -128,7 +128,7 @@ internal sealed class IccReader // Exclude entries that have nonsense values and could cause exceptions further on if (tagOffset < reader.DataLength && tagSize < reader.DataLength - 128) { - table.Add(new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize)); + table.Add(new((IccProfileTag)tagSignature, tagOffset, tagSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs index 5e73e2dd00..8e0b4ae6d0 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs @@ -77,7 +77,7 @@ internal sealed class IccWriter writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry); foreach (IccTagDataEntry item in group) { - table.Add(new IccTagTableEntry(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); + table.Add(new(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index 9ddd0ce13d..b8c29ae096 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -147,7 +147,7 @@ internal sealed class IccLut16TagDataEntry : IccTagDataEntry, IEquatable= 0x41 && p4 <= 0x5A) { string culture = new(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); - return new CultureInfo(culture); + return new(culture); } return null; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 85c23d1743..8d13d38628 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -185,7 +185,7 @@ public sealed class IptcProfile : IDeepCloneable } } - this.values.Add(new IptcValue(tag, encoding, value, strict)); + this.values.Add(new(tag, encoding, value, strict)); } /// @@ -322,7 +322,7 @@ public sealed class IptcProfile : IDeepCloneable { byte[] iptcData = new byte[byteCount]; Buffer.BlockCopy(this.Data, offset, iptcData, 0, (int)byteCount); - this.values.Add(new IptcValue(tag, iptcData, false)); + this.values.Add(new(tag, iptcData, false)); } offset += (int)byteCount; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 78f7f6de08..f0b1b717ab 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -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/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index ca358be31c..63630dd55e 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -179,7 +179,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(backdrop.Y, source.Y); float cb = OverlayValueFunction(backdrop.Z, source.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// @@ -208,7 +208,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(source.Y, backdrop.Y); float cb = OverlayValueFunction(source.Z, backdrop.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs index 1444b344b6..00be93b22b 100644 --- a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs +++ b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs @@ -81,7 +81,7 @@ public readonly struct PixelComponentInfo sum += p; } - return new PixelComponentInfo(count, bitsPerPixel - sum, precisionData1, precisionData2); + return new(count, bitsPerPixel - sum, precisionData1, precisionData2); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index 87055bf22d..e81b3e66f4 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs @@ -28,7 +28,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVectorThe y-component /// The z-component public Bgr565(float x, float y, float z) - : this(new Vector3(x, y, z)) + : this(new(x, y, z)) { } @@ -84,7 +84,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector3(source.X, source.Y, source.Z)) }; + public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y, source.Z)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index 55971210c3..d6ffa47237 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs @@ -22,7 +22,7 @@ public partial struct Bgra4444 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra4444(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index 4c94dea5f1..45f013fb1b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs @@ -23,7 +23,7 @@ public partial struct Bgra5551 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra5551(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index 680a7ee0bd..b4479fd509 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs @@ -25,7 +25,7 @@ public partial struct Byte4 : IPixel, IPackedVector /// The z-component /// The w-component public Byte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 888d992d8c..3ef711d6a1 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -55,7 +55,7 @@ public partial struct HalfSingle : IPixel, IPackedVector { float single = this.ToSingle() + 1F; single /= 2F; - return new Vector4(single, 0, 0, 1F); + return new(single, 0, 0, 1F); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index d0b57d788f..254e9290d8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs @@ -22,7 +22,7 @@ public partial struct HalfVector4 : IPixel, IPackedVector /// The z-component. /// The w-component. public HalfVector4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 64a22060c0..faad37ab5d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -64,7 +64,7 @@ public partial struct L16 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float scaled = this.PackedValue / Max; - return new Vector4(scaled, scaled, scaled, 1f); + return new(scaled, scaled, scaled, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index cf8646cfa0..1ef5951feb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -66,7 +66,7 @@ public partial struct L8 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.PackedValue / 255f; - return new Vector4(rgb, rgb, rgb, 1f); + return new(rgb, rgb, rgb, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index 026d0c299d..b1149dc3eb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -93,7 +93,7 @@ public partial struct La16 : IPixel, IPackedVector { const float max = 255f; float rgb = this.L / max; - return new Vector4(rgb, rgb, rgb, this.A / max); + return new(rgb, rgb, rgb, this.A / max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 0ddcf16a1f..ec2c38e3ea 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -90,7 +90,7 @@ public partial struct La32 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.L / Max; - return new Vector4(rgb, rgb, rgb, this.A / Max); + return new(rgb, rgb, rgb, this.A / Max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index 9551d7242f..c4b6bf8187 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -24,7 +24,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVectorThe x-component. /// The y-component. public NormalizedByte2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -70,7 +70,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector @@ -98,7 +98,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 1fb386725a..380465f4e2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs @@ -27,7 +27,7 @@ public partial struct NormalizedByte4 : IPixel, IPackedVectorThe z-component. /// The w-component. public NormalizedByte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index a17868f6df..edd2271ec0 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -26,7 +26,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// The x-component. /// The y-component. public NormalizedShort2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -72,7 +72,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2f; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -100,7 +100,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index 2b33fec27a..2c30a0a569 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs @@ -28,7 +28,7 @@ public partial struct NormalizedShort4 : IPixel, IPackedVector /// The z-component. /// The w-component. public NormalizedShort4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index e7c97269e1..89b2a65b2e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs @@ -22,7 +22,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// The x-component /// The y-component public Rg32(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -90,7 +90,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index b03a54c585..8eaabe02e9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -62,7 +62,7 @@ public partial struct Rgb24 : IPixel /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Rgb24(Rgb color) - => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); + => FromScaledVector4(new(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index cdee22964d..a022476fd5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs @@ -25,7 +25,7 @@ public partial struct Rgba1010102 : IPixel, IPackedVector /// The z-component /// The w-component public Rgba1010102(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 507d6d70b6..f618b9a2f3 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -187,7 +187,7 @@ public partial struct Rgba32 : IPixel, IPackedVector /// The instance of to convert. /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); + public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. @@ -444,6 +444,6 @@ public partial struct Rgba32 : IPixel, IPackedVector char g = hex[1]; char r = hex[0]; - return new string(new[] { r, r, g, g, b, b, a, a }); + return new(new[] { r, r, g, g, b, b, a, a }); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 403d3fbea3..c76f870477 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -29,7 +29,7 @@ public partial struct Short2 : IPixel, IPackedVector /// The x-component. /// The y-component. public Short2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -75,7 +75,7 @@ public partial struct Short2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += new Vector2(32767f); scaled /= 65534F; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -103,7 +103,7 @@ public partial struct Short2 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index b6cece2bef..c657263c0e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs @@ -31,7 +31,7 @@ public partial struct Short4 : IPixel, IPackedVector /// The z-component. /// The w-component. public Short4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs index 559fcdde08..7eb95569df 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs @@ -181,11 +181,11 @@ public partial struct ColorMatrix float m41, float m42, float m43, float m44, float m51, float m52, float m53, float m54) { - this.X = new Vector4(m11, m12, m13, m14); - this.Y = new Vector4(m21, m22, m23, m24); - this.Z = new Vector4(m31, m32, m33, m34); - this.W = new Vector4(m41, m42, m43, m44); - this.V = new Vector4(m51, m52, m53, m54); + this.X = new(m11, m12, m13, m14); + this.Y = new(m21, m22, m23, m24); + this.Z = new(m31, m32, m33, m34); + this.W = new(m41, m42, m43, m44); + this.V = new(m51, m52, m53, m54); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Primitives/Complex64.cs b/src/ImageSharp/Primitives/Complex64.cs index 4baedd9bae..2a16df969c 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 . @@ -53,7 +53,7 @@ internal readonly struct Complex64 : IEquatable [MethodImpl(InliningOptions.ShortMethod)] public static ComplexVector4 operator *(Complex64 value, Vector4 vector) { - return new ComplexVector4 { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; + return new() { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; } /// @@ -67,7 +67,7 @@ internal readonly struct Complex64 : IEquatable { Vector4 real = (value.Real * vector.Real) - (value.Imaginary * vector.Imaginary); Vector4 imaginary = (value.Real * vector.Imaginary) + (value.Imaginary * vector.Real); - return new ComplexVector4 { Real = real, Imaginary = imaginary }; + return new() { Real = real, Imaginary = imaginary }; } /// diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index 9849e0211f..b39f306cbf 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -36,7 +36,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = columns * rows; this.Data = new T[this.Columns * this.Rows]; } @@ -56,7 +56,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -84,7 +84,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -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/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index 69139ac9c4..0b3380ca97 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -133,22 +133,22 @@ internal readonly struct LongRational : IEquatable { if (value == 0.0) { - return new LongRational(0, 1); + return new(0, 1); } if (double.IsNaN(value)) { - return new LongRational(0, 0); + return new(0, 0); } if (double.IsPositiveInfinity(value)) { - return new LongRational(1, 0); + return new(1, 0); } if (double.IsNegativeInfinity(value)) { - return new LongRational(-1, 0); + return new(-1, 0); } long numerator = 1; @@ -208,14 +208,14 @@ internal readonly struct LongRational : IEquatable if (this.Numerator == this.Denominator) { - return new LongRational(1, 1); + return new(1, 1); } long gcd = GreatestCommonDivisor(Math.Abs(this.Numerator), Math.Abs(this.Denominator)); if (gcd > 1) { - return new LongRational(this.Numerator / gcd, this.Denominator / gcd); + return new(this.Numerator / gcd, this.Denominator / gcd); } return this; diff --git a/src/ImageSharp/Primitives/Point.cs b/src/ImageSharp/Primitives/Point.cs index 8ace7ffacf..5eae087ed9 100644 --- a/src/ImageSharp/Primitives/Point.cs +++ b/src/ImageSharp/Primitives/Point.cs @@ -232,7 +232,7 @@ public struct Point : IEquatable /// The transformation matrix used. /// The transformed . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new Vector2(point.X, point.Y), matrix)); + public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new(point.X, point.Y), matrix)); /// /// Deconstructs this point into two integers. diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index e2ae5071ef..a3cb89cf01 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -214,7 +214,7 @@ public struct Rectangle : IEquatable if (x2 >= x1 && y2 >= y1) { - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -245,7 +245,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)MathF.Ceiling(rectangle.X), (int)MathF.Ceiling(rectangle.Y), (int)MathF.Ceiling(rectangle.Width), @@ -261,9 +261,9 @@ public struct Rectangle : IEquatable /// A transformed rectangle. public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix) { - PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = Point.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = Point.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -276,7 +276,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, @@ -294,7 +294,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)MathF.Round(rectangle.X), (int)MathF.Round(rectangle.Y), (int)MathF.Round(rectangle.Width), @@ -316,7 +316,7 @@ public struct Rectangle : IEquatable int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Bottom, b.Bottom); - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/RectangleF.cs b/src/ImageSharp/Primitives/RectangleF.cs index 68add77d09..9a7a97a13c 100644 --- a/src/ImageSharp/Primitives/RectangleF.cs +++ b/src/ImageSharp/Primitives/RectangleF.cs @@ -207,7 +207,7 @@ public struct RectangleF : IEquatable if (x2 >= x1 && y2 >= y1) { - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -236,9 +236,9 @@ public struct RectangleF : IEquatable /// A transformed . public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix) { - PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = PointF.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = PointF.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -255,7 +255,7 @@ public struct RectangleF : IEquatable float y1 = MathF.Min(a.Y, b.Y); float y2 = MathF.Max(a.Bottom, b.Bottom); - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index d56ea825e6..2b62b4c3e7 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; @@ -117,7 +117,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value) { - return new SignedRational(value, false); + return new(value, false); } /// @@ -130,7 +130,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value, bool bestPrecision) { - return new SignedRational(value, bestPrecision); + return new(value, bestPrecision); } /// @@ -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 945b680daa..5ceab493f9 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,9 +237,9 @@ 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(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(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 36cf9eb8ef..88c3b8319a 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -191,9 +191,9 @@ 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(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(v.X, v.Y); } /// diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index f572dd658f..9a76269b3b 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -68,7 +68,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfWidth public static ValueSize PercentageOfWidth(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfWidth); + return new(percentage, ValueSizeType.PercentageOfWidth); } /// @@ -78,7 +78,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfHeight public static ValueSize PercentageOfHeight(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfHeight); + return new(percentage, ValueSizeType.PercentageOfHeight); } /// @@ -88,7 +88,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type Absolute. public static ValueSize Absolute(float value) { - return new ValueSize(value, ValueSizeType.Absolute); + return new(value, ValueSizeType.Absolute); } /// diff --git a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs index d7f4ba3594..6af61338d1 100644 --- a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs @@ -16,7 +16,7 @@ public static class HistogramEqualizationExtensions /// The current image processing context. /// The . public static IImageProcessingContext HistogramEqualization(this IImageProcessingContext source) => - HistogramEqualization(source, new HistogramEqualizationOptions()); + HistogramEqualization(source, new()); /// /// Equalizes the histogram of an image to increases the contrast. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs index 3025806d4f..256bac64e5 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs @@ -19,7 +19,7 @@ public static class CropExtensions /// The target image height. /// The . public static IImageProcessingContext Crop(this IImageProcessingContext source, int width, int height) => - Crop(source, new Rectangle(0, 0, width, height)); + Crop(source, new(0, 0, width, height)); /// /// Crops an image to the given rectangle. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs index b6db0172dc..cca3e42412 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs @@ -30,10 +30,10 @@ 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)), + Size = new(Math.Max(width, size.Width), Math.Max(height, size.Height)), Mode = ResizeMode.BoxPad, Sampler = KnownResamplers.NearestNeighbor, PadColor = color diff --git a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs index 01f296d096..3ac9553d4d 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs @@ -77,7 +77,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, IResampler sampler, bool compand) - => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); + => Resize(source, size.Width, size.Height, sampler, new(0, 0, size.Width, size.Height), compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -90,7 +90,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler, bool compand) - => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); + => Resize(source, width, height, sampler, new(0, 0, width, height), compand); /// /// Resizes an image to the given width and height with the given sampler and @@ -118,9 +118,9 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, @@ -151,9 +151,9 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index 60f90b10f2..dedde797bd 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -34,7 +34,7 @@ public static class TransformExtensions this IImageProcessingContext source, AffineTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs an affine transform of an image using the specified sampling algorithm. @@ -96,7 +96,7 @@ public static class TransformExtensions this IImageProcessingContext source, ProjectiveTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs a projective transform of an image using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index b312287b52..0b40fa945d 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, @@ -221,7 +221,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -246,7 +246,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float contrast = (-.5F * amount) + .5F; - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -338,7 +338,7 @@ public static class KnownFilterMatrices // The matrix is set up to preserve the luminance of the image. // See http://graficaobscura.com/matrix/index.html // Number are taken from https://msdn.microsoft.com/en-us/library/jj192162(v=vs.85).aspx - return new ColorMatrix + return new() { M11 = .213F + (cosRadian * .787F) - (sinRadian * .213F), M21 = .715F - (cosRadian * .715F) - (sinRadian * .715F), @@ -367,7 +367,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float invert = 1F - (2F * amount); - return new ColorMatrix + return new() { M11 = invert, M22 = invert, @@ -389,7 +389,7 @@ public static class KnownFilterMatrices Guard.MustBeBetweenOrEqualTo(amount, 0, 1, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -443,7 +443,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); amount--; - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -467,7 +467,7 @@ public static class KnownFilterMatrices amount = 1F - amount; // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = .393F + (.607F * amount), M21 = .769F - (.769F * amount), diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index bc34f759a0..2e675cdd47 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -158,7 +158,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor[] destinationFrames = new ImageFrame[source.Frames.Count]; for (int i = 0; i < destinationFrames.Length; i++) { - destinationFrames[i] = new ImageFrame( + destinationFrames[i] = new( this.Configuration, destinationSize.Width, destinationSize.Height, @@ -166,7 +166,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor(this.Configuration, source.Metadata.DeepClone(), destinationFrames); + return new(this.Configuration, source.Metadata.DeepClone(), destinationFrames); } private void CheckFrameCount(Image a, Image b) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index ff3b30e9c1..96daca47ab 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 Convolution2PassProcessor(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 2a4a1abf02..08e8425bbf 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 Convolution2DState(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 Convolution2DState(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/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index 6f5388e22b..b3dae6baac 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -22,8 +22,8 @@ internal readonly ref struct Convolution2DState KernelSamplingMap map) { // We check the kernels are the same size upstream. - this.KernelY = new ReadOnlyKernel(kernelY); - this.KernelX = new ReadOnlyKernel(kernelX); + this.KernelY = new(kernelY); + this.KernelX = new(kernelX); this.kernelHeight = (uint)kernelY.Rows; this.kernelWidth = (uint)kernelY.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index 6663c45021..20e95d0582 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -20,7 +20,7 @@ internal readonly ref struct ConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new ReadOnlyKernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = (uint)kernel.Rows; this.kernelWidth = (uint)kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index 5af4360442..fbf576c23a 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 Convolution2DProcessor( 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 7efcbf3a6c..cd9f4d7aba 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 DenseMatrix((int)length); kernel.Fill(-1); int mid = (int)(length / 2); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs index 137334c29e..5b2c903baf 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs @@ -21,7 +21,7 @@ internal readonly ref struct MedianConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new Kernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = kernel.Rows; this.kernelWidth = kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index ca2cabab55..64fd40f153 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -153,7 +153,7 @@ internal readonly struct MedianRowOperation : IRowOperation // Taking the W value from the source pixels, where the middle index in the kernelSpan is by definition the resulting pixel. // This will preserve the alpha value. - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -176,6 +176,6 @@ internal readonly struct MedianRowOperation : IRowOperation zChannel.Sort(); wChannel.Sort(); - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 565a5746d1..6832e24982 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 @@ -99,7 +99,7 @@ internal static class BokehBlurKernelDataProvider NormalizeKernels(kernels, kernelParameters); // Store them in the cache for future use - info = new BokehBlurKernelData(kernelParameters, kernels); + info = new(kernelParameters, kernels); Cache.TryAdd(parameters, info); } @@ -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; @@ -167,7 +167,7 @@ internal static class BokehBlurKernelDataProvider value *= value; // Fill in the complex kernel values - Unsafe.Add(ref baseRef, (uint)i) = new Complex64( + Unsafe.Add(ref baseRef, (uint)i) = new( MathF.Exp(-a * value) * MathF.Cos(b * value), MathF.Exp(-a * value) * MathF.Sin(b * value)); } diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs index 57d8ef59a6..d58f9020c3 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs @@ -65,7 +65,7 @@ public readonly partial struct ErrorDither { 0, 1 / divisor, 0, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateBurks() @@ -79,7 +79,7 @@ public readonly partial struct ErrorDither { 2 / divisor, 4 / divisor, 8 / divisor, 4 / divisor, 2 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateFloydSteinberg() @@ -93,7 +93,7 @@ public readonly partial struct ErrorDither { 3 / divisor, 5 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateJarvisJudiceNinke() @@ -108,7 +108,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 3 / divisor, 5 / divisor, 3 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra2() @@ -122,7 +122,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 3 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra3() @@ -137,7 +137,7 @@ public readonly partial struct ErrorDither { 0, 2 / divisor, 3 / divisor, 2 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierraLite() @@ -151,7 +151,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 1 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStevensonArce() @@ -167,7 +167,7 @@ public readonly partial struct ErrorDither { 5 / divisor, 0, 12 / divisor, 0, 12 / divisor, 0, 5 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStucki() @@ -182,6 +182,6 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 4 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index d1f46c7441..d4dd10b739 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 DenseMatrix((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 7f8b347243..9fa331d7b7 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 DenseMatrix((int)length); uint i = 0; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 0d4680e21f..2f4a0a9f07 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -37,7 +37,7 @@ internal sealed class PaletteDitherProcessor : ImageProcessor this.paletteOwner = this.Configuration.MemoryAllocator.Allocate(sourcePalette.Length); Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span); - this.ditherProcessor = new DitherProcessor( + this.ditherProcessor = new( this.Configuration, this.paletteOwner.Memory, definition.DitherScale); diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index f811bae0f7..5e491c1ee6 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -174,7 +174,7 @@ internal class OilPaintingProcessor : ImageProcessor float green = greenBinSpan[maxIndex] / maxIntensity; float alpha = sourceRowVector4Span[x].W; - targetRowVector4Span[x] = new Vector4(red, green, blue, alpha); + targetRowVector4Span[x] = new(red, green, blue, alpha); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs index 06cfa49b3d..f1014c0df6 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -37,7 +37,7 @@ internal sealed class PixelRowDelegateProcessor : IImageProcessor public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixel : unmanaged, IPixel => new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index d38ffc801e..a3aba4cfc4 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -96,7 +96,7 @@ internal sealed class PixelRowDelegateProcessor : ImageProces PixelOperations.Instance.ToVector4(this.configuration, rowSpan, span, this.modifiers); // Run the user defined pixel shader to the current row of pixels - Unsafe.AsRef(in this.rowProcessor).Invoke(span, new Point(this.startX, y)); + Unsafe.AsRef(in this.rowProcessor).Invoke(span, new(this.startX, y)); PixelOperations.Instance.FromVector4Destructive(this.configuration, span, rowSpan, this.modifiers); } diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs index 6786eb5f50..a54a7bfd25 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -38,7 +38,7 @@ internal sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 78085eaab5..e911249586 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -81,7 +81,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz RowIntervalOperation operation = new(cdfData, tileYStartPositions, tileWidth, tileHeight, tileCount, halfTileWidth, luminanceLevels, source.PixelBuffer); ParallelRowIterator.IterateRowIntervals( this.Configuration, - new Rectangle(0, 0, sourceWidth, tileYStartPositions.Count), + new(0, 0, sourceWidth, tileYStartPositions.Count), in operation); // Fix left column @@ -191,7 +191,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } tileY++; @@ -243,7 +243,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX + 1, cdfY, tileX, tileWidth, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } } @@ -432,7 +432,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz this.tileHeight, this.luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } @@ -515,7 +515,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz ParallelRowIterator.IterateRowIntervals( this.configuration, - new Rectangle(0, 0, this.sourceWidth, this.tileYStartPositions.Count), + new(0, 0, this.sourceWidth, this.tileYStartPositions.Count), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index 606789af96..f104ee34a2 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -214,7 +214,7 @@ internal class AutoLevelProcessor : HistogramEqualizationProcessor.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 3ab8f7431e..b159847bbf 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class GlobalHistogramEqualizationProcessor : HistogramEqualizat Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); } PixelOperations.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 0a8690ba70..3584f2954a 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 : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (1 - (.95F * (distance / this.maxDistance))), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index b08cd898e8..b24ed7ed54 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -113,7 +113,7 @@ internal class VignetteProcessor : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (.9F * (distance / this.maxDistance)), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs index 0a1032bf0d..9a46a9883a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs @@ -16,7 +16,7 @@ public class OctreeQuantizer : IQuantizer /// using the default . /// public OctreeQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 07596b68a8..25d3e74168 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -44,7 +44,7 @@ public struct OctreeQuantizer : IQuantizer this.maxColors = this.Options.MaxColors; this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); - this.octree = new Octree(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); + this.octree = new(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.pixelMap = default; this.palette = default; @@ -547,14 +547,14 @@ public struct OctreeQuantizer : IQuantizer Vector4 vector = Vector4.Clamp( (sum + offset) / this.PixelCount, Vector4.Zero, - new Vector4(255)); + new(255)); if (vector.W < octree.transparencyThreshold255) { vector = Vector4.Zero; } - palette[paletteIndex] = TPixel.FromRgba32(new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); + palette[paletteIndex] = TPixel.FromRgba32(new((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); this.PaletteIndex = paletteIndex++; } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index a49691515a..91d086fc68 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -19,7 +19,7 @@ public class PaletteQuantizer : IQuantizer /// /// The color palette. public PaletteQuantizer(ReadOnlyMemory palette) - : this(palette, new QuantizerOptions()) + : this(palette, new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs index fa1763367c..b1dace40b4 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs @@ -12,7 +12,7 @@ public sealed class WebSafePaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WebSafePaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs index cd7b80e81d..02c217c36e 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs @@ -13,7 +13,7 @@ public sealed class WernerPaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WernerPaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs index 86d798d965..cda78c7d1a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs @@ -15,7 +15,7 @@ public class WuQuantizer : IQuantizer /// using the default . /// public WuQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index 03d6ac0da6..cb70204866 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -513,7 +513,7 @@ internal struct WuQuantizer : IQuantizer continue; } - vector = new Vector4(half.R, half.G, half.B, half.A); + vector = new(half.R, half.G, half.B, half.A); temp += Vector4.Dot(vector, vector) / half.Weight; if (temp > max) diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 1d82dd12ad..5465b502bf 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -50,7 +50,7 @@ internal class CropProcessor : TransformProcessor ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(this.Configuration).MultiplyMinimumPixelsPerTask(4); - var operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); + RowOperation operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( bounds, diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index b3919e5844..6115ded03e 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < destinationRowSpan.Length; x++) { - Vector2 point = Vector2.Transform(new Vector2(x, y), this.matrix); + Vector2 point = Vector2.Transform(new(x, y), this.matrix); int px = (int)MathF.Round(point.X); int py = (int)MathF.Round(point.Y); @@ -204,7 +204,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < span.Length; x++) { - Vector2 point = Vector2.Transform(new Vector2(x, y), matrix); + Vector2 point = Vector2.Transform(new(x, y), matrix); float pY = point.Y; float pX = point.X; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs index d90f948b6f..e9e2849ae4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs @@ -72,7 +72,7 @@ internal static class ResizeHelper // case ResizeMode.Stretch: default: - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(0, 0, Sanitize(width), Sanitize(height))); + return (new(Sanitize(width), Sanitize(height)), new(0, 0, Sanitize(width), Sanitize(height))); } } @@ -143,7 +143,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } // Switch to pad mode to downscale and calculate from there. @@ -253,7 +253,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMaxRectangle( @@ -282,7 +282,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( @@ -298,7 +298,7 @@ internal static class ResizeHelper // Don't upscale if (width > sourceWidth || height > sourceHeight) { - return (new Size(sourceWidth, sourceHeight), new Rectangle(0, 0, sourceWidth, sourceHeight)); + return (new(sourceWidth, sourceHeight), new(0, 0, sourceWidth, sourceHeight)); } // Find the shortest distance to go. @@ -330,7 +330,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculatePadRectangle( @@ -398,7 +398,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateManualRectangle( @@ -419,7 +419,7 @@ internal static class ResizeHelper int targetHeight = targetRectangle.Height > 0 ? targetRectangle.Height : height; // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } [DoesNotReturn] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index c1907bb520..fb4d319883 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -255,7 +255,7 @@ internal partial class ResizeKernelMap : IDisposable ref float rowReference = ref MemoryMarshal.GetReference(rowSpan); float* rowPtr = (float*)Unsafe.AsPointer(ref rowReference); - return new ResizeKernel(left, rowPtr, length); + return new(left, rowPtr, length); } [Conditional("DEBUG")] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index cfc30edc0f..a2bd29116d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -81,7 +81,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling return; } - var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); + Rectangle interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); if (sampler is NearestNeighborResampler) { @@ -110,13 +110,13 @@ internal class ResizeProcessor : TransformProcessor, IResampling // Since all image frame dimensions have to be the same we can calculate // the kernel maps and reuse for all frames. MemoryAllocator allocator = configuration.MemoryAllocator; - using var horizontalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap horizontalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Width, sourceRectangle.Width, allocator); - using var verticalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap verticalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Height, sourceRectangle.Height, @@ -158,7 +158,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling float widthFactor = sourceRectangle.Width / (float)destinationRectangle.Width; float heightFactor = sourceRectangle.Height / (float)destinationRectangle.Height; - var operation = new NNRowOperation( + NNRowOperation operation = new NNRowOperation( sourceRectangle, destinationRectangle, interest, @@ -208,7 +208,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling // To reintroduce parallel processing, we would launch multiple workers // for different row intervals of the image. - using var worker = new ResizeWorker( + using ResizeWorker worker = new ResizeWorker( configuration, sourceRegion, conversionModifiers, @@ -218,7 +218,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling destinationRectangle.Location); worker.Initialize(); - var workingInterval = new RowInterval(interest.Top, interest.Bottom); + RowInterval workingInterval = new RowInterval(interest.Top, interest.Bottom); worker.FillDestinationPixels(workingInterval, destination.PixelBuffer); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index cce27a401c..3da3fcb6ac 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -89,7 +89,7 @@ internal sealed class ResizeWorker : IDisposable this.tempRowBuffer = configuration.MemoryAllocator.Allocate(this.sourceRectangle.Width); this.tempColumnBuffer = configuration.MemoryAllocator.Allocate(targetWorkingRect.Width); - this.currentWindow = new RowInterval(0, this.workerHeight); + this.currentWindow = new(0, this.workerHeight); } public void Dispose() @@ -158,7 +158,7 @@ internal sealed class ResizeWorker : IDisposable 0, this.windowBandHeight); - this.currentWindow = new RowInterval(minY, maxY); + this.currentWindow = new(minY, maxY); // Calculate the remainder: this.CalculateFirstPassValues(this.currentWindow.Slice(this.windowBandHeight)); diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 47b3250b87..1813be2fda 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -407,10 +407,10 @@ internal static class TransformUtils float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) // Apply the offset relative to the scale - SizeF offsetSize = usePixelSpace ? new SizeF(scaleX, scaleY) : SizeF.Empty; + SizeF offsetSize = usePixelSpace ? new(scaleX, scaleY) : SizeF.Empty; // Subtract the offset size to translate to the appropriate space (pixel or coordinate). - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the correct space. return Size.Ceiling(ConstrainSize(bounds) + offsetSize); @@ -459,7 +459,7 @@ internal static class TransformUtils } // Subtract the offset size to translate to the pixel space. - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the coordinate space. return Size.Ceiling((constrain ? ConstrainSize(bounds) : bounds.Size) + offsetSize); @@ -485,10 +485,10 @@ internal static class TransformUtils return false; } - Vector2 tl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Top), matrix); - Vector2 tr = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Top), matrix); - Vector2 bl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Bottom), matrix); - Vector2 br = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Bottom), matrix); + Vector2 tl = Vector2.Transform(new(rectangle.Left, rectangle.Top), matrix); + Vector2 tr = Vector2.Transform(new(rectangle.Right, rectangle.Top), matrix); + Vector2 bl = Vector2.Transform(new(rectangle.Left, rectangle.Bottom), matrix); + Vector2 br = Vector2.Transform(new(rectangle.Right, rectangle.Bottom), matrix); bounds = GetBoundingRectangle(tl, tr, bl, br); return true; @@ -540,7 +540,7 @@ internal static class TransformUtils width = rectangle.Width; } - return new Size(width, height); + return new(width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index 82b897ea5d..3211965821 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -69,7 +69,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -87,7 +87,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder PrependRotationRadians(float radians, Vector2 origin) - => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Appends a centered rotation matrix using the given rotation in degrees. @@ -103,7 +103,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -121,7 +121,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder AppendRotationRadians(float radians, Vector2 origin) - => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Prepends a scale matrix from the given uniform scale. @@ -187,7 +187,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -207,7 +207,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.PrependMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.PrependMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Appends a centered skew matrix from the give angles in degrees. @@ -225,7 +225,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -245,7 +245,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.AppendMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.AppendMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Prepends a translation matrix from the given vector. @@ -261,7 +261,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder PrependTranslation(Vector2 position) - => this.PrependMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.PrependMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Appends a translation matrix from the given vector. @@ -277,7 +277,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder AppendTranslation(Vector2 position) - => this.AppendMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.AppendMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Prepends a quad distortion matrix using the specified corner points. @@ -289,7 +289,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder PrependQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Prepend(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Appends a quad distortion matrix using the specified corner points. @@ -301,7 +301,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder AppendQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Append(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Prepends a raw matrix. @@ -359,7 +359,7 @@ public class ProjectiveTransformBuilder Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle)); // Translate the origin matrix to cater for source rectangle offsets. - Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0)); + Matrix4x4 matrix = Matrix4x4.CreateTranslation(new(-sourceRectangle.Location, 0)); Size size = sourceRectangle.Size; diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs index 92d5bcdbfe..e263e3c629 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs @@ -49,7 +49,7 @@ public abstract class FromRgba32Bytes for (int i = 0; i < this.Count; i++) { int i4 = i * 4; - d[i] = TPixel.FromRgba32(new Rgba32(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); + d[i] = TPixel.FromRgba32(new(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs index eec926a23c..53b76201c7 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs @@ -37,6 +37,6 @@ public class DecodeBmp { using MemoryStream memoryStream = new(this.bmpBytes); using Image image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs index 3238e8dac2..84428d2fcd 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs @@ -23,7 +23,7 @@ public abstract class DecodeEncodeGif private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); [GlobalSetup] - public void Setup() => this.outputStream = new MemoryStream(); + public void Setup() => this.outputStream = new(); [GlobalCleanup] public void Cleanup() => this.outputStream.Close(); @@ -54,6 +54,6 @@ public class DecodeEncodeGif_CoarsePaletteEncoder : DecodeEncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs index 117cdd25b3..044a50d04b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs @@ -36,6 +36,6 @@ public class DecodeGif { using MemoryStream memoryStream = new(this.gifBytes); using Image image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs index b8f8f78517..60c14ff257 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs @@ -38,7 +38,7 @@ public abstract class EncodeGif this.bmpDrawing = SDImage.FromStream(this.bmpStream); this.bmpStream.Position = 0; - this.magickImage = new MagickImageCollection(this.bmpStream); + this.magickImage = new(this.bmpStream); } } @@ -83,6 +83,6 @@ public class EncodeGif_CoarsePaletteEncoder : EncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs index 303272837b..7a0542981e 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs @@ -24,7 +24,7 @@ public class EncodeGifMultiple : MultiImageBenchmarkBase.WithImagesPreloaded // Try to get as close to System.Drawing's output as possible GifEncoder options = new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4 }) }; img.Save(ms, options); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 72b6bb72e8..29a3ae5de0 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 Vector2(sLeft.X); + Vector2 yLeft = new Vector2(sLeft.Y); + Vector2 zLeft = new Vector2(sLeft.Z); + Vector2 wLeft = new Vector2(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 Vector2(sRight.X); + Vector2 yRight = new Vector2(sRight.Y); + Vector2 zRight = new Vector2(sRight.Z); + Vector2 wRight = new Vector2(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 Vector4(sLeft.X); + Vector4 yLeft = new Vector4(sLeft.Y); + Vector4 zLeft = new Vector4(sLeft.Z); + Vector4 wLeft = new Vector4(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 Vector4(sRight.X); + Vector4 yRight = new Vector4(sRight.Y); + Vector4 zRight = new Vector4(sRight.Z); + Vector4 wRight = new Vector4(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 Vector4(sLeft.X); + Vector4 yLeft = new Vector4(sLeft.Y); + Vector4 zLeft = new Vector4(sLeft.Z); + Vector4 wLeft = new Vector4(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 Vector4(sRight.X); + Vector4 yRight = new Vector4(sRight.Y); + Vector4 zRight = new Vector4(sRight.Z); + Vector2 wRight = new Vector2(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 Vector4(sLeft.X) { Z = sLeft.Y, W = sLeft.Y }; - var zwLeft = new Vector4(sLeft.Z) + Vector4 zwLeft = new Vector4(sLeft.Z) { Z = sLeft.W, W = sLeft.W }; - var xyRight = new Vector4(sRight.X) + Vector4 xyRight = new Vector4(sRight.X) { Z = sRight.Y, W = sRight.Y }; - var zwRight = new Vector4(sRight.Z) + Vector4 zwRight = new Vector4(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 efc347586c..ea8a1c47be 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs @@ -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 722b095870..3c03f3e056 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 8964667b74..959522d812 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 Random(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/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs index dbd2557225..6e089d443e 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs @@ -19,7 +19,7 @@ public class DecodeJpeg { this.decoder = JpegDecoder.Instance; byte[] bytes = File.ReadAllBytes(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, imageSubpath)); - this.preloadedImageStream = new MemoryStream(bytes); + this.preloadedImageStream = new(bytes); } private void GenericBenchmark() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 257e44cc40..78beda5ef7 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -49,8 +49,8 @@ public class DecodeJpeg_ImageSpecific public Size ImageSharp() { using MemoryStream memoryStream = new(this.jpegBytes); - using Image image = Image.Load(new DecoderOptions() { SkipMetadata = true }, memoryStream); - return new Size(image.Width, image.Height); + using Image image = Image.Load(new() { SkipMetadata = true }, memoryStream); + return new(image.Width, image.Height); } /* diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs index c7cecd1a52..b865bb85d9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs @@ -38,9 +38,9 @@ public class EncodeJpegComparison using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.imageImageSharp = Image.Load(imageBinaryStream); - this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; + this.encoderImageSharp = new() { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkImageSharp))] @@ -67,7 +67,7 @@ public class EncodeJpegComparison this.imageSkiaSharp = SKBitmap.Decode(imageBinaryStream); - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkSkiaSharp))] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs index 858917995a..2e1cae9730 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs @@ -44,13 +44,13 @@ public class EncodeJpegFeatures { using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.bmpCore = Image.Load(imageBinaryStream); - this.encoder = new JpegEncoder + this.encoder = new() { Quality = this.Quality, ColorType = this.TargetColorSpace, Interleaved = true, }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs index 0adc52441a..64d06ac17f 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs @@ -155,7 +155,7 @@ public abstract class MultiImageBenchmarkBase this.FileNamesToImageSharpImages[fn] = Image.Load(ms1); } - this.FileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes)); + this.FileNamesToSystemDrawingImages[fn] = new(new MemoryStream(bytes)); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs index 125b42680d..4c60de6630 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs @@ -52,7 +52,7 @@ public class EncodeIndexedPng public void PngCoreOctreeNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) }; + PngEncoder options = new() { Quantizer = new OctreeQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -68,7 +68,7 @@ public class EncodeIndexedPng public void PngCorePaletteNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null }) }; + PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -84,7 +84,7 @@ public class EncodeIndexedPng public void PngCoreWuNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }), ColorType = PngColorType.Palette }; + PngEncoder options = new() { Quantizer = new WuQuantizer(new() { Dither = null }), ColorType = PngColorType.Palette }; this.bmpCore.SaveAsPng(memoryStream, options); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs index 169a44d91a..c9ab74eda6 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs @@ -26,7 +26,7 @@ public class EncodeTga if (this.tga == null) { this.tga = Image.Load(this.TestImageFullPath); - this.tgaMagick = new MagickImage(this.TestImageFullPath); + this.tgaMagick = new(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs index 6fa6a15ed4..44c04caef9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs @@ -62,7 +62,7 @@ public class EncodeTiff ImageCodecInfo codec = FindCodecForType("image/tiff"); using EncoderParameters parameters = new(1) { - Param = { [0] = new EncoderParameter(Encoder.Compression, (long)Cast(this.Compression)) } + Param = { [0] = new(Encoder.Compression, (long)Cast(this.Compression)) } }; using MemoryStream memoryStream = new(); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs index 3b90584988..9c134c0e13 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs @@ -30,7 +30,7 @@ public class EncodeWebp if (this.webp == null) { this.webp = Image.Load(this.TestImageFullPath); - this.webpMagick = new MagickImage(this.TestImageFullPath); + this.webpMagick = new(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs index 5166c89a93..38715e6ca0 100644 --- a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs +++ b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs @@ -15,5 +15,5 @@ public class ColorEquality [Benchmark(Description = "ImageSharp Color Equals")] public bool ColorEqual() - => new Rgba32(128, 128, 128, 128).Equals(new Rgba32(128, 128, 128, 128)); + => new Rgba32(128, 128, 128, 128).Equals(new(128, 128, 128, 128)); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs index b847e3ac54..dcc46df376 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs @@ -13,7 +13,7 @@ public class RgbWorkingSpaceAdapt private static readonly RGBColor RGBColor = new(0.206162, 0.260277, 0.746717); - private static readonly ColorProfileConverter ColorProfileConverter = new(new ColorConversionOptions { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); + private static readonly ColorProfileConverter ColorProfileConverter = new(new() { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); private static readonly IColorConverter ColourfulConverter = new ConverterBuilder().FromRGB(RGBWorkingSpaces.WideGamutRGB).ToRGB(RGBWorkingSpaces.sRGB).Build(); diff --git a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs index 093397ad5f..37db166aee 100644 --- a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs +++ b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs @@ -22,7 +22,7 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (0.34414F * ccb) - (0.71414F * ccr), 0, 255); byte b = (byte)Numerics.Clamp(y + (1.772F * ccb), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } [Benchmark(Description = "Scaled Integer Conversion")] @@ -45,6 +45,6 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (g0 >> 10) - (g1 >> 10), 0, 255); byte b = (byte)Numerics.Clamp(y + (b0 >> 10), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } } diff --git a/tests/ImageSharp.Benchmarks/General/Array2D.cs b/tests/ImageSharp.Benchmarks/General/Array2D.cs index f0a36ee1d6..2d244607b1 100644 --- a/tests/ImageSharp.Benchmarks/General/Array2D.cs +++ b/tests/ImageSharp.Benchmarks/General/Array2D.cs @@ -44,7 +44,7 @@ public class Array2D this.jaggedData[i] = new float[this.Count]; } - this.matrix = new DenseMatrix(this.array2D); + this.matrix = new(this.array2D); this.Min = (this.Count / 2) - 10; this.Min = Math.Max(0, this.Min); diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index d47fcb687e..458927a352 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 Random(); for (int i = 0; i < A.Length; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs index 186f88bb71..5d93d20831 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs @@ -42,13 +42,13 @@ public class ClampVector4 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorClamp(float x, float min, float max) { - return Vector4.Clamp(new Vector4(x), new Vector4(min), new Vector4(max)); + return Vector4.Clamp(new(x), new(min), new(max)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorMinMax(float x, float min, float max) { - return Vector4.Min(new Vector4(max), Vector4.Max(new Vector4(min), new Vector4(x))); + return Vector4.Min(new(max), Vector4.Max(new(min), new(x))); } // RESULTS diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 031f9ecf27..85daa5bd26 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -36,11 +36,11 @@ public class CopyBuffers public void Setup() { this.sourceArray = new byte[this.Count]; - this.sourceMemory = new Memory(this.sourceArray); + this.sourceMemory = new(this.sourceArray); this.sourceHandle = this.sourceMemory.Pin(); this.destArray = new byte[this.Count]; - this.destMemory = new Memory(this.destArray); + this.destMemory = new(this.destArray); this.destHandle = this.destMemory.Pin(); } diff --git a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs index d32e1fdd0d..f9b32d22a6 100644 --- a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs @@ -31,28 +31,28 @@ public class BufferedStreams [GlobalSetup] public void CreateStreams() { - this.stream1 = new MemoryStream(this.buffer); - this.stream2 = new MemoryStream(this.buffer); - this.stream3 = new MemoryStream(this.buffer); - this.stream4 = new MemoryStream(this.buffer); - this.stream5 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - - this.chunkedMemoryStream1 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.stream1 = new(this.buffer); + this.stream2 = new(this.buffer); + this.stream3 = new(this.buffer); + this.stream4 = new(this.buffer); + this.stream5 = new(this.buffer); + this.stream6 = new(this.buffer); + this.stream6 = new(this.buffer); + + this.chunkedMemoryStream1 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream1.Write(this.buffer); this.chunkedMemoryStream1.Position = 0; - this.chunkedMemoryStream2 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.chunkedMemoryStream2 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream2.Write(this.buffer); this.chunkedMemoryStream2.Position = 0; - this.bufferedStream1 = new BufferedReadStream(Configuration.Default, this.stream3); - this.bufferedStream2 = new BufferedReadStream(Configuration.Default, this.stream4); - this.bufferedStream3 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream1); - this.bufferedStream4 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream2); - this.bufferedStreamWrap1 = new BufferedReadStreamWrapper(this.stream5); - this.bufferedStreamWrap2 = new BufferedReadStreamWrapper(this.stream6); + this.bufferedStream1 = new(Configuration.Default, this.stream3); + this.bufferedStream2 = new(Configuration.Default, this.stream4); + this.bufferedStream3 = new(Configuration.Default, this.chunkedMemoryStream1); + this.bufferedStream4 = new(Configuration.Default, this.chunkedMemoryStream2); + this.bufferedStreamWrap1 = new(this.stream5); + this.bufferedStreamWrap2 = new(this.stream6); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index c864e26c61..33fe56fc67 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -96,9 +96,9 @@ public abstract class PixelConversion_ConvertFromRgba32 [GlobalSetup] public void Setup() { - this.CompatibleMemLayoutRunner = new ConversionRunner(this.Count); - this.PermutedRunnerRgbaToArgb = new ConversionRunner(this.Count); - this.RunnerRgbaToRgbaVector = new ConversionRunner(this.Count); + this.CompatibleMemLayoutRunner = new(this.Count); + this.PermutedRunnerRgbaToArgb = new(this.Count); + this.RunnerRgbaToRgbaVector = new(this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index 57f79ba1f3..c0dd6b93d5 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -65,8 +65,8 @@ public class PixelConversion_ConvertFromVector4 [GlobalSetup] public void Setup() { - this.nonVectorRunner = new ConversionRunner(this.Count); - this.vectorRunner = new ConversionRunner(this.Count); + this.nonVectorRunner = new(this.Count); + this.vectorRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index 1a03a0c04f..4a36e9cf1a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -69,8 +69,8 @@ public class PixelConversion_ConvertToRgba32 [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 69a71734a3..ad2e71626a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -76,8 +76,8 @@ public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index 9b498b0f2e..ee0fbb4996 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -59,7 +59,7 @@ public class PixelConversion_ConvertToVector4 [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 50c3d0d131..d9723b0e3a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -73,7 +73,7 @@ public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index a42c6c253c..226dcc7775 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 f4fb9e4204..21808b5ef7 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 Vector(0xFF00FF00); + Vector bMask = new Vector(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 2cd6a5a52a..c7df2467bc 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; @@ -24,8 +24,8 @@ public class Vector4Constants [GlobalSetup] public void Setup() { - this.random = new Random(42); - this.parameter = new Vector4( + this.random = new(42); + this.parameter = new( this.GetRandomFloat(), this.GetRandomFloat(), this.GetRandomFloat(), @@ -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(1.2f)); + Vector4 w = Vector4.Max(p, new(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 4d8d9b1ed6..69babfb92f 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 Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(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 1b2c56ab97..2c30cd103c 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 Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(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 d102164e2c..6bdbccace7 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 Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a / v; a.CopyTo(this.result, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index a2eb8d417a..8d5d66c4ba 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 Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(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 Vector(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 a234970a51..d8079423fa 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 Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs index 29b90accc5..8129222c3c 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 Vector4(.5F); return Vector4Utils.Premultiply(input); } [Benchmark] public Vector4 PremultiplyByRef() { - var input = new Vector4(.5F); + Vector4 input = new Vector4(.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 Vector4(.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 7d626d7856..d7204d96d8 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 Vector(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 5f1f5666de..54e9622a38 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 Vector(256.0f / 255.0f); + Vector magicFloat = new Vector(32768.0f); + Vector magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f + Vector mask = new Vector(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 Vector(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 Vector(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 Vector(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 5d20f29d18..e8b6626cd4 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 Vector(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - var a = new Vector(this.data, i); + Vector a = new Vector(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 Vector(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 Vector(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 Vector(this.testValue); - var span = new Span(this.data); + Span span = new Span(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 04621695c6..65ca779ca5 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() { ImageCount = Environment.ProcessorCount, Filter = Filter diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index 44c248dc98..1a2d0360ef 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -117,7 +117,7 @@ public class LoadResizeSaveStressRunner public void ForEachImageParallel(Action action) => Parallel.ForEach( this.Images, - new ParallelOptions { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, + new() { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, action); public Task ForEachImageParallelAsync(Func action) @@ -148,7 +148,7 @@ public class LoadResizeSaveStressRunner private void LogImageProcessed(int width, int height) { - this.LastProcessedImageSize = new Size(width, height); + this.LastProcessedImageSize = new(width, height); double pixels = width * (double)height; this.TotalProcessedMegapixels += pixels / 1_000_000.0; } @@ -322,7 +322,7 @@ public class LoadResizeSaveStressRunner (int width, int height) = this.ScaledSize(info.Width, info.Height, this.ThumbnailSize); SKSizeI supportedScale = codec.GetScaledDimensions((float)width / info.Width); - using SKBitmap original = SKBitmap.Decode(codec, new SKImageInfo(supportedScale.Width, supportedScale.Height)); + using SKBitmap original = SKBitmap.Decode(codec, new(supportedScale.Width, supportedScale.Height)); using SKBitmap resized = original.Resize(new SKImageInfo(width, height), SKFilterQuality.High); if (resized == null) { diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index a308c0c468..9f75f9dc26 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -73,7 +73,7 @@ public class PorterDuffBulkVsPixel BulkVectorConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } [Benchmark(Description = "ImageSharp BulkPixelConvert")] @@ -89,6 +89,6 @@ public class PorterDuffBulkVsPixel BulkPixelConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Crop.cs b/tests/ImageSharp.Benchmarks/Processing/Crop.cs index e14366bfde..d526c6ba4a 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Crop.cs @@ -24,7 +24,7 @@ public class Crop graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.DrawImage(source, new SDRectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); + graphics.DrawImage(source, new(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); return destination.Size; } @@ -34,6 +34,6 @@ public class Crop { using Image image = new(800, 800); image.Mutate(x => x.Crop(100, 100)); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs index 135145a312..8be48260ab 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() { 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() { LuminanceLevels = 256, Method = HistogramEqualizationMethod.AdaptiveTileInterpolation diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 09673cb96a..949b14afa8 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; } @@ -218,9 +218,9 @@ public class Resize_Bicubic_Compare_Rgba32_Rgb24 [GlobalSetup] public void Setup() { - this.rgb24 = new Resize_Bicubic_Rgb24(); + this.rgb24 = new(); this.rgb24.Setup(); - this.rgba32 = new Resize_Bicubic_Rgba32(); + this.rgba32 = new(); this.rgba32.Setup(); } diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs index 248912b14f..79128cfee9 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() { 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))} |"); @@ -295,7 +295,7 @@ internal class LoadResizeSaveParallelMemoryStress (int)B(this.MaxContiguousPoolBufferMegaBytes), B(this.MaxPoolSizeMegaBytes), (int)B(this.MaxCapacityOfNonPoolBuffersMegaBytes), - new UniformUnmanagedMemoryPool.TrimSettings + new() { TrimPeriodMilliseconds = this.TrimTimeSeconds.Value * 1000 }); diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index b5c8b70cde..43e17f5c9e 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 ResizeProfilingBenchmarks(new ConsoleOutput()); test.ResizeBicubic(4000, 4000); } private static void RunToVector4ProfilingTest() { - var tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); + PixelOperationsTests.Rgba32_OperationsTests tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); tests.Benchmark_ToVector4(); } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index 4247345c7b..6c3377d10d 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(); @@ -108,10 +108,10 @@ public partial class ColorTests Color color = Color.FromScaledVector(Vector4.One); // Assert: - Assert.Equal(new RgbaVector(1, 1, 1, 1), color.ToPixel()); - Assert.Equal(new Rgba64(65535, 65535, 65535, 65535), color.ToPixel()); - Assert.Equal(new Rgba32(255, 255, 255, 255), color.ToPixel()); - Assert.Equal(new L8(255), color.ToPixel()); + Assert.Equal(new(1, 1, 1, 1), color.ToPixel()); + Assert.Equal(new(65535, 65535, 65535, 65535), color.ToPixel()); + Assert.Equal(new(255, 255, 255, 255), color.ToPixel()); + Assert.Equal(new(255), color.ToPixel()); } [Fact] @@ -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/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index d430df5b44..8b636ee39f 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -108,29 +108,29 @@ public partial class ColorTests [Fact] public void ShortHex() { - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("#fff").ToPixel()); - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("fff").ToPixel()); - Assert.Equal(new Rgba32(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("#fff").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("fff").ToPixel()); + Assert.Equal(new(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); } [Fact] public void TryShortHex() { Assert.True(Color.TryParseHex("#fff", out Color actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("fff", out actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("000f", out actual)); - Assert.Equal(new Rgba32(0, 0, 0, 255), actual.ToPixel()); + Assert.Equal(new(0, 0, 0, 255), actual.ToPixel()); } [Fact] public void LeadingPoundIsOptional() { - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("#008080").ToPixel()); - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("#008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("008080").ToPixel()); } [Fact] diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs index 69fabc7508..93e64aa9bd 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs @@ -35,8 +35,8 @@ public class CieLabTests Assert.True(new CieLab(1, 0, 1) != default); Assert.False(new CieLab(1, 0, 1) == default); Assert.Equal(default, default(CieLab)); - Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); - Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(new CieLab(1, 0, 1) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs index 484db3e8cf..e2bf8655e5 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs @@ -33,8 +33,8 @@ public class CieLchTests Assert.True(default == default(CieLch)); Assert.False(default != default(CieLch)); Assert.Equal(default, default(CieLch)); - Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); - Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLch(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLch(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs index 3fe550a5ba..cc8f9789a8 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs @@ -34,8 +34,8 @@ public class CieLchuvTests Assert.True(default == default(CieLchuv)); Assert.False(default != default(CieLchuv)); Assert.Equal(default, default(CieLchuv)); - Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); - Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLchuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLchuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs index 173491081d..7d715349ff 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs @@ -34,8 +34,8 @@ public class CieLuvTests Assert.True(default == default(CieLuv)); Assert.False(default != default(CieLuv)); Assert.Equal(default, default(CieLuv)); - Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); - Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs index 8bc71f1e18..5875b78c1c 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs @@ -32,8 +32,8 @@ public class CieXyChromaticityCoordinatesTests Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.Equal(default, default(CieXyChromaticityCoordinates)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); + Assert.Equal(new(1, 0), new CieXyChromaticityCoordinates(1, 0)); + Assert.Equal(new(1, 1), new CieXyChromaticityCoordinates(1, 1)); Assert.False(x.Equals(y)); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs index 80904c5df1..6290546a85 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs @@ -34,8 +34,8 @@ public class CieXyyTests Assert.True(default == default(CieXyy)); Assert.False(default != default(CieXyy)); Assert.Equal(default, default(CieXyy)); - Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); - Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyy(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyy(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs index 683b3b6611..e7e4261c66 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs @@ -34,8 +34,8 @@ public class CieXyzTests Assert.True(default == default(CieXyz)); Assert.False(default != default(CieXyz)); Assert.Equal(default, default(CieXyz)); - Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); - Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyz(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyz(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs index 22b7a7f70c..a732c68c56 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs @@ -36,8 +36,8 @@ public class CmykTests Assert.True(default == default(Cmyk)); Assert.False(default != default(Cmyk)); Assert.Equal(default, default(Cmyk)); - Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); - Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); + Assert.Equal(new(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); + Assert.Equal(new(Vector4.One), new Cmyk(Vector4.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs index 1bdefa1095..24b221155e 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs @@ -102,7 +102,7 @@ public class CompandingTests private static void CompandingIsCorrectImpl(Vector4 e, Vector4 c, float expanded, Vector4 compressed) { // W (alpha) is already the linear representation of the color. - Assert.Equal(new Vector4(expanded, expanded, expanded, e.W), e, Comparer); + Assert.Equal(new(expanded, expanded, expanded, e.W), e, Comparer); Assert.Equal(compressed, c, Comparer); } } diff --git a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs index 6697cbfde2..6d9af0eee4 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs @@ -34,8 +34,8 @@ public class HslTests Assert.True(default == default(Hsl)); Assert.False(default != default(Hsl)); Assert.Equal(default, default(Hsl)); - Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); - Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsl(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsl(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs index dd71fcd3ff..36a8d599bd 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs @@ -34,8 +34,8 @@ public class HsvTests Assert.True(default == default(Hsv)); Assert.False(default != default(Hsv)); Assert.Equal(default, default(Hsv)); - Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); - Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs index af06b3c91f..f136aa2880 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs @@ -35,8 +35,8 @@ public class HunterLabTests Assert.True(new HunterLab(1, 0, 1) != default); Assert.False(new HunterLab(1, 0, 1) == default); Assert.Equal(default, default(HunterLab)); - Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); - Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new HunterLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new HunterLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs index 6c56dc682d..cd6fe33cc8 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs @@ -152,7 +152,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) private static Vector4 GetActualTargetValues(float[] input, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new ColorConversionOptions + ColorProfileConverter converter = new(new() { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -163,20 +163,20 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) return sourceDataSpace switch { IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), _ => throw new NotSupportedException($"Unsupported ICC profile data color space conversion: {sourceDataSpace} -> {targetDataSpace}") }; } private static List GetBulkActualTargetValues(List inputs, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new ColorConversionOptions + ColorProfileConverter converter = new(new() { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -189,7 +189,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) { case IccColorSpaceType.Cmyk: { - Span inputSpan = inputs.Select(x => new Cmyk(new Vector4(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Cmyk(new(x))).ToArray(); switch (targetDataSpace) { @@ -214,7 +214,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) case IccColorSpaceType.Rgb: { - Span inputSpan = inputs.Select(x => new Rgb(new Vector3(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Rgb(new(x))).ToArray(); switch (targetDataSpace) { diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs index 3e3bb4d498..c5f9507847 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs @@ -58,12 +58,12 @@ internal static class TestIccProfiles public const string StandardRgbV2 = "sRGB2014.icc"; public static IccProfile GetProfile(string file) - => ProfileCache.GetOrAdd(file, f => new IccProfile(File.ReadAllBytes(GetFullPath(f)))); + => ProfileCache.GetOrAdd(file, f => new(File.ReadAllBytes(GetFullPath(f)))); 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(iccConfig: new(GetFullPath(f), Intent.Unspecified, f))); public static bool HasUnicolourConfiguration(string file) => UnicolourConfigurationCache.ContainsKey(file); diff --git a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs index 395b547fdb..c409bfd69f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs @@ -35,8 +35,8 @@ public class LmsTests Assert.True(new Lms(1, 0, 1) != default); Assert.False(new Lms(1, 0, 1) == default); Assert.Equal(default, default(Lms)); - Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); - Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Lms(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Lms(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs index 707b3e2a7d..5ee4dac119 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs @@ -35,8 +35,8 @@ public class RgbTests Assert.True(default == default(Rgb)); Assert.False(default != default(Rgb)); Assert.Equal(default, default(Rgb)); - Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); - Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Rgb(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Rgb(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs index f61124d8f5..1a52d8a7f6 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs @@ -50,7 +50,7 @@ public class StringRepresentationTests { new HunterLab(Random), "HunterLab(42.4, 94.5, 83.4)" }, { new Lms(Random), "Lms(42.4, 94.5, 83.4)" }, { new Rgb(Random), "Rgb(42.4, 94.5, 83.4)" }, - { Rgb.Clamp(new Rgb(Random)), "Rgb(1, 1, 1)" }, + { Rgb.Clamp(new(Random)), "Rgb(1, 1, 1)" }, { new Hsl(Random), "Hsl(42.4, 1, 1)" }, // clamping to 1 is expected { new Hsv(Random), "Hsv(42.4, 1, 1)" }, // clamping to 1 is expected { new Y(Random.X), "Y(1)" }, diff --git a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs index 64558a3f8a..7bd7c5167c 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs @@ -34,8 +34,8 @@ public class YCbCrTests Assert.True(default == default(YCbCr)); Assert.False(default != default(YCbCr)); Assert.Equal(default, default(YCbCr)); - Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); - Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); + Assert.Equal(new(1, 0, 1), new YCbCr(1, 0, 1)); + Assert.Equal(new(Vector3.One), new YCbCr(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs index 7e5e48b69e..e924484186 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs @@ -28,9 +28,9 @@ public class YTests Assert.True(default == default(Y)); Assert.False(default != default(Y)); Assert.Equal(default, default(Y)); - Assert.Equal(new Y(1), new Y(1)); + Assert.Equal(new(1), new Y(1)); - Assert.Equal(new Y(.5F), new Y(.5F)); + Assert.Equal(new(.5F), new Y(.5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs index bfe0bdb175..ada125f59f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs @@ -34,8 +34,8 @@ public class YccKTests Assert.True(default == default(YccK)); Assert.False(default != default(YccK)); Assert.Equal(default, default(YccK)); - Assert.Equal(new YccK(1, 1, 1, 1), new YccK(1, 1, 1, 1)); - Assert.Equal(new YccK(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); + Assert.Equal(new(1, 1, 1, 1), new YccK(1, 1, 1, 1)); + Assert.Equal(new(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs index 190bfe1dc6..db2da6a697 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 ReadOnlySpan(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 2b92769436..69f8f9c2cd 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 Random(seed); for (int i = 0; i < count; i++) { uint value = (uint)rng.Next(); diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 36b3012640..e4d9a04b45 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -51,7 +51,7 @@ public partial class SimdUtilsTests data[i] = data[i - 4] + 100f; } - return new Vector(data); + return new(data); } private static Vector CreateRandomTestVector(int seed, float min, float max) @@ -66,7 +66,7 @@ public partial class SimdUtilsTests data[i] = v; } - return new Vector(data); + return new(data); } [Fact] @@ -287,7 +287,7 @@ public partial class SimdUtilsTests TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { - expected[i] = TPixel.FromRgb24(new Rgb24(r[i], g[i], b[i])); + expected[i] = TPixel.FromRgb24(new(r[i], g[i], b[i])); } TPixel[] actual = new TPixel[count + 3]; // padding for Rgb24 AVX2 diff --git a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs index 1931109448..3df5e8f30d 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 MemoryStream(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 SeekableStream(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()) { 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 EofStream(7)) { eofStream.Skip(7); diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index c8e6cd2657..b90579a024 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -27,7 +27,7 @@ public class ConfigurationTests // The shallow copy of configuration should behave exactly like the default configuration, // so by using the copy, we test both the default and the copy. this.DefaultConfiguration = Configuration.CreateDefaultInstance().Clone(); - this.ConfigurationEmpty = new Configuration(); + this.ConfigurationEmpty = new(); } [Fact] @@ -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 88f4cde7ac..2e2c30784c 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -195,9 +195,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(64, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(64, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -216,9 +216,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(320, 128, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(320, 128, 32, 32), 1F)); background.DebugSave( provider, @@ -237,9 +237,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -258,9 +258,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -279,9 +279,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(80, 80), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(80, 80), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index d8ec7c9009..8b48576456 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 BmpFileHeader(1, 2, 3, 4); - var buffer = new byte[14]; + byte[] buffer = new byte[14]; header.WriteTo(buffer); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs index 14b017bee1..988e8935a0 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(file, new BmpEncoder()); + image.SaveAsBmp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(memoryStream, new BmpEncoder()); + image.SaveAsBmp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 44ed5e38dd..740cb9ac76 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -56,7 +56,7 @@ public class GifEncoderTests { // Use the palette quantizer without dithering to ensure results // are consistent - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = null, TransparencyThreshold = 0 }) }; // Always save as we need to compare the encoded output. @@ -115,7 +115,7 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = FrameColorTableMode.Global, - Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) + Quantizer = new OctreeQuantizer(new() { Dither = null }) }; // Always save as we need to compare the encoded output. @@ -124,7 +124,7 @@ public class GifEncoderTests encoder = new() { ColorTableMode = FrameColorTableMode.Local, - Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }), + Quantizer = new OctreeQuantizer(new() { Dither = null }), }; provider.Utility.SaveTestOutputFile(image, "gif", encoder, "local"); @@ -191,7 +191,7 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = colorMode, - Quantizer = new OctreeQuantizer(new QuantizerOptions { MaxColors = maxColors }) + Quantizer = new OctreeQuantizer(new() { MaxColors = maxColors }) }; image.Save(outStream, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs index dd3879703b..625b043d40 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs @@ -86,7 +86,7 @@ public class GifMetadataTests using Image image = testFile.CreateRgba32Image(GifDecoder.Instance); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } @@ -104,7 +104,7 @@ public class GifMetadataTests using Image image = decoder.Decode(DecoderOptions.Default, memoryStream); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } diff --git a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs index 97fdb38e76..d23efdd79d 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(file, new GifEncoder()); + image.SaveAsGif(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(memoryStream, new GifEncoder()); + image.SaveAsGif(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs index 69c6317a75..f895afbd51 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/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 324bd4783a..f7743e1494 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -24,7 +24,7 @@ public class ImageFormatManagerTests public ImageFormatManagerTests() { this.DefaultFormatsManager = Configuration.CreateDefaultInstance().ImageFormatsManager; - this.FormatsManagerEmpty = new ImageFormatManager(); + this.FormatsManagerEmpty = new(); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index cb8f52a96f..ae6f0331df 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 Random(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 Random(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 Random(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 7b411a28fe..062a8a5ee5 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 b89d9ad27a..625932e2ab 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 Random(seed); for (int i = 0; i < 1000; i++) { uint number = (uint)rng.Next(0, maxNumber); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs index b1f7997323..0d8bf3a743 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(file, new JpegEncoder()); + image.SaveAsJpeg(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(memoryStream, new JpegEncoder()); + image.SaveAsJpeg(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 1dba8ee1c9..ba60139c54 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -620,10 +620,10 @@ public class JpegColorConverterTests // no need to dispose when buffer is not array owner Memory memory = new(values); MemoryGroup source = MemoryGroup.Wrap(memory); - buffers[i] = new Buffer2D(source, values.Length, 1); + buffers[i] = new(source, values.Length, 1); } - return new JpegColorConverterBase.ComponentValues(buffers, 0); + return new(buffers, 0); } private static float[] CreateRandomValues(int length, Random rnd) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index 20a9ad3877..d2c7bcd5c2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -400,10 +400,10 @@ public partial class JpegDecoderTests exif.SetValue(ExifTag.XPSubject, "This is a subject"); // exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "ビッ")); - exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); + exif.SetValue(ExifTag.UserComment, new(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); - exif.SetValue(ExifTag.GPSProcessingMethod, new EncodedString(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); - exif.SetValue(ExifTag.GPSAreaInformation, new EncodedString(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); + exif.SetValue(ExifTag.GPSProcessingMethod, new(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); + exif.SetValue(ExifTag.GPSAreaInformation, new(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); image.Metadata.ExifProfile = exif; @@ -495,7 +495,7 @@ public partial class JpegDecoderTests Assert.Equal("Carers; seniors; caregiver; senior care; retirement home; hands; old; elderly; elderly caregiver; elder care; elderly care; geriatric care; nursing home; age; old age care; outpatient; needy; health care; home nurse; home care; sick; retirement; medical; mobile; the elderly; nursing department; nursing treatment; nursing; care services; nursing services; nursing care; nursing allowance; nursing homes; home nursing; care category; nursing class; care; nursing shortage; nursing patient care staff\0", exifProfile.GetValue(ExifTag.XPKeywords).Value); Assert.Equal( - new EncodedString(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), + new(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), exifProfile.GetValue(ExifTag.UserComment).Value); // the profile contains 4 duplicated UserComment diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index 99322687cc..ebc5a77a94 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -57,7 +57,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.ExifProfile = new ExifProfile(); + input.Metadata.ExifProfile = new(); input.Metadata.ExifProfile.SetValue(ExifTag.Software, "unit_test"); // act @@ -78,7 +78,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.ProfileRandomArray); + input.Metadata.IccProfile = new(IccTestDataProfiles.ProfileRandomArray); // act using MemoryStream memStream = new(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs index df74d266cb..1f8bdd67a6 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 JpegFileMarker(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 19b5265a17..df0595d7bf 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 JpegMetadata { 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 JpegMetadata(); 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 JpegMetadata { 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 JpegMetadata { 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 JpegMetadata { 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 JpegMetadata(); 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 Collection { comment }; - var meta = new JpegMetadata(); + JpegMetadata meta = new JpegMetadata(); 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 b202fd9ec3..e9821db4cf 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 Size(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 StringBuilder(); 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 Size(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 f5d7c159ba..2fcd953ae0 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 499cf79916..e069296d12 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); @@ -101,7 +101,7 @@ public class SpectralJpegTests int componentCount = imageSharpData.ComponentCount; if (libJpegData.ComponentCount != componentCount) { - throw new Exception("libJpegData.ComponentCount != componentCount"); + throw new("libJpegData.ComponentCount != componentCount"); } double averageDifference = 0; @@ -198,14 +198,14 @@ 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]; - spectralComponents[i] = new LibJpegTools.ComponentData(component.WidthInBlocks, component.HeightInBlocks, component.Index); + spectralComponents[i] = new(component.WidthInBlocks, component.HeightInBlocks, component.Index); } - this.spectralData = new LibJpegTools.SpectralData(spectralComponents); + this.spectralData = new(spectralComponents); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index b9f4a90b6d..186f723413 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()); 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 a3fbe4018e..511150c523 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 Random(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 Random(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 StringBuilder(); 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 StringBuilder(); 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 ApproximateFloatComparer(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 ApproximateFloatComparer(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 bd1df33772..b08202df50 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -18,12 +18,12 @@ internal static partial class LibJpegTools BigInteger totalDiff = 0; if (actual.WidthInBlocks < expected.WidthInBlocks) { - throw new Exception("actual.WidthInBlocks < expected.WidthInBlocks"); + throw new("actual.WidthInBlocks < expected.WidthInBlocks"); } if (actual.HeightInBlocks < expected.HeightInBlocks) { - throw new Exception("actual.HeightInBlocks < expected.HeightInBlocks"); + throw new("actual.HeightInBlocks < expected.HeightInBlocks"); } int w = expected.WidthInBlocks; @@ -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++) { @@ -127,7 +127,7 @@ internal static partial class LibJpegTools } } - return new SpectralData(result); + return new(result); } } finally diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index b6e7b29a62..2d4db15dfc 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 0d5f3114d1..acb3d27e37 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)); @@ -219,8 +219,8 @@ internal static partial class ReferenceImplementations y[6] = c3 * r[6] - c2 * r[2]; */ - w0 = new Vector4(1.175876f); - w1 = new Vector4(0.785695f); + w0 = new(1.175876f); + w1 = new(0.785695f); c3 = (w0 * t4) + (w1 * t7); c0 = (w0 * t7) - (w1 * t4); /* @@ -228,8 +228,8 @@ internal static partial class ReferenceImplementations c0 = t7 * r[3] - t4 * r[5]; */ - w0 = new Vector4(1.387040f); - w1 = new Vector4(0.275899f); + w0 = new(1.387040f); + w1 = new(0.275899f); c2 = (w0 * t5) + (w1 * t6); c1 = (w0 * t6) - (w1 * t5); /* @@ -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 @@ -300,7 +300,7 @@ internal static partial class ReferenceImplementations #pragma warning restore SA1300 // Element should begin with upper-case letter { src = src.Slice(offset); - return new Vector4(src[0], src[1], src[2], src[3]); + return new(src[0], src[1], src[2], src[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -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 95ab076b0b..10019c609e 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 240a338f9b..d7c2c0bbbb 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/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index 7a31e35d0c..d7b0b64b2d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -11,7 +11,7 @@ internal static class VerifyJpeg { internal static void VerifySize(IJpegComponent component, int expectedBlocksX, int expectedBlocksY) { - Assert.Equal(new Size(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); + Assert.Equal(new(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); } internal static void VerifyComponent( diff --git a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs index 5cbdd3dab0..1b71f49d5b 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(file, new PbmEncoder()); + image.SaveAsPbm(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(memoryStream, new PbmEncoder()); + image.SaveAsPbm(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 11dd1cd58c..2da8015324 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); @@ -130,7 +130,7 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(bytes); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(100, 100), eofHitCounter.Image.Size); + Assert.Equal(new(100, 100), eofHitCounter.Image.Size); } [Fact] @@ -139,6 +139,6 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(RgbBinaryPrematureEof); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(29, 30), eofHitCounter.Image.Size); + Assert.Equal(new(29, 30), eofHitCounter.Image.Size); } } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 05f1d963b2..0501ed2b25 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 PbmEncoder(); - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { 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 PbmEncoder() { 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 MemoryStream()) { 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 PbmEncoder { ColorType = colorType, Encoding = encoding }; - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { 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 b7ce32ed8f..f7c6dc1714 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 MemoryStream(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 MemoryStream(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 MemoryStream(); 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 1b66c4cc3c..6e03042fad 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 SharpAdler32(); adler.Update(data); long expected = adler.Value; diff --git a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs index a03e1a7aa4..145cc1d68f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(file, new PngEncoder()); + image.SaveAsPng(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(memoryStream, new PngEncoder()); + image.SaveAsPng(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index aff8bc12a2..71523d5b6f 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 MemoryStream()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 4d058e54e8..26da6f5215 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -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() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); Assert.NotNull(imageInfo); Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel); @@ -679,7 +679,7 @@ public partial class PngDecoderTests // TODO: Try to reduce this to 1. Assert.True(eofHitCounter.EofHitCount <= 3); - Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size); + Assert.Equal(new(200, 120), eofHitCounter.Image.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 796d35bf72..9ce1a9386e 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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 TestData(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 Random(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 b0d0563ccb..56909b9dcf 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -380,7 +380,7 @@ public partial class PngEncoderTests if (colorType is PngColorType.Grayscale or PngColorType.GrayscaleWithAlpha) { byte luminance = ColorNumerics.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); - expectedColor = new Rgba32(luminance, luminance, luminance); + expectedColor = new(luminance, luminance, luminance); } actual.ProcessPixelRows(accessor => @@ -680,7 +680,7 @@ public partial class PngEncoderTests PaletteQuantizer quantizer = new( palette.Select(Color.FromPixel).ToArray(), - new QuantizerOptions() { ColorMatchingMode = ColorMatchingMode.Hybrid }); + new() { ColorMatchingMode = ColorMatchingMode.Hybrid }); using MemoryStream ms = new(); image.Save(ms, new PngEncoder @@ -720,7 +720,7 @@ public partial class PngEncoderTests FilterMethod = pngFilterMethod, CompressionLevel = compressionLevel, BitDepth = bitDepth, - Quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = paletteSize }), + Quantizer = new WuQuantizer(new() { MaxColors = paletteSize }), InterlaceMethod = interlaceMode, ChunkFilter = optimizeMethod, }; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 225e4deef2..6902990240 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 }; @@ -111,10 +111,10 @@ public class PngMetadataTests using MemoryStream memoryStream = new(); // This will be a zTXt chunk. - PngTextData expectedText = new("large-text", new string('c', 100), string.Empty, string.Empty); + PngTextData expectedText = new("large-text", new('c', 100), string.Empty, string.Empty); // This will be a iTXt chunk. - PngTextData expectedTextNoneLatin = new("large-text-non-latin", new string('Ф', 100), "language-tag", "translated-keyword"); + PngTextData expectedTextNoneLatin = new("large-text-non-latin", new('Ф', 100), "language-tag", "translated-keyword"); PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs index 878f3fb8d4..f4c2f58978 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,13 +59,13 @@ 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); Assert.Equal("test", property.TranslatedKeyword); - property = new PngTextData("Foo", string.Empty, string.Empty, null); + property = new("Foo", string.Empty, string.Empty, null); Assert.Equal("Foo", property.Keyword); Assert.Equal(string.Empty, property.Value); Assert.Equal(string.Empty, property.LanguageTag); diff --git a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs index 31ec27da0c..11e79512ef 100644 --- a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(file, new QoiEncoder()); + image.SaveAsQoi(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(memoryStream, new QoiEncoder()); + image.SaveAsQoi(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs index 9b6daee4c9..9648f93e52 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(file, new TgaEncoder()); + image.SaveAsTga(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(memoryStream, new TgaEncoder()); + image.SaveAsTga(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs index 4646de7f82..04e8f29408 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); @@ -131,16 +131,16 @@ public class BigTiffMetadataTests values.Add(newExifValue); } - input.Frames.RootFrame.Metadata.ExifProfile = new ExifProfile(values, Array.Empty()); + input.Frames.RootFrame.Metadata.ExifProfile = new(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 b16119f338..ca39cd5bea 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); @@ -41,6 +41,6 @@ public class DeflateTiffCompressionTests } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs index 8c21e346af..01aaca9f5f 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,13 +47,13 @@ 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); } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs index e79ed7ce77..0a2726c21e 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 MemoryStream(inputData); + using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new NoneTiffCompression(default, default, default); + using NoneTiffCompression decompressor = new NoneTiffCompression(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 c91ab0e7fe..f5fbcb2e1f 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 MemoryStream(inputData); + using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); + using PackBitsTiffCompression decompressor = new PackBitsTiffCompression(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/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs index bf9e73ea6e..69d70e5e7e 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(file, new TiffEncoder()); + image.SaveAsTiff(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(memoryStream, new TiffEncoder()); + image.SaveAsTiff(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index 0fa7e01e8e..d2176f7e63 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -154,7 +154,7 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode( expectedResult, - pixels => new BlackIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); + pixels => new BlackIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); [Theory] [MemberData(nameof(BilevelData))] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index c809c6c7f9..fce40c4c4c 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -83,12 +83,12 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, ushort[] colorMap, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode(expectedResult, pixels => { - new PaletteTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); + new PaletteTiffColor(new(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); }); 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++) { @@ -124,7 +124,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase for (int x = 0; x < pixelLookup[y].Length; x++) { uint[] sourceColor = colorPalette[pixelLookup[y][x]]; - result[y][x] = new Rgba32(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); + result[y][x] = new(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index 3582dc75a6..ef57b288ce 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -17,7 +17,7 @@ public abstract class PhotometricInterpretationTestBase 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 Image(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 d8249c3619..6e0d5b2be0 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -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/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index 0b58e3891e..a79cc00585 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 = { @@ -155,7 +155,7 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { AssertDecode(expectedResult, pixels => { - new WhiteIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); + new WhiteIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); }); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs index 1bf9f5a400..70ba2e5dff 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 TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new MemoryStream(); 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 TiffEncoder { PhotometricInterpretation = photometricInterpretation, BitsPerPixel = bitsPerPixel, diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs index 716b978a71..a138d9ef87 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 TiffEncoder { 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(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new Image(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 TiffEncoder { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Deflate }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new System.IO.MemoryStream()) { 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(image.Width, image.Height, Color.Red.ToPixel()); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new Image(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 TiffEncoder { PhotometricInterpretation = TiffPhotometricInterpretation.PaletteColor, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Lzw }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new System.IO.MemoryStream()) { 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/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 4317c2714d..b00b8d7ac8 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -334,7 +334,7 @@ public class TiffEncoderTests : TiffEncoderBaseTester foreach (ImageFrame frame in image.Frames) { TiffFrameMetadata metadata = frame.Metadata.GetTiffMetadata(); - encodedDimensions.Add(new Size(metadata.EncodingWidth, metadata.EncodingHeight)); + encodedDimensions.Add(new(metadata.EncodingWidth, metadata.EncodingHeight)); } const int scale = 2; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 9b26ab2702..3bcbd26e5c 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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(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 MemoryStream(); Span buffer = stackalloc byte[4]; - using (var writer = new TiffStreamWriter(stream)) + using (TiffStreamWriter writer = new TiffStreamWriter(stream)) { writer.Write(0x11111111, buffer); long marker = writer.PlaceMarker(buffer); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs index ea13fd7125..510d67103b 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(file, new WebpEncoder()); + image.SaveAsWebp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(memoryStream, new WebpEncoder()); + image.SaveAsWebp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 4551e3e23e..321aff2bd3 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 Vp8LMultipliers() { GreenToBlue = 240, GreenToRed = 232, @@ -121,7 +121,7 @@ public class LosslessUtilsTests 16711680, 65027, 16712962 }; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new Vp8LMultipliers() { GreenToBlue = 240, GreenToRed = 232, diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index b4279b0454..a154417569 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -150,7 +150,7 @@ public class PredictorEncoderTests where TPixel : unmanaged, IPixel { Rgba32 rgba = color.ToRgba32(); - return new Bgra32(rgba.R, rgba.G, rgba.B, rgba.A); + return new(rgba.R, rgba.G, rgba.B, rgba.A); } private static string TestImageFullPath(string path) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs index a18eff73ce..79c7ff26bf 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 List(); 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 Vp8Histogram(); byte[] reference = { @@ -172,7 +172,7 @@ public class Vp8HistogramTests public void GetAlpha_WithEmptyHistogram_Works() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new Vp8Histogram(); // 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 Vp8Histogram(); 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 Vp8Histogram(); histogram1.CollectHistogram(reference, pred, 0, 1); - var histogram2 = new Vp8Histogram(); + Vp8Histogram histogram2 = new Vp8Histogram(); histogram1.Merge(histogram2); // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs index 0b85ececb9..a014e8991f 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 Vp8ModeScore(); 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 Vp8ModeScore { Score = 123, Nz = 1, @@ -36,7 +36,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore(); + Vp8ModeScore score2 = new Vp8ModeScore(); score2.InitScore(); // act @@ -55,7 +55,7 @@ public class Vp8ModeScoreTests public void AddScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new Vp8ModeScore { Score = 123, Nz = 1, @@ -66,7 +66,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore + Vp8ModeScore score2 = new Vp8ModeScore { Score = 123, Nz = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index 4982929c2c..dcb54dc198 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -80,7 +80,7 @@ public class Vp8ResidualTests Vp8BandProbas[] bandProbas = new Vp8BandProbas[8]; for (int i = 0; i < bandProbas.Length; i++) { - bandProbas[i] = new Vp8BandProbas(); + bandProbas[i] = new(); for (int j = 0; j < bandProbas[i].Probabilities.Length; j++) { for (int k = 0; k < 11; k++) @@ -95,7 +95,7 @@ public class Vp8ResidualTests residual.Costs = new Vp8Costs[16]; for (int i = 0; i < residual.Costs.Length; i++) { - residual.Costs[i] = new Vp8Costs(); + residual.Costs[i] = new(); Vp8CostArray[] costsArray = residual.Costs[i].Costs; for (int j = 0; j < costsArray.Length; j++) { @@ -109,7 +109,7 @@ public class Vp8ResidualTests residual.Stats = new Vp8Stats[8]; for (int i = 0; i < residual.Stats.Length; i++) { - residual.Stats[i] = new Vp8Stats(); + residual.Stats[i] = new(); for (int j = 0; j < residual.Stats[i].Stats.Length; j++) { for (int k = 0; k < residual.Stats[i].Stats[j].Stats.Length; k++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 1ffbd9f559..f8c7770e69 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() { MaxFrames = 1 } @@ -460,7 +460,7 @@ public class WebpDecoderTests // Web using Image image = provider.GetImage( WebpDecoder.Instance, - new WebpDecoderOptions() { BackgroundColorHandling = BackgroundColorHandling.Ignore }); + new() { 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 af6f7eea17..55a6e8ba0a 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs @@ -139,7 +139,7 @@ public class WebpEncoderTests }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "octree"); - gifEncoder = new GifEncoder() + gifEncoder = new() { Quantizer = new WuQuantizer(options) }; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs index ab8fef60f7..fefe27790c 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 Image(25, 25); + using MemoryStream memoryStream = new MemoryStream(); + ExifProfile expectedExif = new ExifProfile(); 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 MemoryStream(); 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 MemoryStream(); 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 MemoryStream(); 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 f50bc89335..6a46b26f2d 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 d663a803b3..e894f7b864 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 GraphicsOptions(); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 GraphicsOptions() { BlendPercentage = 0.9f }; - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 GraphicsOptions(); + Configuration config = new Configuration(); config.SetGraphicsOptions(option); @@ -59,11 +59,11 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new GraphicsOptions() { BlendPercentage = 0.9f }; - var config = new Configuration(); + Configuration config = new Configuration(); 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 Configuration(); - 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 Configuration(); 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 Configuration(); 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 Configuration(); - 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 Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 GraphicsOptions(); + Configuration config = new Configuration(); config.SetGraphicsOptions(option); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(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 3531599866..351254e401 100644 --- a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs @@ -57,7 +57,7 @@ public class GraphicsOptionsTests [Fact] public void NonDefaultClone() { - var expected = new GraphicsOptions + GraphicsOptions expected = new GraphicsOptions { AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop, Antialias = false, @@ -74,7 +74,7 @@ public class GraphicsOptionsTests [Fact] public void CloneIsDeep() { - var expected = new GraphicsOptions(); + GraphicsOptions expected = new GraphicsOptions(); 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 4c06d0cd55..1e6ab7bc9d 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 Vector4(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 75f988a4cb..c40fffd55b 100644 --- a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs @@ -162,7 +162,7 @@ public class NumericsTests [InlineData(63)] public void PremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new Random(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 Random(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 Random(); 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 c13a30052c..eadae91246 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 ParallelExecutionSettings( 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 d393850d6b..e5e6b18f80 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,13 +322,13 @@ 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) { for (int x = rect.Left; x < rect.Right; x++) { - buffer[x, y] = new Point(x, y); + buffer[x, y] = new(x, y); } } @@ -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 95f1d4e289..cc367df308 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 RowInterval(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 RowInterval(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 RowInterval(42, 123); + RowInterval b = new RowInterval(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 RowInterval(42, 123); + RowInterval b = new RowInterval(42, 125); + RowInterval c = new RowInterval(40, 123); Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 390170cfef..560d77e212 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -269,7 +269,7 @@ public class ChunkedMemoryStreamTests { ChunkedMemoryStream memoryStream; const string bufferSize = nameof(bufferSize); - using (memoryStream = new ChunkedMemoryStream(this.allocator)) + using (memoryStream = new(this.allocator)) { const string destination = nameof(destination); Assert.Throws(destination, () => memoryStream.CopyTo(destination: null)); @@ -293,7 +293,7 @@ public class ChunkedMemoryStreamTests Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); // Then for the destination being disposed. - memoryStream = new ChunkedMemoryStream(this.allocator); + memoryStream = new(this.allocator); Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); memoryStream.Dispose(); } diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 25674e6a8d..409fd46b9e 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 Image(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 Image(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 14c38d1f70..c3ed16dcd2 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs @@ -14,10 +14,10 @@ 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("en-US"); - this.Image = new Image(10, 10); - this.Collection = new ImageFrameCollection(this.Image, 10, 10, default(Rgba32)); + this.Image = new(10, 10); + this.Collection = new(this.Image, 10, 10, default(Rgba32)); } public void Dispose() diff --git a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs index ef5b5f4def..f3070311dc 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 TestMemoryAllocator(); 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 Image(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; Rgba32 val = frame[3, 4]; Assert.Equal(default(Rgba32), val); @@ -57,7 +57,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(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 Image(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 Image(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 Image(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 Image(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 Image(1, 1); ImageFrame frame = img.Frames.RootFrame; Assert.Throws(() => frame.ProcessPixelRows(null)); diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index e7d3b548bc..e9bdd5128b 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -12,14 +12,14 @@ public class ImageRotationTests public void RotateImageByMinus90Degrees() { (Size original, Size rotated) = Rotate(-90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] public void RotateImageBy90Degrees() { (Size original, Size rotated) = Rotate(90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] @@ -33,7 +33,7 @@ public class ImageRotationTests public void RotateImageBy270Degrees() { (Size original, Size rotated) = Rotate(270); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index f9c01ab564..c92383ca8e 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -23,22 +23,22 @@ public class ImageSaveTests : IDisposable public ImageSaveTests() { - this.localImageFormat = new Mock(); + this.localImageFormat = new(); this.localImageFormat.Setup(x => x.FileExtensions).Returns(new[] { "png" }); this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormat.Object); - this.encoder = new Mock(); + this.encoder = new(); - this.encoderNotInFormat = new Mock(); + this.encoderNotInFormat = new(); - this.fileSystem = new Mock(); - var config = new Configuration + this.fileSystem = new(); + Configuration config = new() { FileSystem = this.fileSystem.Object }; config.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); config.ImageFormatsManager.SetEncoder(this.localImageFormat.Object, this.encoder.Object); - this.image = new Image(config, 1, 1); + this.image = new(config, 1, 1); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs index f3b1a01c94..88e2b86ed6 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs @@ -15,7 +15,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsBmpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsBmpAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -23,7 +23,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsCurAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsCurAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -31,7 +31,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -41,7 +41,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -49,7 +49,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsIcoAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsIcoAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -57,7 +57,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsJpegAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsJpegAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -65,7 +65,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPbmAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPbmAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -73,7 +73,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -83,7 +83,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -91,7 +91,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsQoiAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsQoiAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -99,7 +99,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTgaAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsTgaAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -107,7 +107,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTiffAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsTiffAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -115,7 +115,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -125,7 +125,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); } } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index 51e2a01a28..ae48fde397 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. @@ -56,13 +56,13 @@ public partial class ImageTests protected ImageLoadTestBase() { // 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.localStreamReturnImageRgba32 = new(1, 1); + this.localStreamReturnImageAgnostic = new(1, 1); + this.LocalImageInfo = new(new(1, 1), new() { DecodedImageFormat = PngFormat.Instance }); - this.localImageFormatMock = new Mock(); + this.localImageFormatMock = new(); - this.localDecoder = new Mock(); + this.localDecoder = new(); this.localDecoder.Setup(x => x.Identify(It.IsAny(), It.IsAny())) .Returns(this.LocalImageInfo); @@ -111,15 +111,15 @@ public partial class ImageTests this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object); - this.LocalConfiguration = new Configuration(); + this.LocalConfiguration = new(); this.LocalConfiguration.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); this.LocalConfiguration.ImageFormatsManager.SetDecoder(this.localImageFormatMock.Object, this.localDecoder.Object); - this.TopLevelConfiguration = new Configuration(this.TestFormat); + this.TopLevelConfiguration = new(this.TestFormat); this.Marker = Guid.NewGuid().ToByteArray(); - this.dataStreamLazy = new Lazy(this.CreateStream); + this.dataStreamLazy = new(this.CreateStream); Stream StreamFactory() => this.DataStream; this.LocalFileSystemMock.Setup(x => x.OpenRead(this.MockFilePath)).Returns(StreamFactory); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index 3e488be9a3..8c110d143a 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private string Path { get; } = TestFile.GetInputFileFullPath(TestImages.Bmp.Bit8); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Path_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index 00ec985ac2..80a407a35c 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -14,7 +14,7 @@ public partial class ImageTests private static Span ByteSpan => new(ByteArray); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Bytes_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs index 7a5bd186b7..c16a50b437 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs @@ -21,12 +21,12 @@ public partial class ImageTests public Load_FromStream_UseDefaultConfiguration() { - this.BaseStream = new MemoryStream(Data); - this.Stream = new AsyncStreamWrapper(this.BaseStream, () => this.AllowSynchronousIO); + this.BaseStream = new(Data); + this.Stream = new(this.BaseStream, () => this.AllowSynchronousIO); } private static void VerifyDecodedImage(Image img) - => Assert.Equal(new Size(127, 64), img.Size); + => Assert.Equal(new(127, 64), img.Size); [Fact] public void Stream_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index e3c4a7df18..d38ed749a3 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; } @@ -64,13 +64,13 @@ public partial class ImageTests public override unsafe Span GetSpan() { void* ptr = (void*)this.bmpData.Scan0; - return new Span(ptr, this.length); + return new(ptr, this.length); } public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* ptr = (void*)this.bmpData.Scan0; - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() @@ -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 12caa6e7a9..ffb89923ab 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 Image(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 27cbe1a7ea..1a6d563c88 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++) @@ -51,7 +51,7 @@ public abstract class ProcessPixelRowsTestBase Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } }); @@ -71,18 +71,18 @@ 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++) { Span row = buffer.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - using var img2 = new Image(256, 256); + using Image img2 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, (accessor1, accessor2) => { @@ -109,19 +109,19 @@ 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++) { Span row = buffer2.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - 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/Memory/Allocators/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs index 33950c4697..6b9907ef5f 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs @@ -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 517eda7076..ac03863fd6 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 MockLifetimeGuard(); 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 MockLifetimeGuard(); 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 MockLifetimeGuard(); 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 UnmanagedBufferLifetimeGuard.FreeHandle(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 MockLifetimeGuard(); if (addRef) { guard.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs index a956190cd2..51552be7d3 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 SharedArrayPoolBuffer(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 SharedArrayPoolBuffer(900); Span span = buffer.GetSpan(); buffer.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index fd8b6af591..c5820c27f3 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 UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool pool1 = new UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool pool2 = new UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool.TrimSettings { 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 UniformUnmanagedMemoryPool.TrimSettings { 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 UniformUnmanagedMemoryPool(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 69fc1a5f7d..c0c7f5c22d 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 UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool(length, capacity); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); @@ -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 UniformUnmanagedMemoryPool(length, 10); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(128, 10); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(pool); + HashSet allHandles = new HashSet(); + List handleUnits = new List(); 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 UniformUnmanagedMemoryPool(7, 1000); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(16, 16); + using CleanupUtil cleanup = new CleanupUtil(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 UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool(8, count); + using CleanupUtil cleanup = new CleanupUtil(pool); + Random rnd = new Random(0); Parallel.For(0, Environment.ProcessorCount, (int i) => { - var allHandles = new List(); + List allHandles = new List(); 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 UniformUnmanagedMemoryPool(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 aa34a5c108..e0f129a653 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() { 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() { 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() { 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() { AllocationLimitMegabytes = (int)(threeGB / 1024) }); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs index d0a5cfa9a7..1e4795bc86 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 List>(); 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 7a0736b545..ef3af71f45 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 List(); 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 88c05fdd0e..578ffc4806 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() @@ -29,8 +29,8 @@ public partial class Buffer2DTests Assert.Equal(bb, a.FastMemoryGroup.Single()); Assert.Equal(aa, b.FastMemoryGroup.Single()); - Assert.Equal(new Size(3, 7), a.Size()); - Assert.Equal(new Size(10, 5), b.Size()); + Assert.Equal(new(3, 7), a.Size()); + Assert.Equal(new(10, 5), b.Size()); Assert.Equal(666, b[1, 3]); Assert.Equal(444, a[1, 3]); @@ -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 8ba3bf70a2..a5c2eea2dc 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; @@ -72,7 +72,7 @@ public partial class Buffer2DTests using Buffer2D buffer = useSizeOverload ? this.MemoryAllocator.Allocate2D( - new Size(200, 200), + new(200, 200), preferContiguosImageBuffers: true) : this.MemoryAllocator.Allocate2D( 200, @@ -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++) { @@ -169,7 +169,7 @@ public partial class Buffer2DTests } // Re-seed - rnd = new Random(42); + rnd = new(42); for (int y = 0; y < buffer.Height; y++) { Span span = buffer.GetSafeRowMemory(y).Span; @@ -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); @@ -354,7 +354,7 @@ public partial class Buffer2DTests [Theory] [MemberData(nameof(InvalidLengths))] public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationException_Size(Size size) - => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new Size(size))); + => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new(size))); [Theory] [MemberData(nameof(InvalidLengths))] diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index 46907b9c0e..cb89f6cf64 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -13,8 +13,8 @@ public class BufferAreaTests 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 Rectangle(3, 2, 5, 6); + Buffer2DRegion area = new Buffer2DRegion(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 Rectangle(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 Rectangle(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 Rectangle(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/MemoryGroupIndex.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs index 878084674a..ea98357cbf 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs @@ -27,7 +27,7 @@ public struct MemoryGroupIndex : IEquatable public static MemoryGroupIndex operator +(MemoryGroupIndex idx, int val) { int nextElementIndex = idx.ElementIndex + val; - return new MemoryGroupIndex( + return new( idx.BufferLength, idx.BufferIndex + (nextElementIndex / idx.BufferLength), nextElementIndex % idx.BufferLength); @@ -105,14 +105,14 @@ internal static class MemoryGroupIndexExtensions public static MemoryGroupIndex MinIndex(this IMemoryGroup group) where T : struct { - return new MemoryGroupIndex(group.BufferLength, 0, 0); + return new(group.BufferLength, 0, 0); } public static MemoryGroupIndex MaxIndex(this IMemoryGroup group) where T : struct { return group.Count == 0 - ? new MemoryGroupIndex(group.BufferLength, 0, 0) + ? new(group.BufferLength, 0, 0) : new MemoryGroupIndex(group.BufferLength, group.Count - 1, group[group.Count - 1].Length); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs index a49ab77781..9c7915e221 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,20 +45,20 @@ 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); + Assert.Equal(new(10, 3, 4), a); } [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; - Assert.Equal(new MemoryGroupIndex(10, 6, 1), a); - Assert.Equal(new MemoryGroupIndex(10, 6, 0), b); + Assert.Equal(new(10, 6, 1), a); + Assert.Equal(new(10, 6, 0), b); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs index 4c7de5412c..ac242e846d 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 UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool(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 UniformUnmanagedMemoryPool(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 23aaf3c559..c140571fcc 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 316150c305..044c8f584c 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); @@ -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 TestMemoryManager(data0); + using TestMemoryManager mgr1 = new TestMemoryManager(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); @@ -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 8fe6ef3ddb..56e2e95fe7 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs @@ -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 ccbee5bd51..0fd823ee50 100644 --- a/tests/ImageSharp.Tests/Memory/TestStructs.cs +++ b/tests/ImageSharp.Tests/Memory/TestStructs.cs @@ -19,10 +19,10 @@ 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); + result[i] = new(i + 1, i + 1); } return result; @@ -70,10 +70,10 @@ 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); + result[i] = new(i + 1, i + 1); } return result; diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 252784a7c5..a19b82e645 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 TestMemoryDiagnostics(); LocalInstance.Value = diag; return diag; } diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index cdd6f0cc4f..2a78b74bef 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() { CmmType = "Unittest" } diff --git a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs index ae02c3d57b..78290db639 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs @@ -36,7 +36,7 @@ public class ImageMetadataTests { ImageMetadata metaData = new() { - ExifProfile = new ExifProfile(), + ExifProfile = new(), HorizontalResolution = 4, VerticalResolution = 2 }; @@ -86,8 +86,8 @@ public class ImageMetadataTests public void SyncProfiles() { ExifProfile exifProfile = new(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(300)); using Image image = new(1, 1); image.Metadata.ExifProfile = exifProfile; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs index 76e2d35c45..ab4d8a0d14 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 Image(1, 1); + CicpProfile original = CreateCicpProfile(); image.Metadata.CicpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new PngEncoder(); // 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 CicpProfile() { 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 MemoryStream()) { 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 8072bebd77..1f8b80b406 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -63,7 +63,7 @@ public class ExifProfileTests Assert.Null(image.Metadata.ExifProfile); const string expected = "Dirk Lemstra"; - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Copyright, expected); image = WriteAndRead(image, imageFormat); @@ -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)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime)); - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -142,7 +142,7 @@ public class ExifProfileTests memStream.Position = 0; profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime, true)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime, true)); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -164,26 +164,26 @@ public class ExifProfileTests public void ReadWriteInfinity(TestImageWriteFormat imageFormat) { Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image(); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.PositiveInfinity)); image = WriteAndReadJpeg(image); IExifValue value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.PositiveInfinity), value.Value); + Assert.Equal(new(double.PositiveInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.NegativeInfinity), value.Value); + Assert.Equal(new(double.NegativeInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); IExifValue value2 = image.Metadata.ExifProfile.GetValue(ExifTag.FlashEnergy); Assert.NotNull(value2); - Assert.Equal(new Rational(double.PositiveInfinity), value2.Value); + Assert.Equal(new(double.PositiveInfinity), value2.Value); image.Dispose(); } @@ -209,20 +209,20 @@ public class ExifProfileTests Assert.True(software.TrySetValue(15)); Assert.False(software.TrySetValue(15F)); - image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55)); + image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new(75.55)); IExifValue shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(7555, 100), shutterSpeed.Value); + Assert.Equal(new(7555, 100), shutterSpeed.Value); Assert.False(shutterSpeed.TrySetValue(75)); - image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0)); + image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new(150.0)); // We also need to change this value because this overrides XResolution when the image is written. image.Metadata.HorizontalResolution = 150.0; IExifValue xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150, 1), xResolution.Value); + Assert.Equal(new(150, 1), xResolution.Value); Assert.False(xResolution.TrySetValue("ImageSharp")); @@ -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); @@ -251,10 +251,10 @@ public class ExifProfileTests Assert.Equal("15", software.Value); shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(75.55), shutterSpeed.Value); + Assert.Equal(new(75.55), shutterSpeed.Value); xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150.0), xResolution.Value); + Assert.Equal(new(150.0), xResolution.Value); referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite, false); Assert.Null(referenceBlackWhite); @@ -308,11 +308,11 @@ public class ExifProfileTests [Fact] public void Syncs() { - var exifProfile = new ExifProfile(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + ExifProfile exifProfile = new(); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(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() { FileFormat = fileFormat }); image.Dispose(); memStream.Position = 0; @@ -593,7 +593,7 @@ public class ExifProfileTests Assert.Equal("Windows Photo Editor 10.0.10011.16384", software.Value); IExifValue xResolution = profile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(300.0), xResolution.Value); + Assert.Equal(new(300.0), xResolution.Value); IExifValue xDimension = profile.GetValue(ExifTag.PixelXDimension); Assert.Equal(2338U, xDimension.Value); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs index 8fe19b37de..dcdc5f0f38 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 ExifReader(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 ExifReader(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 1154b3439c..4ba259f391 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(); 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 99cafa8960..bf6018c652 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -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 Rational(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 SignedRational(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 EncodedString(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/DataReader/IccDataReaderCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs index 86c6a5e9f2..9f089f4829 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderCurvesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs index a686d44872..817832807c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderLutTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs index 930665a07c..030cf0df45 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs @@ -55,6 +55,6 @@ public class IccDataReaderMultiProcessElementTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs index ee0464bb23..f4f89d11dc 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs @@ -122,6 +122,6 @@ public class IccDataReaderNonPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs index 9c5be4c675..77e334a49c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs @@ -82,6 +82,6 @@ public class IccDataReaderPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index e0cfa65431..735a6abf7f 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -442,6 +442,6 @@ public class IccDataReaderTagDataEntryTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index 9c4abfe3e6..79a8fb263c 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 IccProfile(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 24671aa3c5..ffc4ed2eb8 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 IccProfile { 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 968fa86c4e..e56f7f182c 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 IccProfileId(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 1a52ade629..36df7da0ca 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(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(); @@ -228,7 +228,7 @@ public class IptcProfileTests { // arrange using Image image = new(1, 1); - image.Metadata.IptcProfile = new IptcProfile(); + image.Metadata.IptcProfile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; image.Metadata.IptcProfile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -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"); @@ -380,12 +380,12 @@ public class IptcProfileTests private static void ContainsIptcValue(List values, IptcTag tag, string value) { Assert.True(values.Any(val => val.Tag == tag), $"Missing iptc tag {tag}"); - Assert.True(values.Contains(new IptcValue(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); + Assert.True(values.Contains(new(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); } 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 5dc6ac6db7..1c253bbbeb 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 Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new GifEncoder(); + GifEncoder encoder = new GifEncoder(); // 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 Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new JpegEncoder(); // 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 JpegEncoder(); // 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 Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new PngEncoder(); // 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 Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Frames.RootFrame.Metadata.XmpProfile = original; - var encoder = new TiffEncoder(); + TiffEncoder encoder = new TiffEncoder(); // 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 Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new WebpEncoder(); + WebpEncoder encoder = new WebpEncoder(); // 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 XmpProfile(data); return profile; } private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index f9cefaddda..9e7e3b7a09 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -70,19 +70,19 @@ public class RationalTests Assert.Equal(7U, rational.Numerator); Assert.Equal(55U, rational.Denominator); - rational = new Rational(755, 100); + rational = new(755, 100); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(755, 100, false); + rational = new(755, 100, false); Assert.Equal(755U, rational.Numerator); Assert.Equal(100U, rational.Denominator); - rational = new Rational(-7.55); + rational = new(-7.55); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(7); + rational = new(7); Assert.Equal(7U, rational.Numerator); Assert.Equal(1U, rational.Denominator); } @@ -101,7 +101,7 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new Rational(2, 0); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); } @@ -111,19 +111,19 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new Rational(double.PositiveInfinity); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new Rational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new Rational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs index 04183571b5..275ba4d5f5 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,27 +47,27 @@ 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); - rational = new SignedRational(-755, 100); + rational = new(-755, 100); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(-755, -100, false); + rational = new(-755, -100, false); Assert.Equal(-755, rational.Numerator); Assert.Equal(-100, rational.Denominator); - rational = new SignedRational(-151, -20); + rational = new(-151, -20); Assert.Equal(-151, rational.Numerator); Assert.Equal(-20, rational.Denominator); - rational = new SignedRational(-7.55); + rational = new(-7.55); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(7); + rational = new(7); Assert.Equal(7, rational.Numerator); Assert.Equal(1, rational.Denominator); } @@ -75,43 +75,43 @@ 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); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); - rational = new SignedRational(-2, 0); + rational = new(-2, 0); Assert.Equal(double.NegativeInfinity, rational.ToDouble()); } [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); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new SignedRational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ NegativeInfinity ]", rational.ToString()); - rational = new SignedRational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new SignedRational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new SignedRational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index 4b4e84b4b3..4b348b88f8 100644 --- a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -101,7 +101,7 @@ public class A8Tests const byte expected = byte.MaxValue; // act - A8 alpha = A8.FromBgra5551(new Bgra5551(0.0f, 0.0f, 0.0f, 1.0f)); + A8 alpha = A8.FromBgra5551(new(0.0f, 0.0f, 0.0f, 1.0f)); // assert Assert.Equal(expected, alpha.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs index 98fdce5dbd..4156503210 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs @@ -96,7 +96,7 @@ public class Abgr32Tests [Fact] public void FromRgba32() { - Abgr32 abgr = Abgr32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Abgr32 abgr = Abgr32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, abgr.R); Assert.Equal(2, abgr.G); @@ -136,7 +136,7 @@ public class Abgr32Tests const uint expected = uint.MaxValue; // act - Abgr32 abgr = Abgr32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Abgr32 abgr = Abgr32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, abgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs index bcaf9265a3..8e05c5ca0f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs @@ -128,7 +128,7 @@ public class Argb32Tests const uint expected = uint.MaxValue; // act - Argb32 argb = Argb32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Argb32 argb = Argb32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, argb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index 362e20bbae..a7e4a08f0d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -80,7 +80,7 @@ public class Bgr24Tests [Fact] public void FromRgba32() { - Bgr24 rgb = Bgr24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgr24 rgb = Bgr24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -115,7 +115,7 @@ public class Bgr24Tests public void Bgr24_FromBgra5551() { // act - Bgr24 bgr = Bgr24.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Bgr24 bgr = Bgr24.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(255, bgr.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs index 3c4a104233..f74660731c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs @@ -17,8 +17,8 @@ public class Bgr565Tests public void AreEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(0.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 1.0f)); + Bgr565 color2 = new(new(0.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 1.0f)); Bgr565 color4 = new(1.0f, 0.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgr565Tests public void AreNotEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(1.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 0.0f)); + Bgr565 color2 = new(new(1.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 0.0f)); Bgr565 color4 = new(1.0f, 1.0f, 0.0f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr = Bgr565.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -115,8 +115,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -131,8 +131,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -159,7 +159,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -172,7 +172,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -185,7 +185,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -198,7 +198,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -211,7 +211,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL8(new L8(byte.MaxValue)); + Bgr565 bgr = Bgr565.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -224,7 +224,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL16(new L16(ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 277975896e..d0150c808b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -96,7 +96,7 @@ public class Bgra32Tests [Fact] public void FromRgba32() { - Bgra32 bgra = Bgra32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgra32 bgra = Bgra32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, bgra.R); Assert.Equal(2, bgra.G); @@ -136,7 +136,7 @@ public class Bgra32Tests const uint expected = uint.MaxValue; // act - Bgra32 bgra = Bgra32.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra32 bgra = Bgra32.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs index 5d20b5cf12..166a069402 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs @@ -17,8 +17,8 @@ public class Bgra4444Tests public void AreEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(0.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + Bgra4444 color2 = new(new(0.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 1.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 0.0f, 1.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra4444Tests public void AreNotEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(1.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + Bgra4444 color2 = new(new(1.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 0.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 1.0f, 0.0f, 1.0f); Assert.NotEqual(color1, color2); @@ -114,7 +114,7 @@ public class Bgra4444Tests const ushort expected = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra4444 pixel = Bgra4444.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -127,7 +127,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra4444 pixel = Bgra4444.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -141,8 +141,8 @@ public class Bgra4444Tests const ushort expectedPackedValue2 = 0xFF0F; // act - Bgra4444 bgra1 = Bgra4444.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra4444 bgra2 = Bgra4444.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra4444 bgra1 = Bgra4444.FromRgba32(new(255, 255, 255, 255)); + Bgra4444 bgra2 = Bgra4444.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -156,7 +156,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -169,7 +169,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -182,7 +182,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL16(new L16(ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -195,7 +195,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL8(new L8(byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -208,7 +208,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -221,7 +221,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs index 38f809e49f..a19f0e9a19 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs @@ -17,8 +17,8 @@ public class Bgra5551Tests public void AreEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(0.0f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(0.0f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 0.0f, 0.0f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra5551Tests public void AreNotEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(1f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(1f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -134,8 +134,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromRgba32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -150,8 +150,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromBgra32(new Bgra32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromBgra32(new Bgra32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromBgra32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromBgra32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -165,7 +165,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra5551 pixel = Bgra5551.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -178,7 +178,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -191,7 +191,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -204,7 +204,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL16(new L16(ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -217,7 +217,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL8(new L8(byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -230,7 +230,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -243,7 +243,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs index e73d646408..51c7ec4dbb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs @@ -17,8 +17,8 @@ public class Byte4Tests public void AreEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(0f)); - Byte4 color3 = new(new Vector4(1f, 0f, 1f, 1f)); + Byte4 color2 = new(new(0f)); + Byte4 color3 = new(new(1f, 0f, 1f, 1f)); Byte4 color4 = new(1f, 0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Byte4Tests public void AreNotEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(1f)); - Byte4 color3 = new(new Vector4(1f, 0f, 0f, 1f)); + Byte4 color2 = new(new(1f)); + Byte4 color3 = new(new(1f, 0f, 0f, 1f)); Byte4 color4 = new(1f, 1f, 0f, 1f); Assert.NotEqual(color1, color2); @@ -111,7 +111,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromArgb32(new Argb32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -124,7 +124,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -137,7 +137,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL8(new L8(byte.MaxValue)); + Byte4 pixel = Byte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -150,7 +150,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL16(new L16(ushort.MaxValue)); + Byte4 pixel = Byte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -163,7 +163,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -176,7 +176,7 @@ public class Byte4Tests const uint expected = 0xFFFFFFFF; // act - Byte4 pixel = Byte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Byte4 pixel = Byte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -189,7 +189,7 @@ public class Byte4Tests const uint expectedPackedValue1 = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue1, pixel.PackedValue); @@ -202,7 +202,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -215,7 +215,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs index c5a89df1e9..d723aac47a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs @@ -76,7 +76,7 @@ public class HalfVector2Tests public void HalfVector2_FromBgra5551() { // act - HalfVector2 pixel = HalfVector2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + HalfVector2 pixel = HalfVector2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Vector4 actual = pixel.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs index 16c78a23d3..5717118009 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs @@ -73,7 +73,7 @@ public class HalfVector4Tests Vector4 expected = Vector4.One; // act - HalfVector4 pixel = HalfVector4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + HalfVector4 pixel = HalfVector4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 7f0a4217c1..5631bbc7e0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -115,7 +115,7 @@ public class L16Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - L16 pixel = L16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L16 pixel = L16.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.PackedValue; // Assert @@ -149,7 +149,7 @@ public class L16Tests const ushort expected = ushort.MaxValue; // act - L16 pixel = L16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + L16 pixel = L16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index 1ca865ef41..b1c94c754b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -114,7 +114,7 @@ public class L8Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - L8 pixel = L8.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L8 pixel = L8.FromRgba32(new(rgb, rgb, rgb)); byte actual = pixel.PackedValue; // Assert @@ -145,7 +145,7 @@ public class L8Tests const byte expected = byte.MaxValue; // act - L8 grey = L8.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + L8 grey = L8.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, grey.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index f6cbfc4426..d82afdff1e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -116,7 +116,7 @@ public class La16Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - La16 gray = La16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La16 gray = La16.FromRgba32(new(rgb, rgb, rgb)); byte actual = gray.L; // Assert @@ -148,7 +148,7 @@ public class La16Tests const byte expected = byte.MaxValue; // act - La16 grey = La16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + La16 grey = La16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, grey.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs index fd5556d3bc..571aa3fd03 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -119,7 +119,7 @@ public class La32Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - La32 pixel = La32.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La32 pixel = La32.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.L; // Assert @@ -154,7 +154,7 @@ public class La32Tests const ushort expected = ushort.MaxValue; // act - La32 pixel = La32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + La32 pixel = La32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs index ffbddb1398..c6a14518a7 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs @@ -32,8 +32,8 @@ public class NormalizedByte2Tests [Fact] public void NormalizedByte2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); } [Fact] @@ -74,7 +74,7 @@ public class NormalizedByte2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs index 5a025f6c4e..40d81cad66 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedByte4Tests public void AreEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(0.0f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedByte4 color2 = new(new(0.0f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedByte4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedByte4Tests public void AreNotEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(1f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedByte4 color2 = new(new(1f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedByte4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -98,7 +98,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -111,7 +111,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -124,7 +124,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL8(new L8(byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -137,7 +137,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL16(new L16(ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -150,7 +150,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -163,7 +163,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -176,7 +176,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); @@ -189,7 +189,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -202,7 +202,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs index be7b390527..f153f6aea2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs @@ -36,8 +36,8 @@ public class NormalizedShort2Tests [Fact] public void NormalizedShort2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); } [Fact] @@ -78,7 +78,7 @@ public class NormalizedShort2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort2.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs index 281ae7ee52..cf0c3e8195 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedShort4Tests public void AreEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(0.0f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedShort4 color2 = new(new(0.0f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedShort4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedShort4Tests public void AreNotEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(1f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedShort4 color2 = new(new(1f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedShort4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -99,7 +99,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -112,7 +112,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -125,7 +125,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL8(new L8(byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -138,7 +138,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL16(new L16(ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -151,7 +151,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -164,7 +164,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -177,7 +177,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -190,7 +190,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -216,7 +216,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort4.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs index 924e94d929..2e66115b0d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs @@ -44,14 +44,14 @@ public class PixelBlenderTests public static TheoryData ColorBlendingExpectedResults = new() { { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Normal, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new Rgba32(0xFFC62D32) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new Rgba32(0xFFDDCEFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new Rgba32(0xFF701919) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new Rgba32(0xFFE1E4FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new Rgba32(0xFFFFFDFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new Rgba32(0xFF71CBE6) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new Rgba32(0xFF631619) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new(0xFFEEE7FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new(0xFFC62D32) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new(0xFFDDCEFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new(0xFF701919) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new(0xFFE1E4FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new(0xFFFFFDFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new(0xFF71CBE6) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new(0xFF631619) }, }; [Theory] @@ -67,17 +67,17 @@ public class PixelBlenderTests public static TheoryData AlphaCompositionExpectedResults = new() { - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Dest, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestAtop, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestIn, Color.MistyRose.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOver, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Src, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcAtop, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcIn, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOver, Color.MidnightBlue.ToPixel() }, }; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index 976a272ebf..908625e17a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -16,8 +16,8 @@ public class PorterDuffFunctionsTests public static TheoryData NormalBlendFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) } }; [Theory] @@ -47,9 +47,9 @@ public class PorterDuffFunctionsTests public static TheoryData MultiplyFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, - { new TestVector4(0.9f, 0.9f, 0.9f, 0.9f), new TestVector4(0.4f, 0.4f, 0.4f, 0.4f), .5f, new TestVector4(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) }, + { new(0.9f, 0.9f, 0.9f, 0.9f), new(0.4f, 0.4f, 0.4f, 0.4f), .5f, new(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } }; [Theory] @@ -79,9 +79,9 @@ public class PorterDuffFunctionsTests public static TheoryData AddFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(0.24324325f, 0.24324325f, 0.24324325f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(0.24324325f, 0.24324325f, 0.24324325f, .37f) } }; [Theory] @@ -111,9 +111,9 @@ public class PorterDuffFunctionsTests public static TheoryData SubtractFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(0, 0, 0, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2027027f, .2027027f, .2027027f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(0, 0, 0, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2027027f, .2027027f, .2027027f, .37f) } }; [Theory] @@ -143,9 +143,9 @@ public class PorterDuffFunctionsTests public static TheoryData ScreenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2383784f, .2383784f, .2383784f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2383784f, .2383784f, .2383784f, .37f) } }; [Theory] @@ -175,9 +175,9 @@ public class PorterDuffFunctionsTests public static TheoryData DarkenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2189189f, .2189189f, .2189189f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(.6f, .6f, .6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2189189f, .2189189f, .2189189f, .37f) } }; [Theory] @@ -207,9 +207,9 @@ public class PorterDuffFunctionsTests public static TheoryData LightenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.227027f, .227027f, .227027f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.227027f, .227027f, .227027f, .37f) }, }; [Theory] @@ -239,9 +239,9 @@ public class PorterDuffFunctionsTests public static TheoryData OverlayFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] @@ -271,9 +271,9 @@ public class PorterDuffFunctionsTests public static TheoryData HardLightFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index d375a74c67..4c15fda313 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -12,10 +12,10 @@ public class PorterDuffFunctionsTestsTPixel private static Span AsSpan(T value) where T : struct { - return new Span(new[] { value }); + return new(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/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 32b62fc03d..6d5013cde0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -117,7 +117,7 @@ public abstract class PixelOperationsTests : MeasureFixture const byte alpha = byte.MinValue; const byte noAlpha = byte.MaxValue; - TPixel pixel = TPixel.FromRgba32(new Rgba32(0, 0, 0, alpha)); + TPixel pixel = TPixel.FromRgba32(new(0, 0, 0, alpha)); Rgba32 dest = pixel.ToRgba32(); @@ -480,7 +480,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromArgb32(new Argb32(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); + expected[i] = TPixel.FromArgb32(new(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); } TestOperation( @@ -524,7 +524,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromBgr24(new Bgr24(source[i3 + 2], source[i3 + 1], source[i3])); + expected[i] = TPixel.FromBgr24(new(source[i3 + 2], source[i3 + 1], source[i3])); } TestOperation( @@ -566,7 +566,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromBgra32(new Bgra32(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); + expected[i] = TPixel.FromBgra32(new(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); } TestOperation( @@ -609,7 +609,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromAbgr32(new Abgr32(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); + expected[i] = TPixel.FromAbgr32(new(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); } TestOperation( @@ -863,7 +863,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromRgb24(new Rgb24(source[i3 + 0], source[i3 + 1], source[i3 + 2])); + expected[i] = TPixel.FromRgb24(new(source[i3 + 0], source[i3 + 1], source[i3 + 2])); } TestOperation( @@ -905,7 +905,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromRgba32(new Rgba32(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); + expected[i] = TPixel.FromRgba32(new(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); } TestOperation( diff --git a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs index b2790469a1..c4e2fc7a2e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs @@ -69,7 +69,7 @@ public class Rg32Tests const uint expected = 0xFFFFFFFF; // act - Rg32 rg32 = Rg32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rg32 rg32 = Rg32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rg32.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index 6364378c15..22c977dcca 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -68,7 +68,7 @@ public class Rgb24Tests [Fact] public void FromRgba32() { - Rgb24 rgb = Rgb24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Rgb24 rgb = Rgb24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -117,7 +117,7 @@ public class Rgb24Tests public void Rgb24_FromBgra5551() { // act - Rgb24 rgb = Rgb24.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgb24 rgb = Rgb24.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(255, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs index 764627ee34..cf8e2e7e90 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs @@ -65,7 +65,7 @@ public class Rgb48Tests const ushort expected = ushort.MaxValue; // act - Rgb48 rgb = Rgb48.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgb48 rgb = Rgb48.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs index 79a1aefc9c..c342d0aa3f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs @@ -17,8 +17,8 @@ public class Rgba1010102Tests public void AreEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(0.0f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + Rgba1010102 color2 = new(new(0.0f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 1f, 1f)); Rgba1010102 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Rgba1010102Tests public void AreNotEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(1f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Rgba1010102 color2 = new(new(1f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Rgba1010102 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Rgba1010102Tests const uint expected = 0xFFFFFFFF; // act - Rgba1010102 rgba = Rgba1010102.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba1010102 rgba = Rgba1010102.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgba.PackedValue); @@ -114,7 +114,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromArgb32(new Argb32(255, 255, 255, 255)); + Rgba1010102 rgba = Rgba1010102.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -128,8 +128,8 @@ public class Rgba1010102Tests const uint expectedPackedValue2 = 0xFFF003FF; // act - Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new Rgba32(255, 255, 255, 255)); - Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new Rgba32(255, 0, 255, 255)); + Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new(255, 255, 255, 255)); + Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, rgba1.PackedValue); @@ -143,7 +143,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -156,7 +156,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL8(new L8(byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -169,7 +169,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL16(new L16(ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -182,7 +182,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -195,7 +195,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -208,7 +208,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs index 6d56185ecf..fafee5d3cb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs @@ -286,7 +286,7 @@ public class Rgba32Tests const uint expected = 0xFFFFFFFF; // act - Rgba32 rgb = Rgba32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba32 rgb = Rgba32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs index 694d0ace10..e962b41feb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs @@ -106,7 +106,7 @@ public class Rgba64Tests const ushort expected = ushort.MaxValue; // act - Rgba64 rgba = Rgba64.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgba64 rgba = Rgba64.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgba.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs index 5273482efb..daafabaa34 100644 --- a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs @@ -150,7 +150,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgb = RgbaVector.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + RgbaVector rgb = RgbaVector.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgb.ToScaledVector4()); @@ -163,7 +163,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL16(new L16(ushort.MaxValue)); + RgbaVector rgba = RgbaVector.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); @@ -176,7 +176,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL8(new L8(byte.MaxValue)); + RgbaVector rgba = RgbaVector.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs index f23da0c7a6..a9942220c7 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs @@ -36,9 +36,9 @@ public class Short2Tests [Fact] public void Short2_ToVector4() { - Assert.Equal(new Vector4(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); - Assert.Equal(new Vector4(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); + Assert.Equal(new(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); + Assert.Equal(new(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); } [Fact] @@ -140,7 +140,7 @@ public class Short2Tests public void Short2_FromBgra5551() { // act - Short2 short2 = Short2.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short2 short2 = Short2.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Vector4 actual = short2.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs index 819ff0e1e5..fd25f50866 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs @@ -190,7 +190,7 @@ public class Short4Tests Vector4 expected = Vector4.One; // act - Short4 short4 = Short4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short4 short4 = Short4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, short4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs index 9c0e83a7fe..0ea429a771 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 ecc5923264..e5162e23d4 100644 --- a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -38,12 +38,12 @@ 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); Assert.Equal(2, dense.Rows); - Assert.Equal(new Size(3, 2), dense.Size); + Assert.Equal(new(3, 2), dense.Size); } [Fact] @@ -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 c3d9e8176b..772d8bd2d0 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,11 +126,11 @@ 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); - Assert.Equal(new PointF(30, 30), pout); + PointF pout = PointF.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -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 f5c64abf52..8ade95eb14 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); } @@ -76,7 +76,7 @@ public class PointTests public void PointFConversionTest(int x, int y) { PointF p = new Point(x, y); - Assert.Equal(new PointF(x, y), p); + Assert.Equal(new(x, y), p); } [Theory] @@ -86,8 +86,8 @@ public class PointTests [InlineData(0, 0)] public void SizeConversionTest(int x, int y) { - var sz = (Size)new Point(x, y); - Assert.Equal(new Size(x, y), sz); + Size sz = (Size)new Point(x, y); + Assert.Equal(new(x, y), sz); } [Theory] @@ -97,13 +97,13 @@ 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 { - addExpected = new Point(x + y, y + x); - subExpected = new Point(x - y, y - x); + addExpected = new(x + y, y + x); + subExpected = new(x - y, y - x); } Assert.Equal(addExpected, p + s); @@ -119,14 +119,14 @@ 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 { - pCeiling = new Point((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); - pTruncate = new Point((int)x, (int)y); - pRound = new Point((int)MathF.Round(x), (int)MathF.Round(y)); + pCeiling = new((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); + pTruncate = new((int)x, (int)y); + pRound = new((int)MathF.Round(x), (int)MathF.Round(y)); } Assert.Equal(pCeiling, Point.Ceiling(pf)); @@ -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,22 +156,22 @@ 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); + Assert.Equal(new(-3, 21), pout); } [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); - Assert.Equal(new Point(30, 30), pout); + Point pout = Point.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -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 a9b3251ca3..0e8bf4f344 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 RectangleF(x, y, width, height); + PointF p = new PointF(x, y); + SizeF s = new SizeF(width, height); + RectangleF rect2 = new RectangleF(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 RectangleF(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 RectangleF(x, y, width, height); + PointF p = new PointF(x, y); + SizeF s = new SizeF(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 PointF(x, y); + RectangleF rect = new RectangleF(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 SizeF(x, y); + RectangleF rect = new RectangleF(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 RectangleF(x, y, width, height); + RectangleF rect2 = new RectangleF(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 RectangleF(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 RectangleF(10, 10, 10, 10); + RectangleF rect2 = new RectangleF(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 RectangleF(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 PointF(x1, y1); + RectangleF r = new RectangleF(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 RectangleF(x, y, width, height); + RectangleF inflatedRect = new RectangleF(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 SizeF(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 RectangleF(x, y, width, height); + RectangleF rect2 = new RectangleF(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 RectangleF(0, 0, 5, 5); + RectangleF rect2 = new RectangleF(1, 1, 3, 3); + RectangleF expected = new RectangleF(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 RectangleF(x, y, width, height); + RectangleF b = new RectangleF(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 RectangleF(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 RectangleF(x, y, width, height); + RectangleF expectedRect = new RectangleF(x + width, y + height, width, height); + PointF p = new PointF(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 RectangleF(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()); } diff --git a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs index 2ba3a77315..2a4d64147e 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(x, y), new(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,9 +68,9 @@ 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); - Assert.Equal(new Point(x, y), rect.Location); - Assert.Equal(new Size(width, height), rect.Size); + Rectangle rect = new(x, y, width, height); + Assert.Equal(new(x, y), rect.Location); + Assert.Equal(new(width, height), rect.Size); Assert.Equal(x, rect.X); Assert.Equal(y, rect.Y); @@ -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,20 +166,20 @@ 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 { - rCeiling = new Rectangle( + rCeiling = new( (int)Math.Ceiling(x), (int)Math.Ceiling(y), (int)Math.Ceiling(width), (int)Math.Ceiling(height)); - rTruncate = new Rectangle((int)x, (int)y, (int)width, (int)height); + rTruncate = new((int)x, (int)y, (int)width, (int)height); - rRound = new Rectangle( + rRound = new( (int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(width), @@ -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,10 +211,10 @@ 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)); + inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); } Assert.Equal(inflatedRect, Rectangle.Inflate(rect, width, height)); @@ -222,10 +222,10 @@ 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)); + inflatedRect = new(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); } rect.Inflate(s); @@ -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 1a36b4921a..246f21b1ee 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs @@ -20,13 +20,13 @@ 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)); - Assert.Equal(s2, new SizeF(p1)); + Assert.Equal(s1, new(p1)); + Assert.Equal(s2, new(p1)); Assert.Equal(width, s1.Width); Assert.Equal(height, s1.Height); @@ -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,11 +132,11 @@ 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(new(width, height), p1); Assert.Equal(p1, (PointF)s1); Assert.Equal(s2, (Size)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,10 +172,10 @@ 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); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -185,10 +185,10 @@ 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); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -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 eec1fb63b0..6b366e183f 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); } @@ -72,7 +72,7 @@ public class SizeTests public void PointFConversionTest(int width, int height) { SizeF sz = new Size(width, height); - Assert.Equal(new SizeF(width, height), sz); + Assert.Equal(new(width, height), sz); } [Theory] @@ -82,8 +82,8 @@ public class SizeTests [InlineData(0, 0)] public void SizeConversionTest(int width, int height) { - var sz = (Point)new Size(width, height); - Assert.Equal(new Point(width, height), sz); + Point sz = (Point)new Size(width, height); + Assert.Equal(new(width, height), sz); } [Theory] @@ -93,14 +93,14 @@ 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 { - addExpected = new Size(width + height, height + width); - subExpected = new Size(width - height, height - width); + addExpected = new(width + height, height + width); + subExpected = new(width - height, height - width); } Assert.Equal(addExpected, sz1 + sz2); @@ -116,14 +116,14 @@ 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 { - pCeiling = new Size((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); - pTruncate = new Size((int)width, (int)height); - pRound = new Size((int)MathF.Round(width), (int)MathF.Round(height)); + pCeiling = new((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); + pTruncate = new((int)width, (int)height); + pRound = new((int)MathF.Round(width), (int)MathF.Round(height)); } Assert.Equal(pCeiling, Size.Ceiling(szF)); @@ -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,12 +206,12 @@ 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 { - mulExpected = new Size(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -222,12 +222,12 @@ 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 { - mulExpected = new Size(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -258,10 +258,10 @@ 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); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -271,10 +271,10 @@ 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); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -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,10 +305,10 @@ 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); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -317,10 +317,10 @@ 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); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -341,10 +341,10 @@ 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); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -352,10 +352,10 @@ 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); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / 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/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs index 5e5887c923..1b8388ebae 100644 --- a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs @@ -18,10 +18,10 @@ public abstract class BaseImageOperationsExtensionTest : IDisposable public BaseImageOperationsExtensionTest() { - this.options = new GraphicsOptions { Antialias = false }; - this.source = new Image(91 + 324, 123 + 56); - this.rect = new Rectangle(91, 123, 324, 56); // make this random? - this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations(this.source.Configuration, this.source, false); + this.options = new() { Antialias = false }; + this.source = new(91 + 324, 123 + 56); + this.rect = new(91, 123, 324, 56); // make this random? + this.internalOperations = new(this.source.Configuration, this.source, false); this.internalOperations.SetGraphicsOptions(this.options); this.operations = this.internalOperations; } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index da2bc465f6..2337e4567d 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 476e5b0a90..2cf1c744dc 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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(5, 5); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 Size(3, 3); + Rectangle bounds = new Rectangle(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 KernelSamplingMap(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/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 6d5973dbbb..b24ab6c817 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 6531f7b442..f557183d6e 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 17f63384e0..8b2411bf2b 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; } @@ -69,7 +69,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { NonGenericProcessor = processor }); diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 87436e4a35..9cfc3a3f09 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -31,28 +31,28 @@ 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))); - Assert.Equal(new Rgb24(0, 0, 0), rgbImage[0, 0]); + Assert.Equal(new(0, 0, 0), rgbImage[0, 0]); - rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); + rgbImage = new(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]); + Assert.Equal(new(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))); - Assert.Equal(new HalfSingle(-1), halfSingleImage[0, 0]); + Assert.Equal(new(-1), halfSingleImage[0, 0]); - halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); + halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new HalfSingle(0), halfSingleImage[0, 0]); + Assert.Equal(new(0), halfSingleImage[0, 0]); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index 0c197a96f7..33deb715ba 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 e84bd243e4..f68ecef08f 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 7d3e0aed0f..89d8d47bcf 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 744e26d8f7..d53dc74b9a 100644 --- a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs @@ -22,13 +22,13 @@ public class ImageOperationTests : IDisposable public ImageOperationTests() { - this.provider = new FakeImageOperationsProvider(); + this.provider = new(); - var processorMock = new Mock(); + Mock processorMock = new(); this.processorDefinition = processorMock.Object; - this.image = new Image( - new Configuration + this.image = new( + new() { ImageOperationsProvider = this.provider }, @@ -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 88707c60ff..06eb90005a 100644 --- a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs @@ -23,18 +23,18 @@ 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() { - this.processorDefinition = new Mock(); - this.cloningProcessorDefinition = new Mock(); - this.regularProcessorImpl = new Mock>(); - this.cloningProcessorImpl = new Mock>(); + this.processorDefinition = new(); + this.cloningProcessorDefinition = new(); + this.regularProcessorImpl = new(); + this.cloningProcessorImpl = new(); } // 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 60e33835af..e37cd5db1f 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -32,14 +32,14 @@ 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++) { for (int x = 0; x < 8; x++) { byte luminance = pixels[(y * 8) + x]; - image[x, y] = new Rgba32(luminance, luminance, luminance); + image[x, y] = new(luminance, luminance, luminance); } } @@ -56,7 +56,7 @@ public class HistogramEqualizationTests }; // Act - image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions + image.Mutate(x => x.HistogramEqualization(new() { LuminanceLevels = luminanceLevels, Method = HistogramEqualizationMethod.Global @@ -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/Normalization/MagickCompareTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs index 2b609a9b2a..50c177cc0c 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs @@ -49,7 +49,7 @@ public class MagickCompareTests ?? throw new InvalidOperationException("CompareToMagick() works only with file providers!"); TestFile testFile = TestFile.Create(path); - return new FileStream(testFile.FullPath, FileMode.Open); + return new(testFile.FullPath, FileMode.Open); } private static Image ConvertImageFromMagick(MagickImage magickImage) diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 7eec6eb0c1..be92633341 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 Rectangle(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 1602b5c7a2..14dcc7438e 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 Rectangle(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 9694aeb222..18f62c1717 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -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 Rectangle(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 Rectangle(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 ecbbb21abd..a94c759751 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -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 Rectangle(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 Rectangle(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 Rectangle(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/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index f045c981eb..9c1ffbbef8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -108,9 +108,9 @@ public class BokehBlurTest public static readonly TheoryData BokehBlurValues = new() { - new BokehBlurInfo { Radius = 8, Components = 1, Gamma = 1 }, - new BokehBlurInfo { Radius = 16, Components = 1, Gamma = 3 }, - new BokehBlurInfo { Radius = 16, Components = 2, Gamma = 3 } + new() { Radius = 8, Components = 1, Gamma = 1 }, + new() { Radius = 16, Components = 1, Gamma = 3 }, + new() { Radius = 16, Components = 2, Gamma = 3 } }; public static readonly string[] TestFiles = diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index d51012f9ec..2da74377a4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -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 Rectangle(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 Rectangle(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 b8e968f73a..9e47f54cc9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -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 Image(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 10811a559e..06d3850a4f 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 } }; @@ -49,7 +49,7 @@ public class OilPaintTest [Fact] public void Issue2518_PixelComponentOutsideOfRange_ThrowsImageProcessingException() { - using Image image = new(10, 10, new RgbaVector(1, 1, 100)); + using Image image = new(10, 10, new(1, 1, 100)); Assert.Throws(() => image.Mutate(ctx => ctx.OilPaint())); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index fd732f570f..963394e7d5 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -24,7 +24,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }), appendPixelTypeToFileName: false); @@ -43,7 +43,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }, rect)); @@ -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/Quantization/OctreeQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs index c6880d3a81..cabfe30598 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs @@ -13,24 +13,24 @@ 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); - expected = new QuantizerOptions { Dither = null }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, 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); @@ -46,14 +46,14 @@ public class OctreeQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index 91cf90bc46..ed92546054 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -15,24 +15,24 @@ 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); - expected = new QuantizerOptions { Dither = null }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = null }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, 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); @@ -48,14 +48,14 @@ public class PaletteQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = null }); + quantizer = new(Palette, new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(Palette, new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs index ab4304d898..6e43fe2525 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs @@ -13,24 +13,24 @@ 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); - expected = new QuantizerOptions { Dither = null }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, 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); @@ -46,14 +46,14 @@ public class WuQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index a7855e23aa..34a8b1e587 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -213,7 +213,7 @@ public class AffineTransformTests public void Issue1911() { using Image image = new(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix3x2.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix3x2.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -227,7 +227,7 @@ public class AffineTransformTests using Image image = provider.GetImage(); AffineTransformBuilder builder = - new AffineTransformBuilder().AppendRotationDegrees(270, new Vector2(3.5f, 3.5f)); + new AffineTransformBuilder().AppendRotationDegrees(270, new(3.5f, 3.5f)); image.Mutate(x => x.BackgroundColor(Color.Red)); image.Mutate(x => x = x.Transform(builder)); @@ -246,7 +246,7 @@ public class AffineTransformTests Matrix3x2 m = Matrix3x2.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -260,9 +260,9 @@ public class AffineTransformTests { using Image image = provider.GetImage(); - Matrix3x2 m = Matrix3x2.CreateRotation(radians, new Vector2(50, 50)); + Matrix3x2 m = Matrix3x2.CreateRotation(radians, new(50, 50)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 6a61538ea1..21e218d4c1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -44,7 +44,7 @@ public class AutoOrientTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); image.Mutate(x => x.AutoOrient()); @@ -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(); @@ -79,7 +79,7 @@ public class AutoOrientTests using Image image = provider.GetImage(); using Image reference = image.Clone(); - image.Metadata.ExifProfile = new ExifProfile(bytes); + image.Metadata.ExifProfile = new(bytes); image.Mutate(x => x.AutoOrient()); image.DebugSave(provider, $"{dataType}-{orientationCode}", appendPixelTypeToFileName: false); ImageComparer.Exact.VerifySimilarity(image, reference); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 18a7a9bd09..619610cc26 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest public void Crop(TestImageProvider provider, int x, int y, int w, int h) where TPixel : unmanaged, IPixel { - var rect = new Rectangle(x, y, w, h); + Rectangle rect = new Rectangle(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; provider.RunValidatingProcessorTest( ctx => ctx.Crop(rect), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index ca4b00d8aa..d587bc7e05 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -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 84d834cc50..96e7702d8e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs @@ -34,33 +34,33 @@ 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, - new ResizeOptions + new() { Mode = ResizeMode.Min, Size = target }); Assert.Equal(sourceSize, size); - Assert.Equal(new Rectangle(0, 0, sourceSize.Width, sourceSize.Height), rectangle); + Assert.Equal(new(0, 0, sourceSize.Width, sourceSize.Height), rectangle); } [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, - new ResizeOptions + new() { Mode = ResizeMode.Max, Size = target @@ -73,15 +73,15 @@ 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, - new ResizeOptions + new() { Mode = ResizeMode.Crop, Size = target @@ -94,15 +94,15 @@ 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, - new ResizeOptions + new() { Mode = ResizeMode.BoxPad, Size = target @@ -115,15 +115,15 @@ 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, - new ResizeOptions + new() { Mode = ResizeMode.Pad, Size = target @@ -136,15 +136,15 @@ 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, - new ResizeOptions + new() { Mode = ResizeMode.Stretch, Size = target diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 290a3b37ac..2c897588ea 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++) { @@ -80,10 +80,10 @@ public partial class ResizeKernelMapTests float[] floatVals = values.Select(v => (float)v).ToArray(); - result.Add(new ReferenceKernel(left, floatVals)); + result.Add(new(left, floatVals)); } - return new ReferenceKernelMap(result.ToArray()); + return new(result.ToArray()); } } @@ -103,7 +103,7 @@ public partial class ResizeKernelMapTests public static implicit operator ReferenceKernel(ResizeKernel orig) { - return new ReferenceKernel(orig.StartIndex, orig.Values.ToArray()); + return new(orig.StartIndex, orig.Values.ToArray()); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index c6da46ee2f..f1309f3310 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -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 ApproximateFloatComparer(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 StringBuilder(); if (kernelMap is ResizeKernelMap actualMap) { @@ -193,7 +193,7 @@ public partial class ResizeKernelMapTests private static TheoryData GenerateImageResizeData() { - var result = new TheoryData(); + TheoryData result = new TheoryData(); 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 d1b005ee4e..b4cf089757 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -78,7 +78,7 @@ public class ResizeTests // resizing: (15, 12) -> (10, 6) // kernel dimensions: (3, 4) using Image image = provider.GetImage(); - Size destSize = new Size(image.Width * wN / wD, image.Height * hN / hD); + Size destSize = new(image.Width * wN / wD, image.Height * hN / hD); image.Mutate(x => x.Resize(destSize, KnownResamplers.Bicubic, false)); FormattableString outputInfo = $"({wN}÷{wD},{hN}÷{hD})"; image.DebugSave(provider, outputInfo, appendPixelTypeToFileName: false); @@ -106,7 +106,7 @@ public class ResizeTests Configuration configuration = Configuration.CreateDefaultInstance(); int workingBufferSizeHintInBytes = workingBufferLimitInRows * destSize.Width * SizeOfVector4; - TestMemoryAllocator allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.EnableNonThreadSafeLogging(); configuration.MemoryAllocator = allocator; configuration.WorkingBufferSizeHintInBytes = workingBufferSizeHintInBytes; @@ -211,7 +211,7 @@ public class ResizeTests provider.RunValidatingProcessorTest( x => { - ResizeOptions resizeOptions = new ResizeOptions() + ResizeOptions resizeOptions = new() { Size = x.GetCurrentSize() / 2, Mode = ResizeMode.Crop, @@ -346,7 +346,7 @@ public class ResizeTests "invalid dimensional input for Resize_WorksWithAllResamplers!"); } - newSize = new SizeF(specificDestWidth.Value, specificDestHeight.Value); + newSize = new(specificDestWidth.Value, specificDestHeight.Value); destSizeInfo = $"{newSize.Width}x{newSize.Height}"; } @@ -365,12 +365,12 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Rectangle sourceRectangle = new Rectangle( + Rectangle sourceRectangle = new( image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); - Rectangle destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); + Rectangle destRectangle = new(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); image.Mutate( x => x.Resize( @@ -437,9 +437,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height + 200), + Size = new(image.Width + 200, image.Height + 200), Mode = ResizeMode.BoxPad, PadColor = Color.HotPink }; @@ -456,7 +456,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width, image.Height / 2) }; + ResizeOptions options = new() { Size = new(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -470,7 +470,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width / 2, image.Height) }; + ResizeOptions options = new() { Size = new(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -484,9 +484,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(480, 600), + Size = new(480, 600), Mode = ResizeMode.Crop }; @@ -502,7 +502,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() { Size = new(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); @@ -516,9 +516,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), + Size = new((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min }; @@ -534,9 +534,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height), + Size = new(image.Width + 200, image.Height), Mode = ResizeMode.Pad, PadColor = Color.Lavender }; @@ -553,9 +553,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width / 2, image.Height), + Size = new(image.Width / 2, image.Height), Mode = ResizeMode.Stretch }; @@ -586,8 +586,8 @@ public class ResizeTests [Fact] public void Issue1195() { - using Image image = new Image(2, 300); - Size size = new Size(50, 50); + using Image image = new(2, 300); + Size size = new(50, 50); image.Mutate(x => x .Resize( new ResizeOptions @@ -605,8 +605,8 @@ public class ResizeTests [InlineData(3, 7)] public void Issue1342(int width, int height) { - using Image image = new Image(1, 1); - Size size = new Size(width, height); + using Image image = new(1, 1); + Size size = new(width, height); image.Mutate(x => x .Resize( new ResizeOptions diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index de02502e2b..b831b0a6c1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -16,13 +16,12 @@ public class SwizzleTests { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } 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); } [Theory] @@ -35,7 +34,7 @@ public class SwizzleTests using Image expectedImage = provider.GetImage(); using Image image = provider.GetImage(); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, @@ -43,7 +42,7 @@ public class SwizzleTests appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 30c89ec339..6e35fca290 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest : BaseImageOperationsExtensionTest this.operations.Crop(width, height); CropProcessor processor = this.Verify(); - Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle); + Assert.Equal(new(0, 0, width, height), processor.CropRectangle); } [Theory] @@ -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/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index 6b6db69c11..0eb32dff75 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -20,7 +20,7 @@ public class ProjectiveTransformTests private ITestOutputHelper Output { get; } - public static readonly TheoryData ResamplerNames = new TheoryData + public static readonly TheoryData ResamplerNames = new() { nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), @@ -39,7 +39,7 @@ public class ProjectiveTransformTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData TaperMatrixData = new TheoryData + public static readonly TheoryData TaperMatrixData = new() { { TaperSide.Bottom, TaperCorner.Both }, { TaperSide.Bottom, TaperCorner.LeftOrTop }, @@ -57,10 +57,10 @@ public class ProjectiveTransformTests public static readonly TheoryData QuadDistortionData = new() { - { new PointF(0, 0), new PointF(150, 0), new PointF(150, 150), new PointF(0, 150) }, // source == destination - { new PointF(25, 50), new PointF(210, 25), new PointF(140, 210), new PointF(15, 125) }, // Distortion - { new PointF(-50, -50), new PointF(200, -50), new PointF(200, 200), new PointF(-50, 200) }, // Scaling - { new PointF(150, 0), new PointF(150, 150), new PointF(0, 150), new PointF(0, 0) }, // Rotation + { new(0, 0), new(150, 0), new(150, 150), new(0, 150) }, // source == destination + { new(25, 50), new(210, 25), new(140, 210), new(15, 125) }, // Distortion + { new(-50, -50), new(200, -50), new(200, 200), new(-50, 200) }, // Scaling + { new(150, 0), new(150, 150), new(0, 150), new(0, 0) }, // Rotation }; public ProjectiveTransformTests(ITestOutputHelper output) => this.Output = output; @@ -174,8 +174,8 @@ public class ProjectiveTransformTests [Fact] public void Issue1911() { - using var image = new Image(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix4x4.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + using Image image = new(100, 100); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix4x4.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -190,7 +190,7 @@ public class ProjectiveTransformTests Matrix4x4 m = Matrix4x4.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -204,9 +204,9 @@ public class ProjectiveTransformTests { using Image image = provider.GetImage(); - Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new Vector3(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new Vector3(50, 50, 1F)); + Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new(50, 50, 1F)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } @@ -246,7 +246,7 @@ public class ProjectiveTransformTests if (property is null) { - throw new Exception($"No resampler named {name}"); + throw new($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index f6c93ffd0e..d38658bbdb 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -64,9 +64,9 @@ public class ResizeTests : BaseImageOperationsExtensionTest bool compand = true; ResizeMode mode = ResizeMode.Stretch; - var resizeOptions = new ResizeOptions + ResizeOptions resizeOptions = new() { - Size = new Size(width, height), + Size = new(width, height), Sampler = sampler, Compand = compand, Mode = mode @@ -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 432bb5cacb..a4f4f152bb 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs @@ -13,13 +13,12 @@ public class SwizzleTests : BaseImageOperationsExtensionTest { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } 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] @@ -28,7 +27,7 @@ public class SwizzleTests : BaseImageOperationsExtensionTest int width = 5; int height = 10; - this.operations.Swizzle(new InvertXAndYSwizzler(new Size(width, height))); + this.operations.Swizzle(new InvertXAndYSwizzler(new(width, height))); SwizzleProcessor processor = this.Verify>(); Assert.Equal(processor.Swizzler.DestinationSize.Width, height); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index f046c2503c..cdc49e2a3f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -10,16 +10,16 @@ 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) }, - { Vector2.One, new Vector2(3, 1), new Vector2(10, 20), new Vector2(13, 21) }, - { new Vector2(2, 0.5f), new Vector2(3, 1), new Vector2(10, 20), new Vector2(23, 11) }, + { Vector2.One, Vector2.Zero, new(10, 20), new(10, 20) }, + { Vector2.One, new(3, 1), new(10, 20), new(13, 21) }, + { new(2, 0.5f), new(3, 1), new(10, 20), new(23, 11) }, }; [Theory] @@ -29,23 +29,23 @@ 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)); + this.AppendScale(builder, new(scale)); this.AppendTranslation(builder, translate); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.True(Comparer.Equals(expectedDest, actualDest)); } 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) }, - { new Vector2(3, 1), new Vector2(2, 0.5f), new Vector2(10, 20), new Vector2(26, 10.5f) }, + { Vector2.Zero, Vector2.One, new(10, 20), new(10, 20) }, + { new(3, 1), new(2, 0.5f), new(10, 20), new(26, 10.5f) }, }; [Theory] @@ -55,13 +55,13 @@ 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); - this.AppendScale(builder, new SizeF(scale)); + this.AppendScale(builder, new(scale)); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.Equal(expectedDest, actualDest, Comparer); } @@ -70,10 +70,10 @@ 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)); + this.AppendScale(builder, new(2, 2)); Vector2 actual = this.Execute(builder, rectangle, Vector2.One); Vector2 expected = new Vector2(-locationX + 1, -locationY + 1) * 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,9 +100,9 @@ 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 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -120,17 +120,17 @@ 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 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -147,16 +147,16 @@ 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 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -174,17 +174,17 @@ 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 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(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(); @@ -201,21 +201,21 @@ public abstract class TransformBuilderTestBase // Forwards this.AppendRotationRadians(b1, pi); this.AppendSkewRadians(b1, pi, pi); - this.AppendScale(b1, new SizeF(2, 0.5f)); - this.AppendRotationRadians(b1, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendSkewRadians(b1, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendTranslation(b1, new PointF(123, 321)); + this.AppendScale(b1, new(2, 0.5f)); + this.AppendRotationRadians(b1, pi / 2, new(-0.5f, -0.1f)); + this.AppendSkewRadians(b1, pi, pi / 2, new(-0.5f, -0.1f)); + this.AppendTranslation(b1, new(123, 321)); // Backwards - this.PrependTranslation(b2, new PointF(123, 321)); - this.PrependSkewRadians(b2, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependRotationRadians(b2, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependScale(b2, new SizeF(2, 0.5f)); + this.PrependTranslation(b2, new(123, 321)); + this.PrependSkewRadians(b2, pi, pi / 2, new(-0.5f, -0.1f)); + this.PrependRotationRadians(b2, pi / 2, new(-0.5f, -0.1f)); + this.PrependScale(b2, new(2, 0.5f)); this.PrependSkewRadians(b2, pi, pi); this.PrependRotationRadians(b2, pi); - Vector2 p1 = this.Execute(b1, rectangle, new Vector2(32, 65)); - Vector2 p2 = this.Execute(b2, rectangle, new Vector2(32, 65)); + Vector2 p1 = this.Execute(b1, rectangle, new(32, 65)); + Vector2 p2 = this.Execute(b2, rectangle, new(32, 65)); Assert.Equal(p1, p2, Comparer); } @@ -226,13 +226,13 @@ 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( () => { TBuilder builder = this.CreateBuilder(); - this.Execute(builder, new Rectangle(Point.Empty, size), Vector2.Zero); + this.Execute(builder, new(Point.Empty, size), Vector2.Zero); }); } @@ -244,7 +244,7 @@ public abstract class TransformBuilderTestBase { TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, 45, 45); - this.Execute(builder, new Rectangle(0, 0, 150, 150), Vector2.Zero); + this.Execute(builder, new(0, 0, 150, 150), Vector2.Zero); }); } diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index a1d7e358b6..fa3fcec41b 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 MemoryStream(); 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 f20ca8ce18..df531ae4c6 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 Image(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 b59542482b..18bcbffae3 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() { MaxColors = 128 }); ImageFrame frame = image.Frames[0]; quantizer.BuildPaletteAndQuantizeFrame(frame, frame.Bounds); } diff --git a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs index 28a7c49e51..d6960d7781 100644 --- a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs @@ -12,7 +12,7 @@ public class WuQuantizerTests public void SinglePixelOpaque() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); using Image image = new(config, 1, 1, Color.Black.ToPixel()); ImageFrame frame = image.Frames.RootFrame; @@ -32,7 +32,7 @@ public class WuQuantizerTests public void SinglePixelTransparent() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); using Image image = new(config, 1, 1, default(Rgba32)); ImageFrame frame = image.Frames.RootFrame; @@ -49,19 +49,19 @@ public class WuQuantizerTests } [Fact] - public void GrayScale() => TestScale(c => new Rgba32(c, c, c, 128)); + public void GrayScale() => TestScale(c => new(c, c, c, 128)); [Fact] - public void RedScale() => TestScale(c => new Rgba32(c, 0, 0, 128)); + public void RedScale() => TestScale(c => new(c, 0, 0, 128)); [Fact] - public void GreenScale() => TestScale(c => new Rgba32(0, c, 0, 128)); + public void GreenScale() => TestScale(c => new(0, c, 0, 128)); [Fact] - public void BlueScale() => TestScale(c => new Rgba32(0, 0, c, 128)); + public void BlueScale() => TestScale(c => new(0, 0, c, 128)); [Fact] - public void AlphaScale() => TestScale(c => new Rgba32(0, 0, 0, c)); + public void AlphaScale() => TestScale(c => new(0, 0, 0, c)); [Fact] public void Palette256() @@ -75,11 +75,11 @@ public class WuQuantizerTests byte b = (byte)(((i / 16) % 4) * 85); byte a = (byte)((i / 64) * 85); - image[0, i] = new Rgba32(r, g, b, a); + image[0, i] = new(r, g, b, a); } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; @@ -125,7 +125,7 @@ public class WuQuantizerTests // See https://github.com/SixLabors/ImageSharp/issues/866 using Image image = provider.GetImage(); Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -152,7 +152,7 @@ public class WuQuantizerTests } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; using (IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config)) diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index 40f54ea74c..094ba76262 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -52,7 +52,7 @@ public class IccConversionDataLutEntry values[i] = 0.1f + (i / (float)length); } - return new IccLut(values); + return new(values); } private static IccLut CreateIdentityLut(float min, float max) => new([min, max]); diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index e4adba078d..57618b9574 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -48,14 +48,14 @@ public class IccConversionDataMultiProcessElement private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) { - var curve = new IccOneDimensionalCurve(new float[0], new[] { segment }); - return new IccCurveSetProcessElement(new[] { curve }); + IccOneDimensionalCurve curve = new(new float[0], new[] { segment }); + return new(new[] { curve }); } private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) { - var curve = new IccOneDimensionalCurve(breakPoints, segments); - return new IccCurveSetProcessElement(new[] { curve }); + IccOneDimensionalCurve curve = new(breakPoints, segments); + return new(new[] { curve }); } public static object[][] MpeCurveConversionTestData = diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 6cd99367a9..cf7a99b635 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -12,11 +12,11 @@ public static class IccConversionDataTrc internal static IccCurveTagDataEntry Gamma2Curve = new(2); internal static IccCurveTagDataEntry LutCurve = new(new float[] { 0, 0.7f, 1 }); - internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new IccParametricCurve(2.2f)); - internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f)); - internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); - internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); - internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new(2.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new(2.2f, 1.5f, -0.5f)); + internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new(2.2f, 1.5f, -0.5f, 0.3f)); + internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); + internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); public static object[][] TrcArrayConversionTestData { get; } = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index 2bd47e4497..c47f6357bf 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -18,7 +18,7 @@ internal static class IccTestDataLut result[i] = i / 255f; } - return new IccLut(result); + return new(result); } private static byte[] CreateLut8() diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index 7441bede83..a31f1d05fb 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -23,7 +23,7 @@ internal static class IccTestDataProfiles public static readonly IccProfileHeader HeaderRandomWrite = CreateHeaderRandomValue( 562, // should be overwritten - new IccProfileId(1, 2, 3, 4), // should be overwritten + new(1, 2, 3, 4), // should be overwritten "ijkl"); // should be overwritten to "acsp" public static readonly IccProfileHeader HeaderRandomRead = CreateHeaderRandomValue(132, HeaderRandomIdValue, "acsp"); @@ -34,7 +34,7 @@ internal static class IccTestDataProfiles { Class = IccProfileClass.DisplayDevice, CmmType = "abcd", - CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), + CreationDate = new(1990, 11, 26, 7, 21, 42), CreatorSignature = "dcba", DataColorSpace = IccColorSpaceType.Rgb, DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, @@ -43,12 +43,12 @@ internal static class IccTestDataProfiles FileSignature = "acsp", Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, Id = id, - PcsIlluminant = new Vector3(4, 5, 6), + PcsIlluminant = new(4, 5, 6), PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, ProfileConnectionSpace = IccColorSpaceType.CieXyz, RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, Size = size, - Version = new IccVersion(4, 3, 0), + Version = new(4, 3, 0), }; public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] profileId) => ArrayHelper.Concat( diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index a83dc3575d..7e5294f854 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -339,7 +339,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new CultureInfo(language); + culture = new(language); } catch (CultureNotFoundException) { @@ -350,7 +350,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new CultureInfo($"{language}-{country}"); + culture = new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -358,7 +358,7 @@ internal static class IccTestDataTagDataEntry } } - return new IccLocalizedString(culture, text); + return new(culture, text); } private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = new[] diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index a53e508067..01c5fdae3b 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -79,7 +79,7 @@ public sealed class TestFile /// The . /// public static TestFile Create(string file) - => Cache.GetOrAdd(file, (string fileName) => new TestFile(GetInputFileFullPath(fileName))); + => Cache.GetOrAdd(file, (string fileName) => new(GetInputFileFullPath(fileName))); /// /// Gets the file name. diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index 01b1faa45a..32cac0b052 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($"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 d30ce7846d..8b2a9a9be0 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -24,8 +24,8 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestFormat() { - this.Encoder = new TestEncoder(this); - this.Decoder = new TestDecoder(this); + this.Encoder = new(this); + this.Decoder = new(this); } public List DecodeCalls { get; } = new(); @@ -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); } @@ -220,7 +220,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat using MemoryStream ms = new(); stream.CopyTo(ms, configuration.StreamProcessingBufferSize); byte[] marker = ms.ToArray().Skip(this.testFormat.header.Length).ToArray(); - this.testFormat.DecodeCalls.Add(new DecodeOperation + this.testFormat.DecodeCalls.Add(new() { Marker = marker, Config = configuration, diff --git a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs index 8ff2abd90b..90a98d1c81 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 57949e7b11..87f6f0479d 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 963c3c7835..2fb75444e3 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/EofHitCounter.cs b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs index c5ffdd6489..45a5ab5f58 100644 --- a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs +++ b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs @@ -31,7 +31,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(Configuration.Default, new MemoryStream(imageData)); Image image = Image.Load(stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public static EofHitCounter RunDecoder(byte[] imageData, T decoder, TO options) @@ -40,7 +40,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(options.GeneralOptions.Configuration, new MemoryStream(imageData)); Image image = decoder.Decode(options, stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public void Dispose() diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index 63126dcbca..a02ea399f3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -67,7 +67,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -109,7 +109,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -153,7 +153,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, BasicSerializer.Serialize(serializable), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -198,7 +198,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(serializable), intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -247,7 +247,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), BasicSerializer.Serialize(arg2), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -294,7 +294,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), arg2, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -338,7 +338,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, serializable.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -385,7 +385,7 @@ public static class FeatureTestRunner action, arg0.ToString(), arg1.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 92fc06eff5..12f8ef773c 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,12 +46,12 @@ public class ExactImageComparer : ImageComparer if (aPixel != bPixel) { - var diff = new PixelDifference(new Point(x, y), aPixel, bPixel); + PixelDifference diff = new(new(x, y), aPixel, bPixel); differences.Add(diff); } } } - return new ImageSimilarityReport(index, expected, actual, differences); + return new(index, expected, actual, differences); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 7153674e6b..dee12915b4 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( @@ -159,7 +159,7 @@ public static class ImageComparerExtensions if (outsideChanges.Any()) { - cleanedReports.Add(new ImageSimilarityReport(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); + cleanedReports.Add(new(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs index 05f65cfbbc..410ada05a2 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs @@ -19,7 +19,7 @@ public static class ImageComparingUtils ?? throw new InvalidOperationException("CompareToOriginal() works only with file providers!"); TestFile testFile = TestFile.Create(path); - using Image magickImage = DecodeWithMagick(new FileInfo(testFile.FullPath)); + using Image magickImage = DecodeWithMagick(new(testFile.FullPath)); if (useExactComparer) { ImageComparer.Exact.VerifySimilarity(magickImage, image); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index c50ae5e219..8c72bbf543 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 StringBuilder(); if (this.TotalNormalizedDifference.HasValue) { sb.AppendLine(); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index d057267da7..004c26a8f0 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(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); totalDifference += d; @@ -102,7 +102,7 @@ public class TolerantImageComparer : ImageComparer if (normalizedDifference > this.ImageThreshold) { - return new ImageSimilarityReport(index, expected, actual, differences, normalizedDifference); + return new(index, expected, actual, differences, normalizedDifference); } else { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs index 813ed505d8..d861d293b9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs @@ -78,6 +78,6 @@ public abstract partial class TestImageProvider : IXunitSerializable return x < midX ? BottomLeftColor : BottomRightColor; } - private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new Vector4(1f, 0f, 1f, 0.5f)); + private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new(1f, 0f, 1f, 0.5f)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 3652d77a1e..caa54feae5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -32,7 +32,7 @@ public abstract partial class TestImageProvider : IXunitSerializable ISpecializedDecoderOptions specialized) { Type customType = customDecoder?.GetType(); - this.commonValues = new Tuple( + this.commonValues = new( pixelType, filePath, customType); @@ -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 390195274f..6da5b75f0d 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 8f22fb2b29..88ebd6c7f6 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -152,7 +152,7 @@ public abstract partial class TestImageProvider : ITestImageProvider, IX this.MethodName = methodName; this.OutputSubfolderName = outputSubfolderName; - this.Utility = new ImagingTestCaseUtility + this.Utility = new() { SourceFileOrDescription = this.SourceFileOrDescription, PixelTypeName = this.PixelType.ToString() diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index de42ba0ccf..b5fad39292 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++) { diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs index d1149dd004..049fda727b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs @@ -92,9 +92,9 @@ public class PausedMemoryStream : MemoryStream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs index 42ed6b0d5e..54aa77be27 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs @@ -94,9 +94,9 @@ public class PausedStream : Stream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 04f59979f7..78014b7af5 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 System.Drawing.Rectangle(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 Image(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 System.Drawing.Rectangle(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 Image(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 Bitmap(w, h, PixelFormat.Format32bppArgb); + System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); BitmapData data = resultBitmap.LockBits(fullRect, ImageLockMode.ReadWrite, resultBitmap.PixelFormat); try { diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index edae08ce16..873d5bfde9 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 DiagnosticMessage(HostEnvironmentInfo.GetInformation()); messageSink.OnMessage(message); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs index 31de3909e1..53f0f06486 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 8818830351..aa94ce4696 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() { @@ -199,7 +198,7 @@ public static partial class TestEnvironment "Microsoft SDKs", "Windows"); - FileInfo corFlagsFile = Find(new DirectoryInfo(windowsSdksDir), "CorFlags.exe"); + FileInfo corFlagsFile = Find(new(windowsSdksDir), "CorFlags.exe"); string remoteExecutorPath = Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe"); @@ -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,14 +223,14 @@ 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(); if (proc.ExitCode != 0) { - throw new Exception( + throw new( $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}"); } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 994aa670c7..6a5f7f892e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -774,7 +774,7 @@ public static class TestImageExtensions { TestMemoryAllocator allocator = new(); provider.Configuration.MemoryAllocator = allocator; - return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf()); + return new(allocator, Unsafe.SizeOf()); } private class MakeOpaqueProcessor : IImageProcessor diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs index fe94cffc43..6ef2c1824f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs @@ -33,8 +33,8 @@ internal class TestMemoryAllocator : MemoryAllocator public void EnableNonThreadSafeLogging() { - this.allocationLog = new List(); - this.returnLog = new List(); + this.allocationLog = new(); + this.returnLog = new(); } public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) @@ -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) @@ -61,7 +61,7 @@ internal class TestMemoryAllocator : MemoryAllocator private void Return(BasicArrayBuffer buffer) where T : struct { - this.returnLog?.Add(new ReturnRequest(buffer.Array.GetHashCode())); + this.returnLog?.Add(new(buffer.Array.GetHashCode())); } public struct AllocationRequest @@ -83,7 +83,7 @@ internal class TestMemoryAllocator : MemoryAllocator { Type type = typeof(T); int elementSize = Marshal.SizeOf(type); - return new AllocationRequest(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); + return new(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); } public Type ElementType { get; } @@ -150,7 +150,7 @@ internal class TestMemoryAllocator : MemoryAllocator } void* ptr = (void*)this.pinHandle.AddrOfPinnedObject(); - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs index 50e086d579..2604aa1de9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs @@ -34,9 +34,9 @@ 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); + return new(pixelArray); } protected override void Dispose(bool disposing) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index f0344e2b9c..42b2b2a256 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -35,7 +35,7 @@ public class TestPixel : IXunitSerializable public float Alpha { get; set; } - public TPixel AsPixel() => TPixel.FromScaledVector4(new Vector4(this.Red, this.Green, this.Blue, this.Alpha)); + public TPixel AsPixel() => TPixel.FromScaledVector4(new(this.Red, this.Green, this.Blue, this.Alpha)); internal Span AsSpan() => new([this.AsPixel()]); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index fbdfb9d619..39c8c4c944 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -69,7 +69,7 @@ public static class TestUtils Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new La16(expected[cnt++], expected[cnt++]); + row[x] = new(expected[cnt++], expected[cnt++]); } } }); @@ -393,7 +393,7 @@ public static class TestUtils if (property is null) { - throw new Exception($"No dither named '{name}"); + throw new($"No dither named '{name}"); } return (IDither)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs index 350333965a..4130d89da1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs @@ -35,7 +35,7 @@ public class TestVector4 : IXunitSerializable public Vector4 AsVector() { - return new Vector4(this.X, this.Y, this.Z, this.W); + return new(this.X, this.Y, this.Z, this.W); } public void Deserialize(IXunitSerializationInfo info) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index 52447b6c2c..f4944992a1 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 DerivedObj() { 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 4c1a740e2b..649c626a14 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,13 +66,13 @@ 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)); PixelDifference diff = ex.Reports.Single().Differences.Single(); - Assert.Equal(new Point(3, 1), diff.Position); + Assert.Equal(new(3, 1), diff.Position); } } } @@ -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); } } @@ -131,7 +131,7 @@ public class ImageComparerTests IEnumerable reports = ImageComparer.Exact.CompareImages(image, clone); PixelDifference difference = reports.Single().Differences.Single(); - Assert.Equal(new Point(42, 43), difference.Position); + Assert.Equal(new(42, 43), difference.Position); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 6e1eba28e8..90e7261942 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 MeasureFixture(this.Output); measure.Measure( times, () => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 4608583791..4a88cfb1b4 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 System.Drawing.Bitmap(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 PngEncoder { 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 System.Drawing.Bitmap(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 System.Drawing.Bitmap(path); using Image resaved = SystemDrawingBridge.From24bppRgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; comparer.VerifySimilarity(original, resaved); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 46fb7159e8..520f40e72a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -83,7 +83,7 @@ public class TestUtilityExtensionsTests PixelTypes pt, IEnumerable> pixelTypesExp) { - Assert.Contains(new KeyValuePair(pt, typeof(T)), pixelTypesExp); + Assert.Contains(new(pt, typeof(T)), pixelTypesExp); } [Fact]