diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs index 6da635c98..1095de325 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs @@ -37,9 +37,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text { Guard.NotNull(text, nameof(text)); Guard.NotNull(font, nameof(font)); - if (brush == null && pen == null) + + if (brush is null && pen is null) { - throw new ArgumentNullException($"at least one of {nameof(brush)} or {nameof(pen)} must not be null"); + throw new ArgumentNullException($"Expected a {nameof(brush)} or {nameof(pen)}. Both were null"); } this.Options = options; diff --git a/src/ImageSharp/Common/Helpers/DebugGuard.cs b/src/ImageSharp/Common/Helpers/DebugGuard.cs index 5a1d3a2e3..2cf18b245 100644 --- a/src/ImageSharp/Common/Helpers/DebugGuard.cs +++ b/src/ImageSharp/Common/Helpers/DebugGuard.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp public static void NotNull(T value, string parameterName) where T : class { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index d09079062..b4a29f9fb 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp public static void NotNull(T value, string parameterName) where T : class { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp /// is empty or contains only blanks. public static void NotNullOrWhiteSpace(string value, string parameterName) { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp /// is empty. public static void NotNullOrEmpty(ICollection value, string parameterName) { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index d3cb50d6b..3d079cf61 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -25,7 +25,6 @@ namespace SixLabors.ImageSharp.Formats.Bmp { /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel { Guard.NotNull(stream, nameof(stream)); diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 3832a30c6..2a4d981eb 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -377,7 +377,7 @@ namespace SixLabors.ImageSharp.Formats.Gif ImageFrame currentFrame = null; ImageFrame imageFrame; - if (previousFrame == null) + if (previousFrame is null) { // This initializes the image to become fully transparent because the alpha channel is zero. image = new Image(this.configuration, imageWidth, imageHeight, this.metaData); @@ -485,7 +485,7 @@ namespace SixLabors.ImageSharp.Formats.Gif private void RestoreToBackground(ImageFrame frame) where TPixel : struct, IPixel { - if (this.restoreArea == null) + if (this.restoreArea is null) { return; } diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 1fb706ae1..553290035 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { foreach (ImageFrame frame in image.Frames) { - if (quantized == null) + if (quantized is null) { quantized = this.quantizer.CreateFrameQuantizer().QuantizeFrame(frame); } diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 3c7b6a4af..07594e81a 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -56,9 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// is null. public LzwDecoder(MemoryAllocator memoryAllocator, Stream stream) { - Guard.NotNull(stream, nameof(stream)); - - this.stream = stream; + this.stream = stream ?? throw new ArgumentNullException(nameof(stream)); this.prefix = memoryAllocator.Allocate(MaxStackSize, AllocationOptions.Clean); this.suffix = memoryAllocator.Allocate(MaxStackSize, AllocationOptions.Clean); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs index 40b8d391a..8aeb01d7f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs @@ -44,7 +44,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters public static JpegColorConverter GetConverter(JpegColorSpace colorSpace) { JpegColorConverter converter = Converters.FirstOrDefault(c => c.ColorSpace == colorSpace); - if (converter == null) + + if (converter is null) { throw new Exception($"Could not find any converter for JpegColorSpace {colorSpace}!"); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs index c15024259..2e20da266 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs @@ -58,13 +58,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public void LoadAndStretchEdges(IPixelSource source, int sourceX, int sourceY) where TPixel : struct, IPixel { - var buffer = source.PixelBuffer as Buffer2D; - if (buffer == null) + if (source.PixelBuffer is Buffer2D buffer) + { + this.LoadAndStretchEdges(buffer, sourceX, sourceY); + } + else { throw new InvalidOperationException("LoadAndStretchEdges() is only valid for TPixel == T !"); } - - this.LoadAndStretchEdges(buffer, sourceX, sourceY); } /// diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 1eb4dad89..7561afa1e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -538,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) { this.isExif = true; - if (this.exifData == null) + if (this.exifData is null) { // The first 6 bytes (Exif00) will be skipped, because this is Jpeg specific this.exifData = profile.Skip(Exif00).ToArray(); @@ -575,7 +575,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] profile = new byte[remaining]; this.InputStream.Read(profile, 0, remaining); - if (this.iccData == null) + if (this.iccData is null) { this.iccData = profile; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 1a3bb7723..f7b6fe996 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -550,7 +550,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg private void WriteDefineHuffmanTables(int componentCount) { // Table identifiers. - byte[] headers = { 0x00, 0x10, 0x01, 0x11 }; + Span headers = stackalloc byte[] { 0x00, 0x10, 0x01, 0x11 }; + int markerlen = 2; HuffmanSpec[] specs = HuffmanSpec.TheHuffmanSpecs; @@ -628,7 +629,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] data = exifProfile?.ToByteArray(); - if (data == null || data.Length == 0) + if (data is null || data.Length == 0) { return; } @@ -687,7 +688,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// private void WriteIccProfile(IccProfile iccProfile) { - if (iccProfile == null) + if (iccProfile is null) { return; } @@ -698,7 +699,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] data = iccProfile.ToByteArray(); - if (data == null || data.Length == 0) + if (data is null || data.Length == 0) { return; } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index e1ec3c1d6..aa96b926c 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.Formats.Png this.ReadPhysicalChunk(metadata, chunk.Data.GetSpan()); break; case PngChunkType.Data: - if (image == null) + if (image is null) { this.InitializeImage(metadata, out image); } @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Png } } - if (image == null) + if (image is null) { throw new ImageFormatException("PNG Image does not contain a data chunk"); } diff --git a/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs index fd9c4ac63..55432d60b 100644 --- a/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs +++ b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib public void AllocateNewBytes(int bytes) { this.currentDataRemaining = bytes; - if (this.compressedStream == null) + if (this.compressedStream is null) { this.InitializeInflateStream(); } diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 3b014e7bd..894551e08 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp where TPixel : struct, IPixel { IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format); - if (decoder == null) + if (decoder is null) { return (null, null); } diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 9a46400fd..bf312cb6f 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp string ext = Path.GetExtension(filePath); IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext); - if (format == null) + if (format is null) { var sb = new StringBuilder(); sb.AppendLine($"Can't find a format that is associated with the file extention '{ext}'. Registered formats with there extensions include:"); @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format); - if (encoder == null) + if (encoder is null) { var sb = new StringBuilder(); sb.AppendLine($"Can't find encoder for file extention '{ext}' using image format '{format.Name}'. Registered encoders include:"); @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp Guard.NotNull(format, nameof(format)); IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format); - if (encoder == null) + if (encoder is null) { var sb = new StringBuilder(); sb.AppendLine("Can't find encoder for provided mime type. Available encoded:"); diff --git a/src/ImageSharp/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs index 929dd7e36..59571ce92 100644 --- a/src/ImageSharp/ImageFrameCollection.cs +++ b/src/ImageSharp/ImageFrameCollection.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Memory; namespace SixLabors.ImageSharp { @@ -23,9 +22,7 @@ namespace SixLabors.ImageSharp internal ImageFrameCollection(Image parent, int width, int height, TPixel backgroundColor) { - Guard.NotNull(parent, nameof(parent)); - - this.parent = parent; + this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, backgroundColor)); @@ -33,9 +30,7 @@ namespace SixLabors.ImageSharp internal ImageFrameCollection(Image parent, int width, int height, MemorySource memorySource) { - Guard.NotNull(parent, nameof(parent)); - - this.parent = parent; + this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, memorySource)); diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index 6f5af8ffc..1dd885721 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return null; } - if (this.data == null || this.data.Length < (this.thumbnailOffset + this.thumbnailLength)) + if (this.data is null || this.data.Length < (this.thumbnailOffset + this.thumbnailLength)) { return null; } @@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// The public byte[] ToByteArray() { - if (this.values == null) + if (this.values is null) { return this.data; } @@ -262,7 +262,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private void SyncResolution(ExifTag tag, double resolution) { ExifValue value = this.GetValue(tag); - if (value == null) + + if (value is null) { return; } @@ -283,7 +284,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return; } - if (this.data == null) + if (this.data is null) { this.values = new List(); return; diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs index db1d0c622..72db6305d 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs @@ -76,7 +76,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { var values = new List(); - if (this.ReadString(2) == "II") + // II == 0x4949 + if (this.ReadUInt16() == 0x4949) { this.endianness = Endianness.LittleEndian; } @@ -202,7 +203,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private object ConvertValue(ExifDataType dataType, ReadOnlySpan buffer, uint numberOfComponents) { - if (buffer == null || buffer.Length == 0) + if (buffer.Length == 0) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs index 4021227f5..286fdbe57 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] internal sealed class ExifTagDescriptionAttribute : Attribute { - private object value; - private string description; + private readonly object value; + private readonly string description; /// /// Initializes a new instance of the class. @@ -37,7 +37,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif public static string GetDescription(ExifTag tag, object value) { FieldInfo field = tag.GetType().GetTypeInfo().GetDeclaredField(tag.ToString()); - if (field == null) + + if (field is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs index 87e3e4494..e6da9b7d1 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { get { - if (this.Value == null) + if (this.Value is null) { return false; } @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { get { - if (this.Value == null) + if (this.Value is null) { return 4; } @@ -213,7 +213,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// public override string ToString() { - if (this.Value == null) + if (this.Value is null) { return null; } @@ -589,7 +589,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif type = type.GetElementType(); } - if (type == null || type == typeof(ushort)) + if (type is null || type == typeof(ushort)) { return new ExifValue(tag, ExifDataType.Short, value, isArray); } @@ -616,7 +616,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// private void CheckValue(object value) { - if (value == null) + if (value is null) { return; } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index dc75697e2..ade373341 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private ExifParts allowedParts; private IList values; private List dataOffsets; - private List ifdIndexes; - private List exifIndexes; - private List gpsIndexes; + private readonly List ifdIndexes; + private readonly List exifIndexes; + private readonly List gpsIndexes; /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs index 157453f1b..516887bcd 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccCurveSegment other) { - if (other == null) + if (other is null) { return false; } @@ -40,4 +40,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return this.Signature == other.Signature; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs index 2ad9079e1..7076e5144 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccOneDimensionalCurve other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs index 6873c5f4d..02ab301bd 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccResponseCurve other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs index 49b453a46..cc0f8f34d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using System.Text; namespace SixLabors.ImageSharp.MetaData.Profiles.Icc @@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The data to read public IccDataReader(byte[] data) { - Guard.NotNull(data, nameof(data)); - this.data = data; + this.data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs index bf39a0849..a58f62519 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs @@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc Guard.MustBeGreaterThan(length, 0, nameof(length)); - if (value == null) + if (value is null) { value = string.Empty; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 18280faaf..51ea2d4e4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -901,7 +901,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int size, count = 0; - if (value.Ascii == null) + if (value.Ascii is null) { count += this.WriteUInt32(0); } @@ -914,7 +914,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.dataStream.Position += size; } - if (value.Unicode == null) + if (value.Unicode is null) { count += this.WriteUInt32(0); count += this.WriteUInt32(0); @@ -929,7 +929,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.dataStream.Position += size; } - if (value.ScriptCode == null) + if (value.ScriptCode is null) { count += this.WriteUInt16(0); count += this.WriteByte(0); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs index 2b2fe1e4e..dac56c608 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// /// The byte array to read the ICC profile from /// - private byte[] data; + private readonly byte[] data; /// /// The backing file for the property @@ -200,7 +200,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return; } - if (this.data == null) + if (this.data is null) { this.header = new IccProfileHeader(); return; @@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return; } - if (this.data == null) + if (this.data is null) { this.entries = new List(); return; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs index 231f3818a..2687e10b6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs index 384ae850f..6aba18632 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs @@ -17,8 +17,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccClutProcessElement(IccClut clutValue) : base(IccMultiProcessElementSignature.Clut, clutValue?.InputChannelCount ?? 1, clutValue?.OutputChannelCount ?? 1) { - Guard.NotNull(clutValue, nameof(clutValue)); - this.ClutValue = clutValue; + this.ClutValue = clutValue ?? throw new ArgumentNullException(nameof(clutValue)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs index 0aa030684..7585fc212 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs @@ -18,8 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccCurveSetProcessElement(IccOneDimensionalCurve[] curves) : base(IccMultiProcessElementSignature.CurveSet, curves?.Length ?? 1, curves?.Length ?? 1) { - Guard.NotNull(curves, nameof(curves)); - this.Curves = curves; + this.Curves = curves ?? throw new ArgumentNullException(nameof(curves)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs index 3da482b1f..db2d56cc3 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccMultiProcessElement other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs index c008463ee..a87dae8c5 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.ChannelValues = channelValues; int channelLength = channelValues[0].Length; - bool channelsNotSame = channelValues.Any(t => t == null || t.Length != channelLength); + bool channelsNotSame = channelValues.Any(t => t is null || t.Length != channelLength); Guard.IsFalse(channelsNotSame, nameof(channelValues), "The number of values per channel is not the same for all channels"); } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs index 6df2f556f..54c205615 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccColorantOrderTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs index 90b1c304b..dd99a2f9f 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccColorantTableTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs index b2bbb7b56..cc1aea319 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccCrdInfoTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs index 40666934f..38a2f4522 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccCurveTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs index 7f034cebf..9b24bffe8 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs @@ -42,8 +42,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccDataTagDataEntry(byte[] data, bool isAscii, IccProfileTag tagSignature) : base(IccTypeSignature.Data, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentException(nameof(data)); this.IsAscii = isAscii; } @@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccDataTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs index 004603a0e..792c653f6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccDateTimeTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs index 8a7d068f9..a76310927 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) : base(IccTypeSignature.S15Fixed16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// @@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccFix16ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index f296a8b07..9a7f2123e 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLut16TagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs index f94d500c3..bc0335cd8 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLut8TagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs index c4f3f8a2a..22d5f7b2f 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLutAToBTagDataEntry other) { - if (other == null) + if (other is null) { return false; } @@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) { - bool thisNull = thisCurves == null; - bool entryNull = entryCurves == null; + bool thisNull = thisCurves is null; + bool entryNull = entryCurves is null; if (thisNull && entryNull) { @@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Vector3? CreateMatrix3x1(float[] matrix) { - if (matrix == null) + if (matrix is null) { return null; } @@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Matrix4x4? CreateMatrix3x3(float[,] matrix) { - if (matrix == null) + if (matrix is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs index 17bbf915b..a739358b5 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLutBToATagDataEntry other) { - if (other == null) + if (other is null) { return false; } @@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) { - bool thisNull = thisCurves == null; - bool entryNull = entryCurves == null; + bool thisNull = thisCurves is null; + bool entryNull = entryCurves is null; if (thisNull && entryNull) { @@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Vector3? CreateMatrix3x1(float[] matrix) { - if (matrix == null) + if (matrix is null) { return null; } @@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Matrix4x4? CreateMatrix3x3(float[,] matrix) { - if (matrix == null) + if (matrix is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs index f32e17714..262129a38 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMeasurementTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs index c006c9556..48ed048bf 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs @@ -29,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccMultiLocalizedUnicodeTagDataEntry(IccLocalizedString[] texts, IccProfileTag tagSignature) : base(IccTypeSignature.MultiLocalizedUnicode, tagSignature) { - Guard.NotNull(texts, nameof(texts)); - this.Texts = texts; + this.Texts = texts ?? throw new ArgumentNullException(nameof(texts)); } /// @@ -47,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs index dcfe010aa..1429a0a87 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMultiProcessElementsTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs index c42004634..da6fcd7a2 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs @@ -30,8 +30,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccProfileSequenceDescTagDataEntry(IccProfileDescription[] descriptions, IccProfileTag tagSignature) : base(IccTypeSignature.ProfileSequenceDesc, tagSignature) { - Guard.NotNull(descriptions, nameof(descriptions)); - this.Descriptions = descriptions; + this.Descriptions = descriptions ?? throw new ArgumentNullException(nameof(descriptions)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs index 333615524..51528a073 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifier[] data, IccProfileTag tagSignature) : base(IccTypeSignature.ProfileSequenceIdentifier, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs index de6264824..0bf8abfca 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs @@ -30,10 +30,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccScreeningTagDataEntry(IccScreeningFlag flags, IccScreeningChannel[] channels, IccProfileTag tagSignature) : base(IccTypeSignature.Screening, tagSignature) { - Guard.NotNull(channels, nameof(channels)); - this.Flags = flags; - this.Channels = channels; + this.Channels = channels ?? throw new ArgumentNullException(nameof(channels)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs index e469e7eab..da557e644 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs @@ -28,12 +28,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccSignatureTagDataEntry(string signatureData, IccProfileTag tagSignature) : base(IccTypeSignature.Signature, tagSignature) { - Guard.NotNull(signatureData, nameof(signatureData)); - this.SignatureData = signatureData; + this.SignatureData = signatureData ?? throw new ArgumentNullException(nameof(signatureData)); } /// - /// Gets the Signature + /// Gets the signature data /// public string SignatureData { get; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs index cc67dd1b1..ca1e4c491 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The converted entry public static explicit operator IccMultiLocalizedUnicodeTagDataEntry(IccTextDescriptionTagDataEntry textEntry) { - if (textEntry == null) + if (textEntry is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs index 1cf321893..f10712d96 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccTextTagDataEntry(string text, IccProfileTag tagSignature) : base(IccTypeSignature.Text, tagSignature) { - Guard.NotNull(text, nameof(text)); - this.Text = text; + this.Text = text ?? throw new ArgumentNullException(nameof(text)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs index 4d9979a4f..19430dc7b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) : base(IccTypeSignature.U16Fixed16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs index b0c225d85..d9c093bda 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt16ArrayTagDataEntry(ushort[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs index c8b95d835..803191929 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt32ArrayTagDataEntry(uint[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt32Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// @@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt32ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs index b780183df..2973b9ae6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt64ArrayTagDataEntry(ulong[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt64Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// @@ -46,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt64ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs index 920b9efc0..2391ce96a 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt8ArrayTagDataEntry(byte[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt8Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// @@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt8ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs index 28759a54c..eed4f97d4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs @@ -32,13 +32,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUcrBgTagDataEntry(ushort[] ucrCurve, ushort[] bgCurve, string description, IccProfileTag tagSignature) : base(IccTypeSignature.UcrBg, tagSignature) { - Guard.NotNull(ucrCurve, nameof(ucrCurve)); - Guard.NotNull(bgCurve, nameof(bgCurve)); - Guard.NotNull(description, nameof(description)); - - this.UcrCurve = ucrCurve; - this.BgCurve = bgCurve; - this.Description = description; + this.UcrCurve = ucrCurve ?? throw new ArgumentNullException(nameof(ucrCurve)); + this.BgCurve = bgCurve ?? throw new ArgumentNullException(nameof(bgCurve)); + this.Description = description ?? throw new ArgumentNullException(nameof(description)); } /// @@ -65,7 +61,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUcrBgTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs index 68a0ff2f4..da206a968 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUnknownTagDataEntry(byte[] data, IccProfileTag tagSignature) : base(IccTypeSignature.Unknown, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// @@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUnknownTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs index 162392326..c1c14d8cb 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccXyzTagDataEntry(Vector3[] data, IccProfileTag tagSignature) : base(IccTypeSignature.Xyz, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs index 3f9d865b7..4878d96e4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccClut other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs index 22e4a0523..56aa8b335 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs @@ -28,9 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// Third PCS value public IccColorantTableEntry(string name, ushort pcs1, ushort pcs2, ushort pcs3) { - Guard.NotNull(name, nameof(name)); - - this.Name = name; + this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.Pcs1 = pcs1; this.Pcs2 = pcs2; this.Pcs3 = pcs3; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs index 18e28e94c..00ededca4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs @@ -29,11 +29,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The text value of this string public IccLocalizedString(CultureInfo culture, string text) { - Guard.NotNull(culture, nameof(culture)); - Guard.NotNull(text, nameof(text)); - - this.Culture = culture; - this.Text = text; + this.Culture = culture ?? throw new ArgumentNullException(nameof(culture)); + this.Text = text ?? throw new ArgumentNullException(nameof(text)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs index a84631143..c46d6884b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs @@ -16,8 +16,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The LUT values public IccLut(float[] values) { - Guard.NotNull(values, nameof(values)); - this.Values = values; + this.Values = values ?? throw new ArgumentNullException(nameof(values)); } /// diff --git a/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs b/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs index c2c0277f9..cf66f5d5e 100644 --- a/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.PixelFormats hex = ToRgbaHex(hex); - if (hex == null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue)) + if (hex is null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue)) { throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); } diff --git a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs index a392b8d8e..43ba25972 100644 --- a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing /// public Image Apply() { - if (!this.mutate && this.destination == null) + if (!this.mutate && this.destination is null) { // Ensure we have cloned it if we are not mutating as we might have failed to register any processors this.destination = this.source.Clone(); @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing /// public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - if (!this.mutate && this.destination == null) + if (!this.mutate && this.destination is null) { // This will only work if the first processor applied is the cloning one thus // realistically for this optimization to work the resize must the first processor diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs index 95f4ef472..048af8261 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs @@ -33,9 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization /// The color to use for pixels that are below the threshold. public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor) { - Guard.NotNull(dither, nameof(dither)); - - this.Dither = dither; + this.Dither = dither ?? throw new ArgumentNullException(nameof(dither)); this.UpperColor = upperColor; this.LowerColor = lowerColor; } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs index 4100fef8c..b5e2eebc2 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs @@ -34,8 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette) : base(palette) { - Guard.NotNull(dither, nameof(dither)); - this.Dither = dither; + this.Dither = dither ?? throw new ArgumentNullException(nameof(dither)); } /// diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs index e70c8acd2..a1bbe7273 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; @@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering /// The palette to select substitute colors from. protected PaletteDitherProcessorBase(TPixel[] palette) { - Guard.NotNull(palette, nameof(palette)); - this.Palette = palette; + this.Palette = palette ?? throw new ArgumentNullException(nameof(palette)); this.paletteVector = new Vector4[this.Palette.Length]; PixelOperations.Instance.ToScaledVector4(this.Palette, this.paletteVector, this.Palette.Length); } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs index 0eb3db864..3eac70eea 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs @@ -233,7 +233,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { // If so, check if I have a previous node setup. This will only occur if the first color in the image // happens to be black, with an alpha component of zero. - if (this.previousNode == null) + if (this.previousNode is null) { this.previousColor = pixel; this.root.AddColor(ref pixel, this.maxColorBits, 0, this, ref rgba); @@ -309,7 +309,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { // Find the deepest level containing at least one reducible node int index = this.maxColorBits - 1; - while ((index > 0) && (this.ReducibleNodes[index] == null)) + while ((index > 0) && (this.ReducibleNodes[index] is null)) { index--; } @@ -440,7 +440,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization | ((rgba.R & Mask[level]) >> shift); OctreeNode child = this.children[index]; - if (child == null) + if (child is null) { // Create a new child node and store it in the array child = new OctreeNode(level + 1, colorBits, octree); diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs index 619107f97..021dc62fb 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs @@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// protected override TPixel[] GetPalette() { - if (this.palette == null) + if (this.palette is null) { this.palette = new TPixel[this.colors]; for (int k = 0; k < this.colors; k++) diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs index c077914ff..a610ae5bb 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs @@ -73,13 +73,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// The private static OrientationMode GetExifOrientation(Image source) { - if (source.MetaData.ExifProfile == null) + if (source.MetaData.ExifProfile is null) { return OrientationMode.Unknown; } ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation); - if (value == null) + if (value is null) { return OrientationMode.Unknown; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index b18d882c2..93c847d59 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms protected override void AfterImageApply(Image source, Image destination, Rectangle sourceRectangle) { ExifProfile profile = destination.MetaData.ExifProfile; - if (profile == null) + if (profile is null) { return; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs index 1b676139b..b22fa64cf 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms where TPixel : struct, IPixel { ExifProfile profile = image.MetaData.ExifProfile; - if (profile == null) + if (profile is null) { return; } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index ae2b12e87..d1d2ea077 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -73,9 +73,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named '{name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index 8ec8409ad..edc6994e7 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -228,9 +228,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index f0a924d27..8cf9dd62f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -124,9 +124,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named {name}"); } return (IResampler)property.GetValue(null);