diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs index f3196a8e89..347d243ae7 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs @@ -94,7 +94,7 @@ protected override void OnFrameApply(ImageFrame source, Rectangle source } float yPlusOne = y + 1; - for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) + for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction) { int pointsFound = region.Scan(subPixel + offset, buffer, configuration); if (pointsFound == 0) @@ -192,4 +192,4 @@ private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush) return this.definition.Options.IsOpaqueColorWithoutBlending(solidBrush.Color); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs index 0c8d23c69b..b3c336c885 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs @@ -135,21 +135,22 @@ private class CachingGlyphRenderer : IGlyphRenderer, IDisposable private readonly PathBuilder builder; - private Point currentRenderPosition = default; - private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams = default; - private readonly int offset = 0; - private PointF currentPoint = default(PointF); + private Point currentRenderPosition; + private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams; + private readonly int offset; + private PointF currentPoint; private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData> glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>(); - private readonly bool renderOutline = false; - private readonly bool renderFill = false; - private bool rasterizationRequired = false; + private readonly bool renderOutline; + private readonly bool renderFill; + private bool rasterizationRequired; public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill) { this.MemoryAllocator = memoryAllocator; + this.currentRenderPosition = default; this.Pen = pen; this.renderFill = renderFill; this.renderOutline = pen != null; @@ -326,7 +327,7 @@ private Buffer2D Render(IPath path) bool scanlineDirty = false; float yPlusOne = y + 1; - for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) + for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction) { var start = new PointF(path.Bounds.Left - 1, subPixel); var end = new PointF(path.Bounds.Right + 1, subPixel); diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs index 6bb5adc060..64532af274 100644 --- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs +++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Threading.Tasks; @@ -16,7 +16,7 @@ internal static class ConfigurationExtensions /// public static ParallelOptions GetParallelOptions(this Configuration configuration) { - return new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index 310765f698..a39d10b6b8 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -231,7 +231,7 @@ public static void DestinationShouldNotBeTooShort( { if (destination.Length < source.Length) { - ThrowArgumentException($"Destination span is too short!", destinationParamName); + ThrowArgumentException("Destination span is too short!", destinationParamName); } } @@ -251,7 +251,7 @@ public static void DestinationShouldNotBeTooShort( { if (destination.Length < source.Length) { - ThrowArgumentException($"Destination span is too short!", destinationParamName); + ThrowArgumentException("Destination span is too short!", destinationParamName); } } diff --git a/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs b/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs index 2c2d045a57..1e7299720d 100644 --- a/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs +++ b/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -61,7 +61,7 @@ public static void IterateRows( int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; Parallel.For( 0, @@ -109,7 +109,7 @@ public static void IterateRowsWithTempBuffer( int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; Parallel.For( 0, @@ -158,4 +158,4 @@ private static void ValidateRectangle(Rectangle rectangle) $"{nameof(rectangle)}.{nameof(rectangle.Height)}"); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs b/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs index 661275fc90..16421cfb0c 100644 --- a/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs @@ -62,7 +62,7 @@ public static BmpFileHeader Parse(Span data) return MemoryMarshal.Cast(data)[0]; } - public unsafe void WriteTo(Span buffer) + public void WriteTo(Span buffer) { ref BmpFileHeader dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); diff --git a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs index 4d7f781001..9ede660705 100644 --- a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs @@ -447,7 +447,7 @@ public void WriteV3Header(Span buffer) /// Writes a complete Bitmap V4 header to a buffer. /// /// The buffer to write to. - public unsafe void WriteV4Header(Span buffer) + public void WriteV4Header(Span buffer) { ref BmpInfoHeader dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index b756427ccb..912e6c04d8 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -84,7 +84,7 @@ public void Encode(Image image, Stream stream) bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global; // Quantize the image returning a palette. - IQuantizedFrame quantized = null; + IQuantizedFrame quantized; using (IFrameQuantizer frameQuantizer = this.quantizer.CreateFrameQuantizer(image.GetConfiguration())) { quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index c50812e253..e8a298c5ab 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -124,7 +124,7 @@ private void ParseBaselineData() } } - private unsafe void ParseBaselineDataInterleaved() + private void ParseBaselineDataInterleaved() { // Interleaved int mcu = 0; @@ -196,7 +196,7 @@ ref Unsafe.Add(ref blockRef, blockCol), } } - private unsafe void ParseBaselineDataNonInterleaved() + private void ParseBaselineDataNonInterleaved() { JpegComponent component = this.components[this.frame.ComponentOrder[0]]; ref HuffmanScanBuffer buffer = ref this.scanBuffer; @@ -366,7 +366,7 @@ ref Unsafe.Add(ref blockRef, blockCol), } } - private unsafe void ParseProgressiveDataNonInterleaved() + private void ParseProgressiveDataNonInterleaved() { JpegComponent component = this.components[this.frame.ComponentOrder[0]]; ref HuffmanScanBuffer buffer = ref this.scanBuffer; diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 5a846ac3e2..632460ec43 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -59,7 +59,7 @@ internal static class PngConstants /// /// The dictionary of available color types. /// - public static readonly Dictionary ColorTypes = new Dictionary() + public static readonly Dictionary ColorTypes = new Dictionary { [PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 }, [PngColorType.Rgb] = new byte[] { 8, 16 }, diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 25dc5a1e0e..465139b2e5 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -147,7 +147,7 @@ public static IImageFormat DetectFormat(ReadOnlySpan data) /// The configuration. /// The byte array containing encoded image data to read the header from. /// The mime type or null if none found. - public static unsafe IImageFormat DetectFormat(Configuration config, ReadOnlySpan data) + public static IImageFormat DetectFormat(Configuration config, ReadOnlySpan data) { int maxHeaderSize = config.MaxHeaderSize; if (maxHeaderSize <= 0) @@ -351,7 +351,7 @@ public static Image Load(ReadOnlySpan data, out IImageFormat format) => /// The configuration options. /// The byte span containing image data. /// A new . - public static unsafe Image Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _); + public static Image Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _); /// /// Load a new instance of from the given encoded byte span. @@ -395,4 +395,4 @@ public static unsafe Image Load( } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index 982f8d8f29..ef1066d498 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -267,7 +267,7 @@ internal ImageFrame CloneAs(Configuration configuration) ParallelHelper.IterateRows( this.Bounds(), configuration, - (rows) => + rows => { for (int y = rows.Min; y < rows.Max; y++) { diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index 096493f2ba..59247aa2d2 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -41,7 +41,7 @@ public static unsafe void CopyColumns( fixed (byte* ptr = span) { - byte* basePtr = (byte*)ptr; + byte* basePtr = ptr; for (int y = 0; y < buffer.Height; y++) { byte* sPtr = basePtr + sOffset; @@ -184,4 +184,4 @@ private static void CheckColumnRegionsDoNotOverlap( } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index 93fe7fbbee..77af1717dd 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -53,12 +53,12 @@ public byte[] GetData() if (this.exifIndexes.Count > 0) { - exifIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset); + exifIndex = this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset); } if (this.gpsIndexes.Count > 0) { - gpsIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset); + gpsIndex = this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset); } uint ifdLength = 2 + this.GetLength(this.ifdIndexes) + 4; @@ -125,7 +125,7 @@ public byte[] GetData() i = this.WriteData(startIndex, this.gpsIndexes, result, i); } - WriteUInt16((ushort)0, result, i); + WriteUInt16(0, result, i); return result; } @@ -373,4 +373,4 @@ private int WriteValue(ExifValue value, Span destination, int offset) return this.WriteValue(value.DataType, value.Value, destination, offset); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Primitives/ColorMatrix.cs b/src/ImageSharp/Primitives/ColorMatrix.cs index af2e9465a9..11886c9c2a 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #pragma warning disable SA1117 // Parameters should be on same line or separate lines @@ -269,7 +269,7 @@ public bool IsIdentity /// /// The source matrix. /// The negated matrix. - public static unsafe ColorMatrix operator -(ColorMatrix value) + public static ColorMatrix operator -(ColorMatrix value) { ColorMatrix m; @@ -456,4 +456,4 @@ public override string ToString() this.M51.ToString(ci), this.M52.ToString(ci), this.M53.ToString(ci), this.M54.ToString(ci)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index a17c8dcac0..1f36e2593a 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -141,7 +141,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 ColorMatrix { M11 = 1.5F, M12 = 1.5F, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 7d8ba62083..dd2f09bcd9 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -74,7 +74,7 @@ protected override void OnFrameApply(ImageFrame source, Rectangle source Parallel.For( 0, tileYStartPositions.Count, - new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, + new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, index => { int cdfX = 0; @@ -470,7 +470,7 @@ public void CalculateLookupTables(ImageFrame source, HistogramEqualizati Parallel.For( 0, this.tileYStartPositions.Count, - new ParallelOptions() { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, + new ParallelOptions { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, index => { int cdfX = 0; diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index b9d867a937..377af51354 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -50,7 +50,7 @@ protected override void OnFrameApply(ImageFrame source, Rectangle source { MemoryAllocator memoryAllocator = configuration.MemoryAllocator; - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; int tileWidth = source.Width / this.Tiles; int tileHeight = tileWidth; int pixelInTile = tileWidth * tileHeight; diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index c7b5802c4f..09e25827c7 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // ReSharper disable InconsistentNaming @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations { public class Block8x8F_Round { - private Block8x8F block = default(Block8x8F); + private Block8x8F block; [GlobalSetup] public void Setup() @@ -66,4 +66,4 @@ public void SimdRound() row7 = SimdUtils.FastRound(row7); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs index 5a4a9ab17c..f40c15cc14 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using BenchmarkDotNet.Attributes; @@ -42,7 +42,7 @@ public void ParseStreamPdfJs() { using (var memoryStream = new MemoryStream(this.jpegBytes)) { - var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder() { IgnoreMetadata = true }); + var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder { IgnoreMetadata = true }); decoder.ParseStream(memoryStream); decoder.Dispose(); } @@ -65,4 +65,4 @@ public void ParseStreamPdfJs() // | 'System.Drawing FULL' | Core | Core | Jpg/b(...)f.jpg [28] | 17.68 ms | 2.711 ms | 0.1486 ms | 1.00 | 0.00 | 343.7500 | - | - | 757.04 KB | // | JpegDecoderCore.ParseStream | Core | Core | Jpg/b(...)f.jpg [28] | 14.27 ms | 3.671 ms | 0.2012 ms | 0.81 | 0.00 | - | - | - | 11.76 KB | } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 62742f729b..99b071e59e 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Drawing; @@ -87,7 +87,7 @@ public CoreSize JpegImageSharp() { using (var memoryStream = new MemoryStream(this.jpegBytes)) { - using (var image = Image.Load(memoryStream, new JpegDecoder() { IgnoreMetadata = true })) + using (var image = Image.Load(memoryStream, new JpegDecoder { IgnoreMetadata = true })) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs index b8235fac87..16fdf1830b 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs @@ -94,7 +94,7 @@ public unsafe struct Byte public static Byte Create(byte[] data) { - Byte result = default(Byte); + Byte result = default; for (int i = 0; i < data.Length; i++) { result.Data[i] = data[i]; @@ -113,9 +113,9 @@ public struct Result // The operation is defined as "RGBA -> YCbCr Transform a stream of bytes into a stream of floats" // We need to benchmark the whole operation, to get true results, not missing any side effects! - private byte[] inputSourceRGB = null; + private byte[] inputSourceRGB; - private int[] inputSourceRGBAsInteger = null; + private int[] inputSourceRGBAsInteger; [GlobalSetup] public void Setup() @@ -303,7 +303,7 @@ public unsafe void RgbaToYcbCrScaledInteger() OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: - Result result = default(Result); + Result result = default; float* yPtr = (float*)&result.Y; float* cbPtr = (float*)&result.Cb; float* crPtr = (float*)&result.Cr; @@ -342,7 +342,7 @@ public unsafe void RgbaToYcbCrScaledIntegerLut() OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: - Result result = default(Result); + Result result = default; float* yPtr = (float*)&result.Y; float* cbPtr = (float*)&result.Cb; float* crPtr = (float*)&result.Cr; diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 6af466e42c..2c325d184a 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -89,7 +89,7 @@ public void SpanCopyTo() } [Benchmark(Description = "Unsafe.CopyBlock(ref)")] - public unsafe void UnsafeCopyBlockReferences() + public void UnsafeCopyBlockReferences() { Unsafe.CopyBlock(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); } @@ -103,7 +103,7 @@ public unsafe void UnsafeCopyBlockPointers() } [Benchmark(Description = "Unsafe.CopyBlockUnaligned(ref)")] - public unsafe void UnsafeCopyBlockUnalignedReferences() + public void UnsafeCopyBlockUnalignedReferences() { Unsafe.CopyBlockUnaligned(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); } diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 3597207ee4..02bc5d843e 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -16,7 +16,7 @@ public class Vector4Constants private static readonly Vector4 C = new Vector4(5.6f); private static readonly Vector4 D = new Vector4(7.8f); - private Random random = null; + private Random random; private Vector4 parameter; @@ -58,4 +58,4 @@ public Vector4 Inlined() private float GetRandomFloat() => (float)this.random.NextDouble(); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs index 8fc9d9977a..8a14f02451 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs @@ -16,7 +16,7 @@ public abstract class SIMDBenchmarkBase protected Vector testVector; - protected virtual T GetTestValue() => default(T); + protected virtual T GetTestValue() => default; protected virtual Vector GetTestVector() => new Vector(this.GetTestValue()); @@ -66,4 +66,4 @@ public void Simd() } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 5efaa06332..83f2537e75 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -111,7 +111,7 @@ public void FillRegion_WorksOnWrappedMemoryImage( } public static readonly TheoryData BlendData = - new TheoryData() + new TheoryData { { false, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f }, { false, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f }, @@ -196,4 +196,4 @@ public void BlendFillColorOverBackground( } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index 40c5f950da..69dff72369 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Primitives; @@ -56,7 +56,7 @@ public int FindIntersections(PointF s, PointF e, Span buffer) public ShapeRegionTests() { - this.pathMock = new Mock() { CallBase = true }; + this.pathMock = new Mock { CallBase = true }; this.bounds = new RectangleF(10.5f, 10, 10, 10); this.pathMock.Setup(x => x.Bounds).Returns(this.bounds); @@ -124,4 +124,4 @@ public void ShapeRegionFromShapeMaxIntersectionsProxyToShape() this.pathMock.Verify(x => x.MaxIntersections); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs b/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs index 6660cd87af..5ad7a1248d 100644 --- a/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Tests.Drawing.Utils @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Utils public class QuickSortTests { - public static readonly TheoryData Data = new TheoryData() + public static readonly TheoryData Data = new TheoryData { new float[]{ 3, 2, 1 }, new float[0], @@ -48,4 +48,4 @@ public void SortSlice() Assert.Equal(actual, expected); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs index c3ae0cddff..fb4afc28d1 100644 --- a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -69,7 +69,7 @@ public Size GetCurrentSize() public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new AppliedOperation() + this.Applied.Add(new AppliedOperation { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectang public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new AppliedOperation() + this.Applied.Add(new AppliedOperation { NonGenericProcessor = processor }); @@ -90,7 +90,7 @@ public struct AppliedOperation { public Rectangle? Rectangle { get; set; } public IImageProcessor GenericProcessor { get; set; } - + public IImageProcessor NonGenericProcessor { get; set; } } } diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index d9fff9ded5..ecec6f0a7a 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -157,7 +157,7 @@ public void BmpDecoder_CanDecode_32BitV4Header_Fast(TestImageProvider(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. @@ -173,7 +173,7 @@ public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta(TestIma public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. @@ -192,7 +192,7 @@ public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit(TestImageProvider public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); if (TestEnvironment.IsWindows) @@ -208,7 +208,7 @@ public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRe public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) { image.DebugSave(provider); image.CompareToOriginal(provider, new MagickReferenceDecoder()); @@ -221,7 +221,7 @@ public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecode public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) { image.DebugSave(provider); image.CompareToOriginal(provider, new MagickReferenceDecoder()); @@ -235,7 +235,7 @@ public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit(TestImageProvider public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs index da17dfb983..7045d64508 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs @@ -17,7 +17,7 @@ public class BmpMetaDataTests [Fact] public void CloneIsDeep() { - var meta = new BmpMetadata() { BitsPerPixel = BmpBitsPerPixel.Pixel24 }; + var meta = new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Pixel24 }; var clone = (BmpMetadata)meta.DeepClone(); clone.BitsPerPixel = BmpBitsPerPixel.Pixel32; diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index b2f9788ae4..62e9acf747 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; @@ -83,7 +83,7 @@ public void QuantizeImageShouldPreserveMaximumColorPrecision(TestImagePr using (Image image = provider.GetImage()) { - image.DebugSave(provider, new PngEncoder() { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName); + image.DebugSave(provider, new PngEncoder { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName); } provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); @@ -201,4 +201,4 @@ private static IImageEncoder GetEncoder(string format) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 0605859c22..38cd5bc95e 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -32,7 +32,7 @@ public void EncodeGeneratedPatterns(TestImageProvider provider) { using (Image image = provider.GetImage()) { - var encoder = new GifEncoder() + var encoder = new GifEncoder { // Use the palette quantizer without dithering to ensure results // are consistent @@ -138,7 +138,7 @@ public void NonMutatingEncodePreservesPaletteCount() GifMetadata metaData = image.Metadata.GetFormatMetadata(GifFormat.Instance); GifFrameMetadata frameMetaData = image.Frames.RootFrame.Metadata.GetFormatMetadata(GifFormat.Instance); GifColorTableMode colorMode = metaData.ColorTableMode; - var encoder = new GifEncoder() + var encoder = new GifEncoder { ColorTableMode = colorMode, Quantizer = new OctreeQuantizer(frameMetaData.ColorTableLength) diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs index d82bfbf227..b891c8ed20 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Formats.Gif; @@ -11,7 +11,7 @@ public class GifFrameMetaDataTests [Fact] public void CloneIsDeep() { - var meta = new GifFrameMetadata() + var meta = new GifFrameMetadata { FrameDelay = 1, DisposalMethod = GifDisposalMethod.RestoreToBackground, diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs index 2d554eb620..a5bd6efbb0 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs @@ -27,13 +27,12 @@ public class GifMetaDataTests [Fact] public void CloneIsDeep() { - var meta = new GifMetadata() + var meta = new GifMetadata { RepeatCount = 1, ColorTableMode = GifColorTableMode.Global, GlobalColorTableLength = 2, - Comments = new List() { "Foo" } - + Comments = new List { "Foo" } }; var clone = (GifMetadata)meta.DeepClone(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index 977bc3a8d8..93f3f70894 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // Uncomment this to turn unit tests into benchmarks: @@ -426,7 +426,7 @@ public void LoadFromUInt16Scalar() for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } @@ -441,14 +441,14 @@ public void LoadFromUInt16ExtendedAvx2() short[] data = Create8x8ShortData(); var source = new Block8x8(data); - + Block8x8F dest = default; dest.LoadFromInt16ExtendedAvx2(ref source); for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index 3df927aeb0..da75e059f4 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -45,7 +45,7 @@ public void Indexer_Set() [Fact] public unsafe void Indexer_GetScalarAt_SetScalarAt() { - int sum = 0; + int sum; var block = default(Block8x8); for (int i = 0; i < Block8x8.Size; i++) @@ -73,7 +73,7 @@ public void AsFloatBlock() for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } @@ -141,4 +141,4 @@ public void TotalDifference() Assert.Equal(15, d); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 92b92eb100..04e55fad3b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -21,7 +21,7 @@ public FastFloatingPoint(ITestOutputHelper output) [Fact] public void iDCT2D8x4_LeftPart() { - float[] sourceArray = JpegFixture.Create8x8FloatData(); + float[] sourceArray = Create8x8FloatData(); float[] expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray, expectedDestArray); @@ -46,7 +46,7 @@ public void iDCT2D8x4_LeftPart() [Fact] public void iDCT2D8x4_RightPart() { - float[] sourceArray = JpegFixture.Create8x8FloatData(); + float[] sourceArray = Create8x8FloatData(); float[] expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray.AsSpan(4), expectedDestArray.AsSpan(4)); @@ -74,7 +74,7 @@ public void iDCT2D8x4_RightPart() [InlineData(3)] public void LLM_TransformIDCT_CompareToNonOptimized(int seed) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed); var source = Block8x8F.Load(sourceArray); @@ -93,7 +93,7 @@ public void LLM_TransformIDCT_CompareToNonOptimized(int seed) [InlineData(3)] public void LLM_TransformIDCT_CompareToAccurate(int seed) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed); var source = Block8x8F.Load(sourceArray); @@ -112,7 +112,7 @@ public void LLM_TransformIDCT_CompareToAccurate(int seed) [InlineData(2)] public void FDCT8x4_LeftPart(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -134,7 +134,7 @@ public void FDCT8x4_LeftPart(int seed) [InlineData(2)] public void FDCT8x4_RightPart(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -156,7 +156,7 @@ public void FDCT8x4_RightPart(int seed) [InlineData(2)] public void TransformFDCT(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -177,4 +177,4 @@ public void TransformFDCT(int seed) } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs index 341d67f0f1..7c42af5961 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs @@ -22,7 +22,7 @@ public static Image CreateTestImage() { for (int j = 0; j < 10; j++) { - var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), (byte)200, (byte)255); + var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), 200, 255); var color = default(TPixel); color.FromRgba32(rgba); @@ -59,7 +59,7 @@ public void LoadAndStretchCorners_FromOrigo(TestImageProvider pr [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgb24 | PixelTypes.Rgba32)] - public unsafe void LoadAndStretchCorners_WithOffset(TestImageProvider provider) + public void LoadAndStretchCorners_WithOffset(TestImageProvider provider) where TPixel : struct, IPixel { using (Image s = provider.GetImage()) @@ -121,4 +121,4 @@ public void Indexer() Assert.Equal(expected77, block[7, 7]); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs index 31a5a0eeb0..2485561f1e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs @@ -36,6 +36,6 @@ public void DecodeBaselineJpeg(TestImageProvider provider) [Theory] [WithFileCollection(nameof(UnrecoverableTestJpegs), PixelTypes.Rgba32)] public void UnrecoverableImagesShouldThrowCorrectError(TestImageProvider provider) - where TPixel : struct, IPixel => Assert.Throws(() => provider.GetImage()); + where TPixel : struct, IPixel => Assert.Throws(provider.GetImage); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs index 8d8d316935..1d5c3e27a4 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs @@ -211,7 +211,7 @@ private static void TestMetaDataImpl( [InlineData(true)] public void IgnoreMetaData_ControlsWhetherMetaDataIsParsed(bool ignoreMetaData) { - var decoder = new JpegDecoder() { IgnoreMetadata = ignoreMetaData }; + var decoder = new JpegDecoder { IgnoreMetadata = ignoreMetaData }; // Snake.jpg has both Exif and ICC profiles defined: var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index d9013b507e..639ec520ec 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; @@ -114,7 +114,7 @@ private static void TestJpegEncoderCore( // There is no alpha in Jpeg! image.Mutate(c => c.MakeOpaque()); - var encoder = new JpegEncoder() + var encoder = new JpegEncoder { Subsample = subsample, Quality = quality @@ -198,4 +198,4 @@ public void Encode_PreserveRatio(string imagePath, int xResolution, int yResolut } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs index 793bdd5229..59ad571f49 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Formats.Jpeg; @@ -11,7 +11,7 @@ public class JpegMetaDataTests [Fact] public void CloneIsDeep() { - var meta = new JpegMetadata() { Quality = 50 }; + var meta = new JpegMetadata { Quality = 50 }; var clone = (JpegMetadata)meta.DeepClone(); clone.Quality = 99; @@ -19,4 +19,4 @@ public void CloneIsDeep() Assert.False(meta.Quality.Equals(clone.Quality)); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index f4f3b83b46..1d7ca746f6 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -80,7 +80,7 @@ public void PrintComponentData(string imageFile) this.Output.WriteLine(sb.ToString()); } - public static readonly TheoryData ComponentVerificationData = new TheoryData() + public static readonly TheoryData ComponentVerificationData = new TheoryData { { TestImages.Jpeg.Baseline.Jpeg444, 3, new Size(1, 1), new Size(1, 1) }, { TestImages.Jpeg.Baseline.Jpeg420Exif, 3, new Size(2, 2), new Size(1, 1) }, diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs index dd2113624e..82fcc368fc 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs @@ -24,7 +24,7 @@ public AccurateDCT(ITestOutputHelper output) [InlineData(2)] public void ForwardThenInverse(int seed) { - float[] data = JpegFixture.Create8x8RandomFloatData(-1000, 1000, seed); + float[] data = Create8x8RandomFloatData(-1000, 1000, seed); var b0 = default(Block8x8F); b0.LoadFrom(data); @@ -36,4 +36,4 @@ public void ForwardThenInverse(int seed) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index ce6f0a744f..60a019c290 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -25,7 +25,7 @@ public FastFloatingPointDCT(ITestOutputHelper output) [InlineData(2, 0)] public void LLM_ForwardThenInverse(int seed, int startAt) { - int[] data = JpegFixture.Create8x8RandomIntData(-1000, 1000, seed); + int[] data = Create8x8RandomIntData(-1000, 1000, seed); float[] original = data.ConvertAllToFloat(); float[] src = data.ConvertAllToFloat(); float[] dest = new float[64]; @@ -52,7 +52,7 @@ public void LLM_CalcConstants() [InlineData(2, 200)] public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-range, range, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-range, range, seed); var source = Block8x8F.Load(sourceArray); @@ -86,7 +86,7 @@ public void LLM_IDCT_CompareToIntegerRoundedAccurateImplementation(int seed, int [InlineData(2)] public void LLM_FDCT_IsEquivalentTo_AccurateImplementation(int seed) { - float[] floatData = JpegFixture.Create8x8RandomFloatData(-1000, 1000); + float[] floatData = Create8x8RandomFloatData(-1000, 1000); Block8x8F source = default; source.LoadFrom(floatData); @@ -107,7 +107,7 @@ public void LLM_FDCT_IsEquivalentTo_AccurateImplementation(int seed) [InlineData(2, 200)] public void GT_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) { - int[] intData = JpegFixture.Create8x8RandomIntData(-range, range, seed); + int[] intData = Create8x8RandomIntData(-range, range, seed); float[] floatSrc = intData.ConvertAllToFloat(); ReferenceImplementations.AccurateDCT.TransformIDCTInplace(intData); @@ -120,4 +120,4 @@ public void GT_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs index f299807fc7..f16d04bf60 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs @@ -64,7 +64,7 @@ public void FDCT_IsEquivalentTo_AccurateImplementation(int seed) [InlineData(2, 0)] public void ForwardThenInverse(int seed, int startAt) { - Span original = JpegFixture.Create8x8RandomIntData(-200, 200, seed); + Span original = Create8x8RandomIntData(-200, 200, seed); Span block = original.AddScalarToAllValues(128); @@ -80,11 +80,11 @@ public void ForwardThenInverse(int seed, int startAt) for (int i = startAt; i < 64; i++) { float expected = original[i]; - float actual = (float)block[i]; + float actual = block[i]; Assert.Equal(expected, actual, new ApproximateFloatComparer(3f)); } } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index e4fcd10c5f..91cd80d144 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -52,8 +52,8 @@ public ComponentData(int widthInBlocks, int heightInBlocks, int index) internal void MakeBlock(short[] data, int y, int x) { - this.MinVal = Math.Min((short)this.MinVal, data.Min()); - this.MaxVal = Math.Max((short)this.MaxVal, data.Max()); + this.MinVal = Math.Min(this.MinVal, data.Min()); + this.MaxVal = Math.Max(this.MaxVal, data.Max()); this.SpectralBlocks[x, y] = new Block8x8(data); } @@ -189,4 +189,4 @@ public ref Block8x8 GetBlockReference(int column, int row) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index 3de4673f5d..5a62de0347 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -87,7 +87,7 @@ public static SpectralData ExtractSpectralData(string inputFile) { TestFile testFile = TestFile.Create(inputFile); - string outDir = TestEnvironment.CreateOutputDirectory(".Temp", $"JpegCoeffs"); + string outDir = TestEnvironment.CreateOutputDirectory(".Temp", "JpegCoeffs"); string fn = $"{Path.GetFileName(inputFile)}-{new Random().Next(1000)}.dctcoeffs"; string coeffFileFullPath = Path.Combine(outDir, fn); @@ -139,4 +139,4 @@ public static SpectralData ExtractSpectralData(string inputFile) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index 2712d1933c..46f0305807 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -14,12 +14,12 @@ internal static partial class ReferenceImplementations /// /* reference idct taken from "ieeetest.c" /// * Written by Tom Lane (tgl@cs.cmu.edu). /// * Released to public domain 11/22/93. - /// */ + /// */ /// internal static class AccurateDCT { private static double[,] CosLut = InitCosLut(); - + public static Block8x8 TransformIDCT(ref Block8x8 block) { Block8x8F temp = block.AsFloatBlock(); @@ -62,7 +62,7 @@ public static Block8x8F TransformIDCT(ref Block8x8F block) for (v=0; v<8; v++) { tmp2 = 0.0; for (u=0; u<8; u++) { - tmp2 += (double) block[v * 8 + u] * CosLut[x, u]; + tmp2 += block[v * 8 + u] * CosLut[x, u]; } tmp += CosLut[y, v] * tmp2; } @@ -71,7 +71,7 @@ public static Block8x8F TransformIDCT(ref Block8x8F block) } return res; } - + public static Block8x8F TransformFDCT(ref Block8x8F block) { int x, y, u, v; @@ -88,14 +88,14 @@ public static Block8x8F TransformFDCT(ref Block8x8F block) tmp2 = 0.0; for (x = 0; x < 8; x++) { - tmp2 += (double)block[y * 8 + x] * CosLut[x,u]; + tmp2 += block[y * 8 + x] * CosLut[x,u]; } tmp += CosLut[y, v] * tmp2; } res[v * 8 + u] = (float) tmp; } } - + return res; } @@ -108,7 +108,7 @@ public static Block8x8F TransformFDCT(ref Block8x8F block) for (a = 0; a < 8; a++) for (b = 0; b < 8; b++) { - tmp = Math.Cos((double)((a + a + 1) * b) * (3.14159265358979323846 / 16.0)); + tmp = Math.Cos((a + a + 1) * b * (3.14159265358979323846 / 16.0)); if (b == 0) { tmp /= Math.Sqrt(2.0); @@ -119,4 +119,4 @@ public static Block8x8F TransformFDCT(ref Block8x8F block) } } } -} \ No newline at end of file +} 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 46b9b4366f..df5ec97408 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 @@ -64,7 +64,7 @@ public static float[] PrintConstants(ITestOutputHelper output) float[] r = new float[8]; for (int i = 0; i < 8; i++) { - r[i] = (float)(Cos((double)i / 16.0 * M_PI) * M_SQRT2); + r[i] = (float)(Cos(i / 16.0 * M_PI) * M_SQRT2); output?.WriteLine($"float r{i} = {r[i]:R}f;"); } return r; @@ -267,13 +267,13 @@ public static void fDCT2D8x4_32f(Span s, Span d) public static void fDCT8x8_llm_sse(Span s, Span d, Span temp) { - ReferenceImplementations.Transpose8x8(s, temp); + Transpose8x8(s, temp); fDCT2D8x4_32f(temp, d); fDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - ReferenceImplementations.Transpose8x8(d, temp); + Transpose8x8(d, temp); fDCT2D8x4_32f(temp, d); @@ -535,14 +535,14 @@ internal static void fDCT2D_llm( fDCT1Dllm_32f(sWorker.Slice(j * 8), temp.Slice(j * 8)); } - ReferenceImplementations.Transpose8x8(temp, d); + Transpose8x8(temp, d); for (int j = 0; j < 8; j++) { fDCT1Dllm_32f(d.Slice(j * 8), temp.Slice(j * 8)); } - ReferenceImplementations.Transpose8x8(temp, d); + Transpose8x8(temp, d); if (downscaleBy8) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index e9527e4c3b..f604cb1b5e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -78,7 +78,7 @@ public static float[] ConvertAllToFloat(this int[] src) float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { - result[i] = (float)src[i]; + result[i] = src[i]; } return result; @@ -118,4 +118,4 @@ public static Span AddScalarToAllValues(this Span src, int scalar) return result; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs index 33fd8ead21..dfa7fd2922 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs @@ -24,13 +24,13 @@ public class PngMetaDataTests [Fact] public void CloneIsDeep() { - var meta = new PngMetadata() + var meta = new PngMetadata { BitDepth = PngBitDepth.Bit16, ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List() { new PngTextData("name", "value", "foo", "bar") } + TextData = new List { new PngTextData("name", "value", "foo", "bar") } }; var clone = (PngMetadata)meta.DeepClone(); @@ -133,7 +133,7 @@ public void Encode_UseCompression_WhenTextIsGreaterThenThreshold_Works(T PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); - input.Save(memoryStream, new PngEncoder() + input.Save(memoryStream, new PngEncoder { TextCompressionThreshold = 50 }); @@ -151,7 +151,7 @@ public void Encode_UseCompression_WhenTextIsGreaterThenThreshold_Works(T [Fact] public void Decode_IgnoreMetadataIsFalse_TextChunkIsRead() { - var options = new PngDecoder() + var options = new PngDecoder { IgnoreMetadata = false }; @@ -172,7 +172,7 @@ public void Decode_IgnoreMetadataIsFalse_TextChunkIsRead() [Fact] public void Decode_IgnoreMetadataIsTrue_TextChunksAreIgnored() { - var options = new PngDecoder() + var options = new PngDecoder { IgnoreMetadata = true }; diff --git a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs index ee309e0e30..3468c076a5 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers public class ParallelHelperTests { private readonly ITestOutputHelper Output; - + public ParallelHelperTests(ITestOutputHelper output) { this.Output = output; @@ -31,7 +31,7 @@ public ParallelHelperTests(ITestOutputHelper output) /// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength /// public static TheoryData IterateRows_OverMinimumPixelsLimit_Data = - new TheoryData() + new TheoryData { { 1, 0, 100, -1, 100 }, { 2, 0, 9, 5, 4 }, @@ -60,7 +60,7 @@ public void IterateRows_OverMinimumPixelsLimit_IntervalsAreCorrect( var rectangle = new Rectangle(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; - + ParallelHelper.IterateRows( rectangle, parallelSettings, @@ -109,7 +109,7 @@ public void IterateRows_OverMinimumPixelsLimit_ShouldVisitAllRows( actualData[y] = y; } }); - + Assert.Equal(expectedData, actualData); } @@ -144,7 +144,7 @@ public void IterateRowsWithTempBuffer_OverMinimumPixelsLimit( int step = rows.Max - rows.Min; int expected = rows.Max < maxY ? expectedStepLength : expectedLastStepLength; - + Interlocked.Increment(ref actualNumberOfSteps); Assert.Equal(expected, step); }); @@ -190,7 +190,7 @@ public void IterateRowsWithTempBuffer_OverMinimumPixelsLimit_ShouldVisitAllRows( } public static TheoryData IterateRows_WithEffectiveMinimumPixelsLimit_Data = - new TheoryData() + new TheoryData { { 2, 200, 50, 2, 1, -1, 2 }, { 2, 200, 200, 1, 1, -1, 1 }, @@ -256,7 +256,7 @@ public void IterateRowsWithTempBuffer_WithEffectiveMinimumPixelsLimit( Configuration.Default.MemoryAllocator); var rectangle = new Rectangle(0, 0, width, height); - + int actualNumberOfSteps = 0; ParallelHelper.IterateRowsWithTempBuffer( rectangle, @@ -277,7 +277,7 @@ public void IterateRowsWithTempBuffer_WithEffectiveMinimumPixelsLimit( } public static readonly TheoryData IterateRectangularBuffer_Data = - new TheoryData() + new TheoryData { { 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox { 2, 582, 453, 10, 10, 291, 226 }, @@ -303,7 +303,7 @@ public void IterateRectangularBuffer( using (Buffer2D actual = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) { var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); - + void FillRow(int y, Buffer2D buffer) { for (int x = rect.Left; x < rect.Right; x++) @@ -348,7 +348,7 @@ public void IterateRowsRequiresValidRectangle(int width, int height) var rect = new Rectangle(0, 0, width, height); ArgumentOutOfRangeException ex = Assert.Throws( - () => ParallelHelper.IterateRows(rect, parallelSettings, (rows) => { })); + () => ParallelHelper.IterateRows(rect, parallelSettings, rows => { })); Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message); } @@ -370,4 +370,4 @@ public void IterateRowsWithTempBufferRequiresValidRectangle(int width, int heigh Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index 50358a9d09..92c5915ff6 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -28,7 +28,7 @@ public void AddFrame_OfDifferentPixelType() this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, - (Bgra32)Color.Blue)) + Color.Blue)) { this.Collection.AddFrame(sourceImage.Frames.RootFrame); } @@ -49,7 +49,7 @@ public void InsertFrame_OfDifferentPixelType() this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, - (Bgra32)Color.Blue)) + Color.Blue)) { this.Collection.InsertFrame(0, sourceImage.Frames.RootFrame); } @@ -88,7 +88,7 @@ public void AddNewFrame_Frame_FramesNotBeNull() ArgumentNullException ex = Assert.Throws( () => { - this.Collection.AddFrame((ImageFrame)null); + this.Collection.AddFrame(null); }); Assert.StartsWith("Value cannot be null.", ex.Message); diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index c4be6fbecf..6236d296e3 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -36,7 +36,7 @@ public ImageSaveTests() this.encoderNotInFormat = new Mock(); this.fileSystem = new Mock(); - var config = new Configuration() + var config = new Configuration { FileSystem = this.fileSystem.Object }; diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index 7f8b133758..c997f9bd07 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -30,7 +30,7 @@ public ImageOperationTests() Mock processorMock = new Mock(); this.processorDefinition = processorMock.Object; - this.image = new Image(new Configuration() + this.image = new Image(new Configuration { ImageOperationsProvider = this.provider }, 1, 1); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index 4af3b81e20..abe78e747e 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -27,7 +27,7 @@ public static void SpanPointsTo(Span span, IMemoryOwner buffer, int buf ref T actual = ref MemoryMarshal.GetReference(span); ref T expected = ref Unsafe.Add(ref buffer.GetReference(), bufferOffset); - Assert.True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position"); + True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position"); } } @@ -179,4 +179,4 @@ public void CopyColumns_InvokeMultipleTimes() } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs index 6fc5142ee8..3ae452d7d7 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs @@ -25,7 +25,7 @@ public enum TestImageWriteFormat Png } - private static readonly Dictionary TestProfileValues = new Dictionary() + private static readonly Dictionary TestProfileValues = new Dictionary { { ExifTag.Software, "Software" }, { ExifTag.Copyright, "Copyright" }, diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs index 43c27335a9..33ecf53c71 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -13,7 +13,7 @@ public void WriteProfile_NoEntries() { IccWriter writer = CreateWriter(); - IccProfile profile = new IccProfile() + IccProfile profile = new IccProfile { Header = IccTestDataProfiles.Header_Random_Write }; diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index 0266704850..7638c5f862 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -28,7 +28,7 @@ public void AreNotEqual() } public static readonly TheoryData ColorData = - new TheoryData() { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } }; + new TheoryData { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } }; [Theory] [MemberData(nameof(ColorData))] @@ -129,4 +129,4 @@ public void Bgr24_FromBgra5551() Assert.Equal(255, bgr.B); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 93ce131d13..28c022709f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -34,7 +34,7 @@ public void AreNotEqual() } public static readonly TheoryData ColorData = - new TheoryData() + new TheoryData { { 1, 2, 3, 4 }, { 4, 5, 6, 7 }, { 0, 255, 42, 0 }, { 1, 2, 3, 255 } }; @@ -141,4 +141,4 @@ public void Bgra32_FromBgra5551() Assert.Equal(expected, bgra.PackedValue); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs index 74fd903ca9..d7b50ee1e2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { public class Gray8Tests { - public static readonly TheoryData LuminanceData = new TheoryData() + public static readonly TheoryData LuminanceData = new TheoryData { 0, 1, @@ -279,4 +279,4 @@ public void FromScaledVector4_IsRgba32Compatible(byte luminance) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index f0b27d4869..e397f70b08 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders { public class PorterDuffFunctionsTests { - public static TheoryData NormalBlendFunctionData = new TheoryData() { + public static TheoryData NormalBlendFunctionData = new TheoryData { { 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) }, }; @@ -23,7 +23,7 @@ public void NormalBlendFunction(TestVector4 back, TestVector4 source, float amou Assert.Equal(expected, actual); } - public static TheoryData MultiplyFunctionData = new TheoryData() { + public static TheoryData MultiplyFunctionData = new TheoryData { { 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) }, { @@ -42,7 +42,7 @@ public void MultiplyFunction(TestVector4 back, TestVector4 source, float amount, VectorAssert.Equal(expected, actual, 5); } - public static TheoryData AddFunctionData = new TheoryData() { + public static TheoryData AddFunctionData = new TheoryData { { 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) }, { @@ -61,7 +61,7 @@ public void AddFunction(TestVector4 back, TestVector4 source, float amount, Test VectorAssert.Equal(expected, actual, 5); } - public static TheoryData SubtractFunctionData = new TheoryData() { + public static TheoryData SubtractFunctionData = new TheoryData { { 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) }, { @@ -80,7 +80,7 @@ public void SubtractFunction(TestVector4 back, TestVector4 source, float amount, VectorAssert.Equal(expected, actual, 5); } - public static TheoryData ScreenFunctionData = new TheoryData() { + public static TheoryData ScreenFunctionData = new TheoryData { { 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) }, { @@ -99,7 +99,7 @@ public void ScreenFunction(TestVector4 back, TestVector4 source, float amount, T VectorAssert.Equal(expected, actual, 5); } - public static TheoryData DarkenFunctionData = new TheoryData() { + public static TheoryData DarkenFunctionData = new TheoryData { { 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) }, { @@ -118,7 +118,7 @@ public void DarkenFunction(TestVector4 back, TestVector4 source, float amount, T VectorAssert.Equal(expected, actual, 5); } - public static TheoryData LightenFunctionData = new TheoryData() { + public static TheoryData LightenFunctionData = new TheoryData { { 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) }, { @@ -137,7 +137,7 @@ public void LightenFunction(TestVector4 back, TestVector4 source, float amount, VectorAssert.Equal(expected, actual, 5); } - public static TheoryData OverlayFunctionData = new TheoryData() { + public static TheoryData OverlayFunctionData = new TheoryData { { 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) }, { @@ -156,7 +156,7 @@ public void OverlayFunction(TestVector4 back, TestVector4 source, float amount, VectorAssert.Equal(expected, actual, 5); } - public static TheoryData HardLightFunctionData = new TheoryData() { + public static TheoryData HardLightFunctionData = new TheoryData { { 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) }, { diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index 0e270dfda4..859be6b205 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -17,7 +17,7 @@ private static Span AsSpan(T value) return new Span(new[] { value }); } - public static TheoryData NormalBlendFunctionData = new TheoryData() { + public static TheoryData NormalBlendFunctionData = new TheoryData { { 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) }, }; @@ -29,7 +29,7 @@ private static Span AsSpan(T value) public void NormalBlendFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)(TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -52,7 +52,7 @@ public void NormalBlendFunctionBlenderBulk(TestPixel back, TestP VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData MultiplyFunctionData = new TheoryData() { + public static TheoryData MultiplyFunctionData = new TheoryData { { 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) }, { @@ -91,7 +91,7 @@ public void MultiplyFunctionBlenderBulk(TestPixel back, TestPixe VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData AddFunctionData = new TheoryData() { + public static TheoryData AddFunctionData = new TheoryData { { 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(1f, 1f, 1f, 1f) }, { @@ -130,7 +130,7 @@ public void AddFunctionBlenderBulk(TestPixel back, TestPixel SubtractFunctionData = new TheoryData() { + public static TheoryData SubtractFunctionData = new TheoryData { { 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) }, { @@ -169,7 +169,7 @@ public void SubtractFunctionBlenderBulk(TestPixel back, TestPixe VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData ScreenFunctionData = new TheoryData() { + public static TheoryData ScreenFunctionData = new TheoryData { { 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) }, { @@ -208,7 +208,7 @@ public void ScreenFunctionBlenderBulk(TestPixel back, TestPixel< VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData DarkenFunctionData = new TheoryData() { + public static TheoryData DarkenFunctionData = new TheoryData { { 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) }, { @@ -247,7 +247,7 @@ public void DarkenFunctionBlenderBulk(TestPixel back, TestPixel< VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData LightenFunctionData = new TheoryData() { + public static TheoryData LightenFunctionData = new TheoryData { { 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) }, { @@ -286,7 +286,7 @@ public void LightenFunctionBlenderBulk(TestPixel back, TestPixel VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData OverlayFunctionData = new TheoryData() { + public static TheoryData OverlayFunctionData = new TheoryData { { 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) }, { @@ -325,7 +325,7 @@ public void OverlayFunctionBlenderBulk(TestPixel back, TestPixel VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData HardLightFunctionData = new TheoryData() { + public static TheoryData HardLightFunctionData = new TheoryData { { 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) }, { diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs index eea0b5eac5..74360e8574 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { public class PixelBlenderTests { - public static TheoryData BlenderMappings = new TheoryData() + public static TheoryData BlenderMappings = new TheoryData { { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelColorBlendingMode.Normal }, { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelColorBlendingMode.Screen }, @@ -44,7 +44,7 @@ public void ReturnsCorrectBlender(TestPixel pixel, Type type, Pi Assert.IsType(type, blender); } - public static TheoryData ColorBlendingExpectedResults = new TheoryData() + public static TheoryData ColorBlendingExpectedResults = new TheoryData { { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Normal, Rgba32.MidnightBlue }, { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, @@ -71,7 +71,7 @@ public void TestColorBlendingModes(Rgba32 backdrop, Rgba32 source, float opacity Assert.Equal(actualResult.ToVector4(), expectedResult.ToVector4()); } - public static TheoryData AlphaCompositionExpectedResults = new TheoryData() + public static TheoryData AlphaCompositionExpectedResults = new TheoryData { { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index df459422c9..06e3d59482 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public class Rgb24Tests { public static readonly TheoryData ColorData = - new TheoryData() + new TheoryData { { 1, 2, 3 }, { 4, 5, 6 }, @@ -130,4 +130,4 @@ public void Rgb24_FromBgra5551() Assert.Equal(255, rgb.B); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 03089bc6c4..c5d18cbb2b 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -17,7 +17,7 @@ private class Assert : Xunit.Assert { public static void Equal(ReadOnlySpan a, ReadOnlySpan b) { - Xunit.Assert.True(a.SequenceEqual(b)); + True(a.SequenceEqual(b)); } } @@ -112,4 +112,4 @@ public void Dither_ErrorDiffuser_rect_CorrectProcessorWithColors() Assert.Equal(this.TestPalette, p.Palette); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index fc9a583dd1..e5015a6ee4 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; @@ -55,7 +55,7 @@ public void HistogramEqualizationTest(int luminanceLevels) }; // Act - image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions() + image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions { LuminanceLevels = luminanceLevels })); @@ -81,7 +81,7 @@ public void Adaptive_SlidingWindow_15Tiles_WithClipping(TestImageProvide { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + var options = new HistogramEqualizationOptions { Method = HistogramEqualizationMethod.AdaptiveSlidingWindow, LuminanceLevels = 256, @@ -101,7 +101,7 @@ public void Adaptive_TileInterpolation_10Tiles_WithClipping(TestImagePro { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + var options = new HistogramEqualizationOptions { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs index 4da2a832cd..c1c6bbd7cf 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs @@ -18,7 +18,7 @@ public abstract class OverlayTestBase public static string[] InputImages = { TestImages.Png.Ducky, TestImages.Png.Splash }; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); - + [Theory] [WithFileCollection(nameof(InputImages), nameof(ColorNames), PixelTypes.Rgba32)] public void FullImage_ApplyColor(TestImageProvider provider, string colorName) @@ -52,13 +52,13 @@ public void InBox(TestImageProvider provider) where TPixel : struct, IPixel { provider.Utility.TestGroupName = this.GetType().Name; - provider.RunRectangleConstrainedValidatingProcessorTest((x, rect) => this.Apply(x, rect)); + provider.RunRectangleConstrainedValidatingProcessorTest(this.Apply); } protected abstract void Apply(IImageProcessingContext ctx, Color color); - + protected abstract void Apply(IImageProcessingContext ctx, float radiusX, float radiusY); - + protected abstract void Apply(IImageProcessingContext ctx, Rectangle rect); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 28271bb77a..69acf9282b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -23,10 +23,10 @@ public static readonly TheoryData InvalidOrientationValues { ExifDataType.SignedByte, new byte[] { 2 } }, { ExifDataType.SignedShort, BitConverter.GetBytes((short) 3) }, { ExifDataType.Long, BitConverter.GetBytes((uint) 4) }, - { ExifDataType.SignedLong, BitConverter.GetBytes((int) 5) } + { ExifDataType.SignedLong, BitConverter.GetBytes(5) } }; - public static readonly TheoryData ExifOrientationValues = new TheoryData() + public static readonly TheoryData ExifOrientationValues = new TheoryData { 0, 1, @@ -87,4 +87,4 @@ public void AutoOrient_WorksWithCorruptExifData(TestImageProvider Directory.Exists(x)); + string directory = directories.FirstOrDefault(Directory.Exists); if (directory != null) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs index e8f60ade31..024c2ee215 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison public class ImageDimensionsMismatchException : ImagesSimilarityException { public ImageDimensionsMismatchException(Size expectedSize, Size actualSize) - : base((string)$"The image dimensions {actualSize} do not match the expected {expectedSize}!") + : base($"The image dimensions {actualSize} do not match the expected {expectedSize}!") { this.ExpectedSize = expectedSize; this.ActualSize = actualSize; @@ -17,4 +17,4 @@ public ImageDimensionsMismatchException(Size expectedSize, Size actualSize) public Size ExpectedSize { get; } public Size ActualSize { get; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 01cc614848..b0d3b8c7e8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -51,7 +51,7 @@ public ReferenceDecoderBenchmarks(ITestOutputHelper output) public void BenchmarkMagickPngDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Png"); + this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Png"); } [Theory(Skip = SkipBenchmarks)] @@ -59,7 +59,7 @@ public void BenchmarkMagickPngDecoder(TestImageProvider provider public void BenchmarkSystemDrawingPngDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Png"); + this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Png"); } [Theory(Skip = SkipBenchmarks)] @@ -67,7 +67,7 @@ public void BenchmarkSystemDrawingPngDecoder(TestImageProvider p public void BenchmarkMagickBmpDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Bmp"); + this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Bmp"); } [Theory(Skip = SkipBenchmarks)] @@ -75,7 +75,7 @@ public void BenchmarkMagickBmpDecoder(TestImageProvider provider public void BenchmarkSystemDrawingBmpDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Bmp"); + this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Bmp"); } private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) @@ -93,4 +93,4 @@ private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder d info); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 3cdb67dbdb..4a02d280e5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -62,7 +62,7 @@ private static string SavePng(TestImageProvider provider, PngCol sourceImage.Mutate(c => c.MakeOpaque()); } - var encoder = new PngEncoder() { ColorType = pngColorType }; + var encoder = new PngEncoder { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } } @@ -133,4 +133,4 @@ public void SaveWithReferenceEncoder(TestImageProvider provider) } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index f589db6976..738465a6ed 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -19,13 +19,13 @@ namespace SixLabors.ImageSharp.Tests { public class TestImageProviderTests { - public static readonly TheoryData BasicData = new TheoryData() + public static readonly TheoryData BasicData = new TheoryData { TestImageProvider.Blank(10, 20), TestImageProvider.Blank(10, 20), }; - public static readonly TheoryData FileData = new TheoryData() + public static readonly TheoryData FileData = new TheoryData { TestImageProvider.File(TestImages.Bmp.Car), TestImageProvider.File(TestImages.Bmp.F) @@ -114,10 +114,10 @@ public void GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParam string testName = nameof(this .GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual); - var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 42 }; + var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 42 }; decoder1.InitCaller(testName); - var decoder2 = new TestDecoderWithParameters() { Param1 = "LoL", Param2 = 42 }; + var decoder2 = new TestDecoderWithParameters { Param1 = "LoL", Param2 = 42 }; decoder2.InitCaller(testName); provider.GetImage(decoder1); @@ -148,10 +148,10 @@ public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParamete string testName = nameof(this .GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual); - var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 }; + var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 }; decoder1.InitCaller(testName); - var decoder2 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 }; + var decoder2 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 }; decoder2.InitCaller(testName); provider.GetImage(decoder1); @@ -354,7 +354,7 @@ private class TestDecoder : IImageDecoder private static readonly object Monitor = new object(); - private string callerName = null; + private string callerName; public static void DoTestThreadSafe(Action action) { @@ -389,7 +389,7 @@ private class TestDecoderWithParameters : IImageDecoder private static readonly object Monitor = new object(); - private string callerName = null; + private string callerName; public string Param1 { get; set; }