Browse Source

Merge pull request #678 from carbon/nulls

Improve CQ7
af/merge-core
James Jackson-South 8 years ago
committed by GitHub
parent
commit
7c9b1d6c73
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs
  2. 2
      src/ImageSharp/Common/Helpers/DebugGuard.cs
  3. 6
      src/ImageSharp/Common/Helpers/Guard.cs
  4. 1
      src/ImageSharp/Formats/Bmp/BmpDecoder.cs
  5. 4
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  6. 2
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  7. 4
      src/ImageSharp/Formats/Gif/LzwDecoder.cs
  8. 3
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs
  9. 9
      src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs
  10. 4
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  11. 9
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
  12. 4
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  13. 2
      src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs
  14. 2
      src/ImageSharp/Image.Decode.cs
  15. 6
      src/ImageSharp/ImageExtensions.cs
  16. 9
      src/ImageSharp/ImageFrameCollection.cs
  17. 9
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
  18. 5
      src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
  19. 7
      src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs
  20. 10
      src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
  21. 6
      src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
  22. 4
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs
  23. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
  24. 2
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  25. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs
  26. 2
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs
  27. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  28. 6
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  29. 2
      src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
  30. 3
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs
  31. 3
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs
  32. 2
      src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs
  33. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  34. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
  35. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
  36. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  37. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
  38. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  39. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
  40. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
  41. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  42. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  43. 10
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  44. 10
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  45. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
  46. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
  47. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
  48. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
  49. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
  50. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
  51. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
  52. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  53. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
  54. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
  55. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
  56. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
  57. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
  58. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
  59. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
  60. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
  61. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs
  62. 2
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
  63. 4
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs
  64. 7
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs
  65. 3
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs
  66. 2
      src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs
  67. 4
      src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs
  68. 4
      src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
  69. 3
      src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs
  70. 4
      src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs
  71. 6
      src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs
  72. 2
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  73. 4
      src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs
  74. 2
      src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
  75. 2
      src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs
  76. 4
      tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs
  77. 4
      tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
  78. 4
      tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs

5
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(text, nameof(text));
Guard.NotNull(font, nameof(font)); 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; this.Options = options;

2
src/ImageSharp/Common/Helpers/DebugGuard.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp
public static void NotNull<T>(T value, string parameterName) public static void NotNull<T>(T value, string parameterName)
where T : class where T : class
{ {
if (value == null) if (value is null)
{ {
throw new ArgumentNullException(parameterName); throw new ArgumentNullException(parameterName);
} }

6
src/ImageSharp/Common/Helpers/Guard.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp
public static void NotNull<T>(T value, string parameterName) public static void NotNull<T>(T value, string parameterName)
where T : class where T : class
{ {
if (value == null) if (value is null)
{ {
throw new ArgumentNullException(parameterName); throw new ArgumentNullException(parameterName);
} }
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp
/// <exception cref="ArgumentException"><paramref name="value"/> is empty or contains only blanks.</exception> /// <exception cref="ArgumentException"><paramref name="value"/> is empty or contains only blanks.</exception>
public static void NotNullOrWhiteSpace(string value, string parameterName) public static void NotNullOrWhiteSpace(string value, string parameterName)
{ {
if (value == null) if (value is null)
{ {
throw new ArgumentNullException(parameterName); throw new ArgumentNullException(parameterName);
} }
@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp
/// <exception cref="ArgumentException"><paramref name="value"/> is empty.</exception> /// <exception cref="ArgumentException"><paramref name="value"/> is empty.</exception>
public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName) public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
{ {
if (value == null) if (value is null)
{ {
throw new ArgumentNullException(parameterName); throw new ArgumentNullException(parameterName);
} }

1
src/ImageSharp/Formats/Bmp/BmpDecoder.cs

@ -25,7 +25,6 @@ namespace SixLabors.ImageSharp.Formats.Bmp
{ {
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));

4
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -377,7 +377,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
ImageFrame<TPixel> currentFrame = null; ImageFrame<TPixel> currentFrame = null;
ImageFrame<TPixel> imageFrame; ImageFrame<TPixel> imageFrame;
if (previousFrame == null) if (previousFrame is null)
{ {
// This initializes the image to become fully transparent because the alpha channel is zero. // This initializes the image to become fully transparent because the alpha channel is zero.
image = new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metaData); image = new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metaData);
@ -485,7 +485,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
private void RestoreToBackground<TPixel>(ImageFrame<TPixel> frame) private void RestoreToBackground<TPixel>(ImageFrame<TPixel> frame)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (this.restoreArea == null) if (this.restoreArea is null)
{ {
return; return;
} }

2
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
{ {
foreach (ImageFrame<TPixel> frame in image.Frames) foreach (ImageFrame<TPixel> frame in image.Frames)
{ {
if (quantized == null) if (quantized is null)
{ {
quantized = this.quantizer.CreateFrameQuantizer<TPixel>().QuantizeFrame(frame); quantized = this.quantizer.CreateFrameQuantizer<TPixel>().QuantizeFrame(frame);
} }

4
src/ImageSharp/Formats/Gif/LzwDecoder.cs

@ -56,9 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <exception cref="System.ArgumentNullException"><paramref name="stream"/> is null.</exception> /// <exception cref="System.ArgumentNullException"><paramref name="stream"/> is null.</exception>
public LzwDecoder(MemoryAllocator memoryAllocator, Stream stream) public LzwDecoder(MemoryAllocator memoryAllocator, Stream stream)
{ {
Guard.NotNull(stream, nameof(stream)); this.stream = stream ?? throw new ArgumentNullException(nameof(stream));
this.stream = stream;
this.prefix = memoryAllocator.Allocate<int>(MaxStackSize, AllocationOptions.Clean); this.prefix = memoryAllocator.Allocate<int>(MaxStackSize, AllocationOptions.Clean);
this.suffix = memoryAllocator.Allocate<int>(MaxStackSize, AllocationOptions.Clean); this.suffix = memoryAllocator.Allocate<int>(MaxStackSize, AllocationOptions.Clean);

3
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) public static JpegColorConverter GetConverter(JpegColorSpace colorSpace)
{ {
JpegColorConverter converter = Converters.FirstOrDefault(c => c.ColorSpace == 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}!"); throw new Exception($"Could not find any converter for JpegColorSpace {colorSpace}!");
} }

9
src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs

@ -58,13 +58,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
public void LoadAndStretchEdges<TPixel>(IPixelSource<TPixel> source, int sourceX, int sourceY) public void LoadAndStretchEdges<TPixel>(IPixelSource<TPixel> source, int sourceX, int sourceY)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var buffer = source.PixelBuffer as Buffer2D<T>; if (source.PixelBuffer is Buffer2D<T> buffer)
if (buffer == null) {
this.LoadAndStretchEdges(buffer, sourceX, sourceY);
}
else
{ {
throw new InvalidOperationException("LoadAndStretchEdges<TPixels>() is only valid for TPixel == T !"); throw new InvalidOperationException("LoadAndStretchEdges<TPixels>() is only valid for TPixel == T !");
} }
this.LoadAndStretchEdges(buffer, sourceX, sourceY);
} }
/// <summary> /// <summary>

4
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -538,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker))
{ {
this.isExif = true; 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 // The first 6 bytes (Exif00) will be skipped, because this is Jpeg specific
this.exifData = profile.Skip(Exif00).ToArray(); this.exifData = profile.Skip(Exif00).ToArray();
@ -575,7 +575,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
byte[] profile = new byte[remaining]; byte[] profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining); this.InputStream.Read(profile, 0, remaining);
if (this.iccData == null) if (this.iccData is null)
{ {
this.iccData = profile; this.iccData = profile;
} }

9
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -550,7 +550,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
private void WriteDefineHuffmanTables(int componentCount) private void WriteDefineHuffmanTables(int componentCount)
{ {
// Table identifiers. // Table identifiers.
byte[] headers = { 0x00, 0x10, 0x01, 0x11 }; Span<byte> headers = stackalloc byte[] { 0x00, 0x10, 0x01, 0x11 };
int markerlen = 2; int markerlen = 2;
HuffmanSpec[] specs = HuffmanSpec.TheHuffmanSpecs; HuffmanSpec[] specs = HuffmanSpec.TheHuffmanSpecs;
@ -628,7 +629,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
byte[] data = exifProfile?.ToByteArray(); byte[] data = exifProfile?.ToByteArray();
if (data == null || data.Length == 0) if (data is null || data.Length == 0)
{ {
return; return;
} }
@ -687,7 +688,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// </exception> /// </exception>
private void WriteIccProfile(IccProfile iccProfile) private void WriteIccProfile(IccProfile iccProfile)
{ {
if (iccProfile == null) if (iccProfile is null)
{ {
return; return;
} }
@ -698,7 +699,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
byte[] data = iccProfile.ToByteArray(); byte[] data = iccProfile.ToByteArray();
if (data == null || data.Length == 0) if (data is null || data.Length == 0)
{ {
return; return;
} }

4
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.ReadPhysicalChunk(metadata, chunk.Data.GetSpan()); this.ReadPhysicalChunk(metadata, chunk.Data.GetSpan());
break; break;
case PngChunkType.Data: case PngChunkType.Data:
if (image == null) if (image is null)
{ {
this.InitializeImage(metadata, out image); 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"); throw new ImageFormatException("PNG Image does not contain a data chunk");
} }

2
src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs

@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
public void AllocateNewBytes(int bytes) public void AllocateNewBytes(int bytes)
{ {
this.currentDataRemaining = bytes; this.currentDataRemaining = bytes;
if (this.compressedStream == null) if (this.compressedStream is null)
{ {
this.InitializeInflateStream(); this.InitializeInflateStream();
} }

2
src/ImageSharp/Image.Decode.cs

@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format); IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format);
if (decoder == null) if (decoder is null)
{ {
return (null, null); return (null, null);
} }

6
src/ImageSharp/ImageExtensions.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp
string ext = Path.GetExtension(filePath); string ext = Path.GetExtension(filePath);
IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext); IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
if (format == null) if (format is null)
{ {
var sb = new StringBuilder(); 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:"); 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); IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);
if (encoder == null) if (encoder is null)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine($"Can't find encoder for file extention '{ext}' using image format '{format.Name}'. Registered encoders include:"); 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)); Guard.NotNull(format, nameof(format));
IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format); IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format);
if (encoder == null) if (encoder is null)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine("Can't find encoder for provided mime type. Available encoded:"); sb.AppendLine("Can't find encoder for provided mime type. Available encoded:");

9
src/ImageSharp/ImageFrameCollection.cs

@ -7,7 +7,6 @@ using System.Collections.Generic;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory;
namespace SixLabors.ImageSharp namespace SixLabors.ImageSharp
{ {
@ -23,9 +22,7 @@ namespace SixLabors.ImageSharp
internal ImageFrameCollection(Image<TPixel> parent, int width, int height, TPixel backgroundColor) internal ImageFrameCollection(Image<TPixel> parent, int width, int height, TPixel backgroundColor)
{ {
Guard.NotNull(parent, nameof(parent)); this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
this.parent = parent;
// Frames are already cloned within the caller // Frames are already cloned within the caller
this.frames.Add(new ImageFrame<TPixel>(parent.GetConfiguration(), width, height, backgroundColor)); this.frames.Add(new ImageFrame<TPixel>(parent.GetConfiguration(), width, height, backgroundColor));
@ -33,9 +30,7 @@ namespace SixLabors.ImageSharp
internal ImageFrameCollection(Image<TPixel> parent, int width, int height, MemorySource<TPixel> memorySource) internal ImageFrameCollection(Image<TPixel> parent, int width, int height, MemorySource<TPixel> memorySource)
{ {
Guard.NotNull(parent, nameof(parent)); this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
this.parent = parent;
// Frames are already cloned within the caller // Frames are already cloned within the caller
this.frames.Add(new ImageFrame<TPixel>(parent.GetConfiguration(), width, height, memorySource)); this.frames.Add(new ImageFrame<TPixel>(parent.GetConfiguration(), width, height, memorySource));

9
src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
return null; 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; return null;
} }
@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <returns>The <see cref="T:byte[]"/></returns> /// <returns>The <see cref="T:byte[]"/></returns>
public byte[] ToByteArray() public byte[] ToByteArray()
{ {
if (this.values == null) if (this.values is null)
{ {
return this.data; return this.data;
} }
@ -262,7 +262,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
private void SyncResolution(ExifTag tag, double resolution) private void SyncResolution(ExifTag tag, double resolution)
{ {
ExifValue value = this.GetValue(tag); ExifValue value = this.GetValue(tag);
if (value == null)
if (value is null)
{ {
return; return;
} }
@ -283,7 +284,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
return; return;
} }
if (this.data == null) if (this.data is null)
{ {
this.values = new List<ExifValue>(); this.values = new List<ExifValue>();
return; return;

5
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs

@ -76,7 +76,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{ {
var values = new List<ExifValue>(); var values = new List<ExifValue>();
if (this.ReadString(2) == "II") // II == 0x4949
if (this.ReadUInt16() == 0x4949)
{ {
this.endianness = Endianness.LittleEndian; this.endianness = Endianness.LittleEndian;
} }
@ -202,7 +203,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
private object ConvertValue(ExifDataType dataType, ReadOnlySpan<byte> buffer, uint numberOfComponents) private object ConvertValue(ExifDataType dataType, ReadOnlySpan<byte> buffer, uint numberOfComponents)
{ {
if (buffer == null || buffer.Length == 0) if (buffer.Length == 0)
{ {
return null; return null;
} }

7
src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs

@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
internal sealed class ExifTagDescriptionAttribute : Attribute internal sealed class ExifTagDescriptionAttribute : Attribute
{ {
private object value; private readonly object value;
private string description; private readonly string description;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ExifTagDescriptionAttribute"/> class. /// Initializes a new instance of the <see cref="ExifTagDescriptionAttribute"/> class.
@ -37,7 +37,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
public static string GetDescription(ExifTag tag, object value) public static string GetDescription(ExifTag tag, object value)
{ {
FieldInfo field = tag.GetType().GetTypeInfo().GetDeclaredField(tag.ToString()); FieldInfo field = tag.GetType().GetTypeInfo().GetDeclaredField(tag.ToString());
if (field == null)
if (field is null)
{ {
return null; return null;
} }

10
src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs

@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{ {
get get
{ {
if (this.Value == null) if (this.Value is null)
{ {
return false; return false;
} }
@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{ {
get get
{ {
if (this.Value == null) if (this.Value is null)
{ {
return 4; return 4;
} }
@ -213,7 +213,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() public override string ToString()
{ {
if (this.Value == null) if (this.Value is null)
{ {
return null; return null;
} }
@ -589,7 +589,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
type = type.GetElementType(); type = type.GetElementType();
} }
if (type == null || type == typeof(ushort)) if (type is null || type == typeof(ushort))
{ {
return new ExifValue(tag, ExifDataType.Short, value, isArray); return new ExifValue(tag, ExifDataType.Short, value, isArray);
} }
@ -616,7 +616,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// </exception> /// </exception>
private void CheckValue(object value) private void CheckValue(object value)
{ {
if (value == null) if (value is null)
{ {
return; return;
} }

6
src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs

@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
private ExifParts allowedParts; private ExifParts allowedParts;
private IList<ExifValue> values; private IList<ExifValue> values;
private List<int> dataOffsets; private List<int> dataOffsets;
private List<int> ifdIndexes; private readonly List<int> ifdIndexes;
private List<int> exifIndexes; private readonly List<int> exifIndexes;
private List<int> gpsIndexes; private readonly List<int> gpsIndexes;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ExifWriter"/> class. /// Initializes a new instance of the <see cref="ExifWriter"/> class.

4
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool Equals(IccCurveSegment other) public virtual bool Equals(IccCurveSegment other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }
@ -40,4 +40,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Signature == other.Signature; return this.Signature == other.Signature;
} }
} }
} }

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc /> /// <inheritdoc />
public bool Equals(IccOneDimensionalCurve other) public bool Equals(IccOneDimensionalCurve other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccResponseCurve other) public bool Equals(IccResponseCurve other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

4
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Text; using System.Text;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <param name="data">The data to read</param> /// <param name="data">The data to read</param>
public IccDataReader(byte[] data) public IccDataReader(byte[] data)
{ {
Guard.NotNull(data, nameof(data)); this.data = data ?? throw new ArgumentNullException(nameof(data));
this.data = data;
} }
/// <summary> /// <summary>

2
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)); Guard.MustBeGreaterThan(length, 0, nameof(length));
if (value == null) if (value is null)
{ {
value = string.Empty; value = string.Empty;
} }

6
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs

@ -901,7 +901,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
int size, count = 0; int size, count = 0;
if (value.Ascii == null) if (value.Ascii is null)
{ {
count += this.WriteUInt32(0); count += this.WriteUInt32(0);
} }
@ -914,7 +914,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
this.dataStream.Position += size; this.dataStream.Position += size;
} }
if (value.Unicode == null) if (value.Unicode is null)
{ {
count += this.WriteUInt32(0); count += this.WriteUInt32(0);
count += this.WriteUInt32(0); count += this.WriteUInt32(0);
@ -929,7 +929,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
this.dataStream.Position += size; this.dataStream.Position += size;
} }
if (value.ScriptCode == null) if (value.ScriptCode is null)
{ {
count += this.WriteUInt16(0); count += this.WriteUInt16(0);
count += this.WriteByte(0); count += this.WriteByte(0);

6
src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <summary> /// <summary>
/// The byte array to read the ICC profile from /// The byte array to read the ICC profile from
/// </summary> /// </summary>
private byte[] data; private readonly byte[] data;
/// <summary> /// <summary>
/// The backing file for the <see cref="Entries"/> property /// The backing file for the <see cref="Entries"/> property
@ -200,7 +200,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return; return;
} }
if (this.data == null) if (this.data is null)
{ {
this.header = new IccProfileHeader(); this.header = new IccProfileHeader();
return; return;
@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return; return;
} }
if (this.data == null) if (this.data is null)
{ {
this.entries = new List<IccTagDataEntry>(); this.entries = new List<IccTagDataEntry>();
return; return;

2
src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool Equals(IccTagDataEntry other) public virtual bool Equals(IccTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs

@ -17,8 +17,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccClutProcessElement(IccClut clutValue) public IccClutProcessElement(IccClut clutValue)
: base(IccMultiProcessElementSignature.Clut, clutValue?.InputChannelCount ?? 1, clutValue?.OutputChannelCount ?? 1) : base(IccMultiProcessElementSignature.Clut, clutValue?.InputChannelCount ?? 1, clutValue?.OutputChannelCount ?? 1)
{ {
Guard.NotNull(clutValue, nameof(clutValue)); this.ClutValue = clutValue ?? throw new ArgumentNullException(nameof(clutValue));
this.ClutValue = clutValue;
} }
/// <summary> /// <summary>

3
src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs

@ -18,8 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccCurveSetProcessElement(IccOneDimensionalCurve[] curves) public IccCurveSetProcessElement(IccOneDimensionalCurve[] curves)
: base(IccMultiProcessElementSignature.CurveSet, curves?.Length ?? 1, curves?.Length ?? 1) : base(IccMultiProcessElementSignature.CurveSet, curves?.Length ?? 1, curves?.Length ?? 1)
{ {
Guard.NotNull(curves, nameof(curves)); this.Curves = curves ?? throw new ArgumentNullException(nameof(curves));
this.Curves = curves;
} }
/// <summary> /// <summary>

2
src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool Equals(IccMultiProcessElement other) public virtual bool Equals(IccMultiProcessElement other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
this.ChannelValues = channelValues; this.ChannelValues = channelValues;
int channelLength = channelValues[0].Length; 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"); Guard.IsFalse(channelsNotSame, nameof(channelValues), "The number of values per channel is not the same for all channels");
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccColorantOrderTagDataEntry other) public bool Equals(IccColorantOrderTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccColorantTableTagDataEntry other) public bool Equals(IccColorantTableTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccCrdInfoTagDataEntry other) public bool Equals(IccCrdInfoTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs

@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccCurveTagDataEntry other) public bool Equals(IccCurveTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
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) public IccDataTagDataEntry(byte[] data, bool isAscii, IccProfileTag tagSignature)
: base(IccTypeSignature.Data, tagSignature) : base(IccTypeSignature.Data, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentException(nameof(data));
this.Data = data;
this.IsAscii = isAscii; this.IsAscii = isAscii;
} }
@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccDataTagDataEntry other) public bool Equals(IccDataTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccDateTimeTagDataEntry other) public bool Equals(IccDateTimeTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) public IccFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.S15Fixed16Array, tagSignature) : base(IccTypeSignature.S15Fixed16Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>
@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccFix16ArrayTagDataEntry other) public bool Equals(IccFix16ArrayTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs

@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut16TagDataEntry other) public bool Equals(IccLut16TagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs

@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut8TagDataEntry other) public bool Equals(IccLut8TagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

10
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs

@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutAToBTagDataEntry other) public bool Equals(IccLutAToBTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }
@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)
{ {
bool thisNull = thisCurves == null; bool thisNull = thisCurves is null;
bool entryNull = entryCurves == null; bool entryNull = entryCurves is null;
if (thisNull && entryNull) if (thisNull && entryNull)
{ {
@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private Vector3? CreateMatrix3x1(float[] matrix) private Vector3? CreateMatrix3x1(float[] matrix)
{ {
if (matrix == null) if (matrix is null)
{ {
return null; return null;
} }
@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private Matrix4x4? CreateMatrix3x3(float[,] matrix) private Matrix4x4? CreateMatrix3x3(float[,] matrix)
{ {
if (matrix == null) if (matrix is null)
{ {
return null; return null;
} }

10
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs

@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutBToATagDataEntry other) public bool Equals(IccLutBToATagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }
@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)
{ {
bool thisNull = thisCurves == null; bool thisNull = thisCurves is null;
bool entryNull = entryCurves == null; bool entryNull = entryCurves is null;
if (thisNull && entryNull) if (thisNull && entryNull)
{ {
@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private Vector3? CreateMatrix3x1(float[] matrix) private Vector3? CreateMatrix3x1(float[] matrix)
{ {
if (matrix == null) if (matrix is null)
{ {
return null; return null;
} }
@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private Matrix4x4? CreateMatrix3x3(float[,] matrix) private Matrix4x4? CreateMatrix3x3(float[,] matrix)
{ {
if (matrix == null) if (matrix is null)
{ {
return null; return null;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs

@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMeasurementTagDataEntry other) public bool Equals(IccMeasurementTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs

@ -29,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccMultiLocalizedUnicodeTagDataEntry(IccLocalizedString[] texts, IccProfileTag tagSignature) public IccMultiLocalizedUnicodeTagDataEntry(IccLocalizedString[] texts, IccProfileTag tagSignature)
: base(IccTypeSignature.MultiLocalizedUnicode, tagSignature) : base(IccTypeSignature.MultiLocalizedUnicode, tagSignature)
{ {
Guard.NotNull(texts, nameof(texts)); this.Texts = texts ?? throw new ArgumentNullException(nameof(texts));
this.Texts = texts;
} }
/// <summary> /// <summary>
@ -47,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other) public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs

@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMultiProcessElementsTagDataEntry other) public bool Equals(IccMultiProcessElementsTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs

@ -30,8 +30,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccProfileSequenceDescTagDataEntry(IccProfileDescription[] descriptions, IccProfileTag tagSignature) public IccProfileSequenceDescTagDataEntry(IccProfileDescription[] descriptions, IccProfileTag tagSignature)
: base(IccTypeSignature.ProfileSequenceDesc, tagSignature) : base(IccTypeSignature.ProfileSequenceDesc, tagSignature)
{ {
Guard.NotNull(descriptions, nameof(descriptions)); this.Descriptions = descriptions ?? throw new ArgumentNullException(nameof(descriptions));
this.Descriptions = descriptions;
} }
/// <summary> /// <summary>

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs

@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifier[] data, IccProfileTag tagSignature) public IccProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifier[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.ProfileSequenceIdentifier, tagSignature) : base(IccTypeSignature.ProfileSequenceIdentifier, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>

4
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) public IccScreeningTagDataEntry(IccScreeningFlag flags, IccScreeningChannel[] channels, IccProfileTag tagSignature)
: base(IccTypeSignature.Screening, tagSignature) : base(IccTypeSignature.Screening, tagSignature)
{ {
Guard.NotNull(channels, nameof(channels));
this.Flags = flags; this.Flags = flags;
this.Channels = channels; this.Channels = channels ?? throw new ArgumentNullException(nameof(channels));
} }
/// <summary> /// <summary>

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs

@ -28,12 +28,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccSignatureTagDataEntry(string signatureData, IccProfileTag tagSignature) public IccSignatureTagDataEntry(string signatureData, IccProfileTag tagSignature)
: base(IccTypeSignature.Signature, tagSignature) : base(IccTypeSignature.Signature, tagSignature)
{ {
Guard.NotNull(signatureData, nameof(signatureData)); this.SignatureData = signatureData ?? throw new ArgumentNullException(nameof(signatureData));
this.SignatureData = signatureData;
} }
/// <summary> /// <summary>
/// Gets the Signature /// Gets the signature data
/// </summary> /// </summary>
public string SignatureData { get; } public string SignatureData { get; }

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <returns>The converted entry</returns> /// <returns>The converted entry</returns>
public static explicit operator IccMultiLocalizedUnicodeTagDataEntry(IccTextDescriptionTagDataEntry textEntry) public static explicit operator IccMultiLocalizedUnicodeTagDataEntry(IccTextDescriptionTagDataEntry textEntry)
{ {
if (textEntry == null) if (textEntry is null)
{ {
return null; return null;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccTextTagDataEntry(string text, IccProfileTag tagSignature) public IccTextTagDataEntry(string text, IccProfileTag tagSignature)
: base(IccTypeSignature.Text, tagSignature) : base(IccTypeSignature.Text, tagSignature)
{ {
Guard.NotNull(text, nameof(text)); this.Text = text ?? throw new ArgumentNullException(nameof(text));
this.Text = text;
} }
/// <summary> /// <summary>

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) public IccUFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.U16Fixed16Array, tagSignature) : base(IccTypeSignature.U16Fixed16Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUInt16ArrayTagDataEntry(ushort[] data, IccProfileTag tagSignature) public IccUInt16ArrayTagDataEntry(ushort[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.UInt16Array, tagSignature) : base(IccTypeSignature.UInt16Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUInt32ArrayTagDataEntry(uint[] data, IccProfileTag tagSignature) public IccUInt32ArrayTagDataEntry(uint[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.UInt32Array, tagSignature) : base(IccTypeSignature.UInt32Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>
@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt32ArrayTagDataEntry other) public bool Equals(IccUInt32ArrayTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs

@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUInt64ArrayTagDataEntry(ulong[] data, IccProfileTag tagSignature) public IccUInt64ArrayTagDataEntry(ulong[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.UInt64Array, tagSignature) : base(IccTypeSignature.UInt64Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>
@ -46,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt64ArrayTagDataEntry other) public bool Equals(IccUInt64ArrayTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUInt8ArrayTagDataEntry(byte[] data, IccProfileTag tagSignature) public IccUInt8ArrayTagDataEntry(byte[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.UInt8Array, tagSignature) : base(IccTypeSignature.UInt8Array, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>
@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt8ArrayTagDataEntry other) public bool Equals(IccUInt8ArrayTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

12
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) public IccUcrBgTagDataEntry(ushort[] ucrCurve, ushort[] bgCurve, string description, IccProfileTag tagSignature)
: base(IccTypeSignature.UcrBg, tagSignature) : base(IccTypeSignature.UcrBg, tagSignature)
{ {
Guard.NotNull(ucrCurve, nameof(ucrCurve)); this.UcrCurve = ucrCurve ?? throw new ArgumentNullException(nameof(ucrCurve));
Guard.NotNull(bgCurve, nameof(bgCurve)); this.BgCurve = bgCurve ?? throw new ArgumentNullException(nameof(bgCurve));
Guard.NotNull(description, nameof(description)); this.Description = description ?? throw new ArgumentNullException(nameof(description));
this.UcrCurve = ucrCurve;
this.BgCurve = bgCurve;
this.Description = description;
} }
/// <summary> /// <summary>
@ -65,7 +61,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUcrBgTagDataEntry other) public bool Equals(IccUcrBgTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs

@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccUnknownTagDataEntry(byte[] data, IccProfileTag tagSignature) public IccUnknownTagDataEntry(byte[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.Unknown, tagSignature) : base(IccTypeSignature.Unknown, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>
@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUnknownTagDataEntry other) public bool Equals(IccUnknownTagDataEntry other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs

@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccXyzTagDataEntry(Vector3[] data, IccProfileTag tagSignature) public IccXyzTagDataEntry(Vector3[] data, IccProfileTag tagSignature)
: base(IccTypeSignature.Xyz, tagSignature) : base(IccTypeSignature.Xyz, tagSignature)
{ {
Guard.NotNull(data, nameof(data)); this.Data = data ?? throw new ArgumentNullException(nameof(data));
this.Data = data;
} }
/// <summary> /// <summary>

2
src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs

@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccClut other) public bool Equals(IccClut other)
{ {
if (other == null) if (other is null)
{ {
return false; return false;
} }

4
src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs

@ -28,9 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <param name="pcs3">Third PCS value</param> /// <param name="pcs3">Third PCS value</param>
public IccColorantTableEntry(string name, ushort pcs1, ushort pcs2, ushort pcs3) public IccColorantTableEntry(string name, ushort pcs1, ushort pcs2, ushort pcs3)
{ {
Guard.NotNull(name, nameof(name)); this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Name = name;
this.Pcs1 = pcs1; this.Pcs1 = pcs1;
this.Pcs2 = pcs2; this.Pcs2 = pcs2;
this.Pcs3 = pcs3; this.Pcs3 = pcs3;

7
src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs

@ -29,11 +29,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <param name="text">The text value of this string</param> /// <param name="text">The text value of this string</param>
public IccLocalizedString(CultureInfo culture, string text) public IccLocalizedString(CultureInfo culture, string text)
{ {
Guard.NotNull(culture, nameof(culture)); this.Culture = culture ?? throw new ArgumentNullException(nameof(culture));
Guard.NotNull(text, nameof(text)); this.Text = text ?? throw new ArgumentNullException(nameof(text));
this.Culture = culture;
this.Text = text;
} }
/// <summary> /// <summary>

3
src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs

@ -16,8 +16,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <param name="values">The LUT values</param> /// <param name="values">The LUT values</param>
public IccLut(float[] values) public IccLut(float[] values)
{ {
Guard.NotNull(values, nameof(values)); this.Values = values ?? throw new ArgumentNullException(nameof(values));
this.Values = values;
} }
/// <summary> /// <summary>

2
src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.PixelFormats
hex = ToRgbaHex(hex); 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)); throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex));
} }

4
src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Apply() public Image<TPixel> 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 // Ensure we have cloned it if we are not mutating as we might have failed to register any processors
this.destination = this.source.Clone(); this.destination = this.source.Clone();
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc/> /// <inheritdoc/>
public IImageProcessingContext<TPixel> ApplyProcessor(IImageProcessor<TPixel> processor, Rectangle rectangle) public IImageProcessingContext<TPixel> ApplyProcessor(IImageProcessor<TPixel> 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 // 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 // realistically for this optimization to work the resize must the first processor

4
src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs

@ -33,9 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
/// <param name="lowerColor">The color to use for pixels that are below the threshold.</param> /// <param name="lowerColor">The color to use for pixels that are below the threshold.</param>
public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor) public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor)
{ {
Guard.NotNull(dither, nameof(dither)); this.Dither = dither ?? throw new ArgumentNullException(nameof(dither));
this.Dither = dither;
this.UpperColor = upperColor; this.UpperColor = upperColor;
this.LowerColor = lowerColor; this.LowerColor = lowerColor;
} }

3
src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs

@ -34,8 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette) public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette)
: base(palette) : base(palette)
{ {
Guard.NotNull(dither, nameof(dither)); this.Dither = dither ?? throw new ArgumentNullException(nameof(dither));
this.Dither = dither;
} }
/// <summary> /// <summary>

4
src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
/// <param name="palette">The palette to select substitute colors from.</param> /// <param name="palette">The palette to select substitute colors from.</param>
protected PaletteDitherProcessorBase(TPixel[] palette) protected PaletteDitherProcessorBase(TPixel[] palette)
{ {
Guard.NotNull(palette, nameof(palette)); this.Palette = palette ?? throw new ArgumentNullException(nameof(palette));
this.Palette = palette;
this.paletteVector = new Vector4[this.Palette.Length]; this.paletteVector = new Vector4[this.Palette.Length];
PixelOperations<TPixel>.Instance.ToScaledVector4(this.Palette, this.paletteVector, this.Palette.Length); PixelOperations<TPixel>.Instance.ToScaledVector4(this.Palette, this.paletteVector, this.Palette.Length);
} }

6
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 // 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. // happens to be black, with an alpha component of zero.
if (this.previousNode == null) if (this.previousNode is null)
{ {
this.previousColor = pixel; this.previousColor = pixel;
this.root.AddColor(ref pixel, this.maxColorBits, 0, this, ref rgba); 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 // Find the deepest level containing at least one reducible node
int index = this.maxColorBits - 1; int index = this.maxColorBits - 1;
while ((index > 0) && (this.ReducibleNodes[index] == null)) while ((index > 0) && (this.ReducibleNodes[index] is null))
{ {
index--; index--;
} }
@ -440,7 +440,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
| ((rgba.R & Mask[level]) >> shift); | ((rgba.R & Mask[level]) >> shift);
OctreeNode child = this.children[index]; OctreeNode child = this.children[index];
if (child == null) if (child is null)
{ {
// Create a new child node and store it in the array // Create a new child node and store it in the array
child = new OctreeNode(level + 1, colorBits, octree); child = new OctreeNode(level + 1, colorBits, octree);

2
src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs

@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <inheritdoc/> /// <inheritdoc/>
protected override TPixel[] GetPalette() protected override TPixel[] GetPalette()
{ {
if (this.palette == null) if (this.palette is null)
{ {
this.palette = new TPixel[this.colors]; this.palette = new TPixel[this.colors];
for (int k = 0; k < this.colors; k++) for (int k = 0; k < this.colors; k++)

4
src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs

@ -73,13 +73,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// <returns>The <see cref="OrientationMode"/></returns> /// <returns>The <see cref="OrientationMode"/></returns>
private static OrientationMode GetExifOrientation(Image<TPixel> source) private static OrientationMode GetExifOrientation(Image<TPixel> source)
{ {
if (source.MetaData.ExifProfile == null) if (source.MetaData.ExifProfile is null)
{ {
return OrientationMode.Unknown; return OrientationMode.Unknown;
} }
ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation); ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation);
if (value == null) if (value is null)
{ {
return OrientationMode.Unknown; return OrientationMode.Unknown;
} }

2
src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
protected override void AfterImageApply(Image<TPixel> source, Image<TPixel> destination, Rectangle sourceRectangle) protected override void AfterImageApply(Image<TPixel> source, Image<TPixel> destination, Rectangle sourceRectangle)
{ {
ExifProfile profile = destination.MetaData.ExifProfile; ExifProfile profile = destination.MetaData.ExifProfile;
if (profile == null) if (profile is null)
{ {
return; return;
} }

2
src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
ExifProfile profile = image.MetaData.ExifProfile; ExifProfile profile = image.MetaData.ExifProfile;
if (profile == null) if (profile is null)
{ {
return; return;
} }

4
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); 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); return (IResampler)property.GetValue(null);

4
tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs

@ -228,9 +228,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); 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); return (IResampler)property.GetValue(null);

4
tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs

@ -124,9 +124,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); 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); return (IResampler)property.GetValue(null);

Loading…
Cancel
Save