diff --git a/src/ImageSharp/ColorSpaces/CieLab.cs b/src/ImageSharp/ColorSpaces/CieLab.cs
index ce5c6c118..66900079f 100644
--- a/src/ImageSharp/ColorSpaces/CieLab.cs
+++ b/src/ImageSharp/ColorSpaces/CieLab.cs
@@ -194,12 +194,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
- if (obj is CieLab)
- {
- return this.Equals((CieLab)obj);
- }
-
- return false;
+ return obj is CieLab other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/Common/Extensions/ListExtensions.cs b/src/ImageSharp/Common/Extensions/ListExtensions.cs
deleted file mode 100644
index 2713896c0..000000000
--- a/src/ImageSharp/Common/Extensions/ListExtensions.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System.Collections.Generic;
-
-namespace SixLabors.ImageSharp.Common.Extensions
-{
- ///
- /// Encapsulates a series of time saving extension methods to the class.
- ///
- internal static class ListExtensions
- {
- ///
- /// Inserts an item at the given index automatically expanding the capacity if required.
- ///
- /// The type of object within the list
- /// The list
- /// The index
- /// The item to insert
- public static void SafeInsert(this List list, int index, T item)
- {
- if (index >= list.Count)
- {
- list.Add(item);
- }
- else
- {
- list[index] = item;
- }
- }
-
- ///
- /// Removes the last element from a list and returns that element. This method changes the length of the list.
- ///
- /// The type of object within the list
- /// The list
- /// The last element in the specified sequence.
- public static T Pop(this List list)
- {
- int last = list.Count - 1;
- T item = list[last];
- list.RemoveAt(last);
- return item;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
index d3ea9743f..6d473fd4b 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
@@ -6,6 +6,7 @@ using System.Buffers.Binary;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using SixLabors.ImageSharp.IO;
@@ -462,7 +463,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
}
}
- private unsafe double ConvertToDouble(ReadOnlySpan buffer)
+ private double ConvertToDouble(ReadOnlySpan buffer)
{
if (buffer.Length < 8)
{
@@ -473,7 +474,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
? BinaryPrimitives.ReadInt64BigEndian(buffer)
: BinaryPrimitives.ReadInt64LittleEndian(buffer);
- return *((double*)&intValue);
+ return Unsafe.As(ref intValue);
}
private uint ConvertToUInt32(ReadOnlySpan buffer)
@@ -501,7 +502,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
: BinaryPrimitives.ReadUInt16LittleEndian(buffer);
}
- private unsafe float ConvertToSingle(ReadOnlySpan buffer)
+ private float ConvertToSingle(ReadOnlySpan buffer)
{
if (buffer.Length < 4)
{
@@ -512,7 +513,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
? BinaryPrimitives.ReadInt32BigEndian(buffer)
: BinaryPrimitives.ReadInt32LittleEndian(buffer);
- return *((float*)&intValue);
+ return Unsafe.As(ref intValue);
}
private Rational ToRational(ReadOnlySpan buffer)
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
index bdd902e23..d475959c6 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
@@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
///
public bool Equals(ExifValue other)
{
- if (ReferenceEquals(other, null))
+ if (other is null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
index 9c3f8aa5e..a241acd21 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
@@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccParametricCurve other)
{
- if (other == null)
+ if (other is null)
{
return false;
}
@@ -148,16 +148,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccParametricCurve other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
index 02a817b8c..e15d8a434 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
@@ -67,16 +67,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccResponseCurve other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs
index 8b942498a..7dc8cf98a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs
@@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// Reads an ICC profile version number
///
/// the version number
- public Version ReadVersionNumber()
+ public IccVersion ReadVersionNumber()
{
int version = this.ReadInt32();
@@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
int minor = (version >> 20) & 0x0F;
int bugfix = (version >> 16) & 0x0F;
- return new Version(major, minor, bugfix);
+ return new IccVersion(major, minor, bugfix);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
index 538a31d6a..5be0060f6 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
@@ -3,6 +3,7 @@
using System;
using System.Buffers.Binary;
+using System.Runtime.CompilerServices;
using System.Text;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
@@ -70,22 +71,22 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// Reads a float.
///
/// the value
- public unsafe float ReadSingle()
+ public float ReadSingle()
{
int intValue = this.ReadInt32();
- return *((float*)&intValue);
+ return Unsafe.As(ref intValue);
}
///
/// Reads a double
///
/// the value
- public unsafe double ReadDouble()
+ public double ReadDouble()
{
long intValue = this.ReadInt64();
- return *((double*)&intValue);
+ return Unsafe.As(ref intValue);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs
index 791a94a33..1a3c2c0ac 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs
@@ -31,11 +31,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteVersionNumber(Version value)
+ public int WriteVersionNumber(in IccVersion value)
{
int major = value.Major.Clamp(0, byte.MaxValue);
int minor = value.Minor.Clamp(0, 15);
- int bugfix = value.Build.Clamp(0, 15);
+ int bugfix = value.Patch.Clamp(0, 15);
// TODO: This is not used?
byte mb = (byte)((minor << 4) | bugfix);
@@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteProfileId(IccProfileId value)
+ public int WriteProfileId(in IccProfileId value)
{
return this.WriteUInt32(value.Part1)
+ this.WriteUInt32(value.Part2)
@@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WritePositionNumber(IccPositionNumber value)
+ public int WritePositionNumber(in IccPositionNumber value)
{
return this.WriteUInt32(value.Offset)
+ this.WriteUInt32(value.Size);
@@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteResponseNumber(IccResponseNumber value)
+ public int WriteResponseNumber(in IccResponseNumber value)
{
return this.WriteUInt16(value.DeviceCode)
+ this.WriteFix16(value.MeasurementValue);
@@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteNamedColor(IccNamedColor value)
+ public int WriteNamedColor(in IccNamedColor value)
{
return this.WriteAsciiString(value.Name, 32, true)
+ this.WriteArray(value.PcsCoordinates)
@@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteProfileDescription(IccProfileDescription value)
+ public int WriteProfileDescription(in IccProfileDescription value)
{
return this.WriteUInt32(value.DeviceManufacturer)
+ this.WriteUInt32(value.DeviceModel)
@@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// The value to write
/// the number of bytes written
- public int WriteScreeningChannel(IccScreeningChannel value)
+ public int WriteScreeningChannel(in IccScreeningChannel value)
{
return this.WriteFix16(value.Frequency)
+ this.WriteFix16(value.Angle)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs
index f91572cfe..189b40275 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs
@@ -7,42 +7,42 @@ using System.Numerics;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
///
- /// Contains all values of an ICC profile header
+ /// Contains all values of an ICC profile header.
///
public sealed class IccProfileHeader
{
///
- /// Gets or sets the profile size in bytes (will be ignored when writing a profile)
+ /// Gets or sets the profile size in bytes (will be ignored when writing a profile).
///
public uint Size { get; set; }
///
- /// Gets or sets the preferred CMM (Color Management Module) type
+ /// Gets or sets the preferred CMM (Color Management Module) type.
///
public string CmmType { get; set; }
///
- /// Gets or sets the profiles version number
+ /// Gets or sets the profiles version number.
///
- public Version Version { get; set; }
+ public IccVersion Version { get; set; }
///
- /// Gets or sets the type of the profile
+ /// Gets or sets the type of the profile.
///
public IccProfileClass Class { get; set; }
///
- /// Gets or sets the data colorspace
+ /// Gets or sets the data colorspace.
///
public IccColorSpaceType DataColorSpace { get; set; }
///
- /// Gets or sets the profile connection space
+ /// Gets or sets the profile connection space.
///
public IccColorSpaceType ProfileConnectionSpace { get; set; }
///
- /// Gets or sets the date and time this profile was created
+ /// Gets or sets the date and time this profile was created.
///
public DateTime CreationDate { get; set; }
@@ -59,42 +59,42 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// Gets or sets the profile flags to indicate various options for the CMM
- /// such as distributed processing and caching options
+ /// such as distributed processing and caching options.
///
public IccProfileFlag Flags { get; set; }
///
- /// Gets or sets the device manufacturer of the device for which this profile is created
+ /// Gets or sets the device manufacturer of the device for which this profile is created.
///
public uint DeviceManufacturer { get; set; }
///
- /// Gets or sets the model of the device for which this profile is created
+ /// Gets or sets the model of the device for which this profile is created.
///
public uint DeviceModel { get; set; }
///
- /// Gets or sets the device attributes unique to the particular device setup such as media type
+ /// Gets or sets the device attributes unique to the particular device setup such as media type.
///
public IccDeviceAttribute DeviceAttributes { get; set; }
///
- /// Gets or sets the rendering Intent
+ /// Gets or sets the rendering Intent.
///
public IccRenderingIntent RenderingIntent { get; set; }
///
- /// Gets or sets The normalized XYZ values of the illuminant of the PCS
+ /// Gets or sets The normalized XYZ values of the illuminant of the PCS.
///
public Vector3 PcsIlluminant { get; set; }
///
- /// Gets or sets Profile creator signature
+ /// Gets or sets profile creator signature.
///
public string CreatorSignature { get; set; }
///
- /// Gets or sets the profile ID (hash)
+ /// Gets or sets the profile ID (hash).
///
public IccProfileId Id { get; set; }
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
index 1b0d041b6..231f3818a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
@@ -44,28 +44,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccTagDataEntry entry && this.Equals(entry);
}
- ///
- public override int GetHashCode()
- {
- unchecked
- {
- return (int)this.Signature * 397;
- }
- }
-
///
public virtual bool Equals(IccTagDataEntry other)
{
@@ -81,5 +62,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Signature == other.Signature;
}
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (int)this.Signature * 397;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
index b400e1bd7..c008463ee 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
@@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccChromaticityTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -104,17 +104,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccChromaticityTagDataEntry && this.Equals((IccChromaticityTagDataEntry)obj);
+ return obj is IccChromaticityTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
index 73024ee12..2194b8ab4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
@@ -65,16 +65,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccColorantOrderTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
index 353dab604..90b1c304b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
@@ -66,16 +66,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccColorantTableTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
index 848418f95..b2bbb7b56 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
@@ -115,16 +115,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccCrdInfoTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
index c9a59bb32..154afd8ed 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
@@ -113,16 +113,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccCurveTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
index c8f5f8b7c..a1addaa90 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -89,16 +89,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccDataTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
index 7a2d97571..004603a0e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
@@ -60,17 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccDateTimeTagDataEntry && this.Equals((IccDateTimeTagDataEntry)obj);
+ return obj is IccDateTimeTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
index afe4e0bd3..b0d9e1ef9 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccFix16ArrayTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
index d98e45ace..f296a8b07 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
@@ -137,17 +137,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccLut16TagDataEntry && this.Equals((IccLut16TagDataEntry)obj);
+ return obj is IccLut16TagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
index e57e0f543..f94d500c3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
@@ -140,17 +140,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccLut8TagDataEntry && this.Equals((IccLut8TagDataEntry)obj);
+ return obj is IccLut8TagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
index 59c80d409..c4f3f8a2a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
@@ -177,16 +177,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccLutAToBTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
index 57b17c452..17bbf915b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
@@ -177,16 +177,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccLutBToATagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
index 5f2dbe347..f32e17714 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
@@ -100,17 +100,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccMeasurementTagDataEntry && this.Equals((IccMeasurementTagDataEntry)obj);
+ return obj is IccMeasurementTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index d1745faac..c006c9556 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
@@ -63,17 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccMultiLocalizedUnicodeTagDataEntry && this.Equals((IccMultiLocalizedUnicodeTagDataEntry)obj);
+ return obj is IccMultiLocalizedUnicodeTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
index 8b0c06568..dcfe010aa 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
@@ -84,16 +84,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccMultiProcessElementsTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
index bdb1aacb3..c32a45182 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
@@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccNamedColor2TagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -148,16 +148,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccNamedColor2TagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
index e8bbc5e8f..46719b80f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
@@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccParametricCurveTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -61,16 +61,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccParametricCurveTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
index cde7c4043..c42004634 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
@@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccProfileSequenceDescTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -64,16 +64,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccProfileSequenceDescTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
index 2309a460e..f6b0582fb 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
@@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccProfileSequenceIdentifierTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -63,16 +63,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccProfileSequenceIdentifierTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
index 5925454a3..e2cd5860b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
@@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccResponseCurveSet16TagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -77,17 +77,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccResponseCurveSet16TagDataEntry && this.Equals((IccResponseCurveSet16TagDataEntry)obj);
+ return obj is IccResponseCurveSet16TagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
index 1e17d0862..c93781d9e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
@@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccScreeningTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -74,16 +74,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccScreeningTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
index a808541cf..e469e7eab 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
@@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccSignatureTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccSignatureTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
index c509197e4..cc67dd1b1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
@@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccTextDescriptionTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -160,17 +160,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccTextDescriptionTagDataEntry && this.Equals((IccTextDescriptionTagDataEntry)obj);
+ return obj is IccTextDescriptionTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
index f5e31ea87..1cf321893 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
@@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccTextTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -61,16 +61,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccTextTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
index c619b40d4..63a19d6d4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
@@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccUFix16ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccUFix16ArrayTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
index 4f1959cf1..d082df39a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
@@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccUInt16ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccUInt16ArrayTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 00ca43084..2e3efe1c7 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
@@ -62,17 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccUInt32ArrayTagDataEntry && this.Equals((IccUInt32ArrayTagDataEntry)obj);
+ return obj is IccUInt32ArrayTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
index 27c273e42..85ae2f9fa 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
@@ -62,17 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccUInt64ArrayTagDataEntry && this.Equals((IccUInt64ArrayTagDataEntry)obj);
+ return obj is IccUInt64ArrayTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
index bf6fdd662..a673abf68 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccUInt8ArrayTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
index 0f190021f..fd38e659b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
@@ -85,16 +85,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccUcrBgTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
index ce3be9b69..0f0a9d218 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
@@ -62,16 +62,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccUnknownTagDataEntry other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index a4db8f7ab..6be21dcc9 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
@@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccViewingConditionsTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other is null)
{
return false;
}
@@ -80,17 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccViewingConditionsTagDataEntry && this.Equals((IccViewingConditionsTagDataEntry)obj);
+ return obj is IccViewingConditionsTagDataEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs
index d704fee96..b776cc4c0 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs
@@ -55,4 +55,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Equals((IccTagDataEntry)other);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
index c42d85134..e88115438 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
@@ -136,16 +136,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccClut other && this.Equals(other);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
index c038cfaba..79c647bf1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
@@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- return obj is IccScreeningChannel && this.Equals((IccScreeningChannel)obj);
+ return obj is IccScreeningChannel other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccVersion.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccVersion.cs
new file mode 100644
index 000000000..2486cc80a
--- /dev/null
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccVersion.cs
@@ -0,0 +1,53 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+
+namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
+{
+ ///
+ /// Represents the ICC profile version number.
+ ///
+ public readonly struct IccVersion : IEquatable
+ {
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The major version number.
+ /// The minor version number.
+ /// The patch version number.
+ public IccVersion(int major, int minor, int patch)
+ {
+ this.Major = major;
+ this.Minor = minor;
+ this.Patch = patch;
+ }
+
+ ///
+ /// Gets the major version number.
+ ///
+ public int Major { get; }
+
+ ///
+ /// Gets the minor version number.
+ ///
+ public int Minor { get; }
+
+ ///
+ /// Gets the patch number.
+ ///
+ public int Patch { get; }
+
+ ///
+ public bool Equals(IccVersion other) =>
+ this.Major == other.Major &&
+ this.Minor == other.Minor &&
+ this.Patch == other.Patch;
+
+ ///
+ public override string ToString()
+ {
+ return string.Join(".", this.Major, this.Minor, this.Patch);
+ }
+ }
+}
diff --git a/src/ImageSharp/PixelFormats/Bgr565.cs b/src/ImageSharp/PixelFormats/Bgr565.cs
index 8595c6b9b..f9a0ce9dc 100644
--- a/src/ImageSharp/PixelFormats/Bgr565.cs
+++ b/src/ImageSharp/PixelFormats/Bgr565.cs
@@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public override bool Equals(object obj)
{
- return (obj is Bgr565) && this.Equals((Bgr565)obj);
+ return obj is Bgr565 other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/PixelFormats/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs
index 504992542..54c615f9b 100644
--- a/src/ImageSharp/PixelFormats/HalfSingle.cs
+++ b/src/ImageSharp/PixelFormats/HalfSingle.cs
@@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public override bool Equals(object obj)
{
- return (obj is HalfSingle) && this.Equals((HalfSingle)obj);
+ return obj is HalfSingle other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/PixelFormats/HalfVector2.cs b/src/ImageSharp/PixelFormats/HalfVector2.cs
index 72eb4f79c..4a135a77c 100644
--- a/src/ImageSharp/PixelFormats/HalfVector2.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector2.cs
@@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public override bool Equals(object obj)
{
- return (obj is HalfVector2) && this.Equals((HalfVector2)obj);
+ return obj is HalfVector2 other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/PixelFormats/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
index 2ddc83e76..1ced412d0 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
@@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public override bool Equals(object obj)
{
- return (obj is NormalizedShort2) && this.Equals((NormalizedShort2)obj);
+ return obj is NormalizedShort2 other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/PixelFormats/Rg32.cs b/src/ImageSharp/PixelFormats/Rg32.cs
index 39a0ff424..e5ceeacec 100644
--- a/src/ImageSharp/PixelFormats/Rg32.cs
+++ b/src/ImageSharp/PixelFormats/Rg32.cs
@@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public override bool Equals(object obj)
{
- return (obj is Rg32) && this.Equals((Rg32)obj);
+ return obj is Rg32 other && this.Equals(other);
}
///
diff --git a/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs
index 6530850ec..a0a68a705 100644
--- a/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs
+++ b/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs
@@ -46,8 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj)) return false;
- return obj is CustomStruct && this.Equals((CustomStruct)obj);
+ return obj is CustomStruct other && this.Equals(other);
}
public override int GetHashCode()
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs
index 880fa0607..86f308ea1 100644
--- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs
@@ -23,11 +23,11 @@ namespace SixLabors.ImageSharp.Tests.Icc
[Theory]
[MemberData(nameof(IccTestDataNonPrimitives.VersionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
- public void ReadVersionNumber(byte[] data, Version expected)
+ public void ReadVersionNumber(byte[] data, IccVersion expected)
{
IccDataReader reader = CreateReader(data);
- Version output = reader.ReadVersionNumber();
+ IccVersion output = reader.ReadVersionNumber();
Assert.Equal(expected, output);
}
diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs
index eda6a33c7..1d482e2c1 100644
--- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs
+++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs
@@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
[Theory]
[MemberData(nameof(IccTestDataNonPrimitives.VersionNumberTestData), MemberType = typeof(IccTestDataNonPrimitives))]
- public void WriteVersionNumber(byte[] expected, Version data)
+ public void WriteVersionNumber(byte[] expected, IccVersion data)
{
IccDataWriter writer = CreateWriter();
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
index 3b8c3321a..f16da90c6 100644
--- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
@@ -67,10 +67,10 @@ namespace SixLabors.ImageSharp.Tests
#region VersionNumber
- public static readonly Version VersionNumber_ValMin = new Version(0, 0, 0);
- public static readonly Version VersionNumber_Val211 = new Version(2, 1, 1);
- public static readonly Version VersionNumber_Val430 = new Version(4, 3, 0);
- public static readonly Version VersionNumber_ValMax = new Version(255, 15, 15);
+ public static readonly IccVersion VersionNumber_ValMin = new IccVersion(0, 0, 0);
+ public static readonly IccVersion VersionNumber_Val211 = new IccVersion(2, 1, 1);
+ public static readonly IccVersion VersionNumber_Val430 = new IccVersion(4, 3, 0);
+ public static readonly IccVersion VersionNumber_ValMax = new IccVersion(255, 15, 15);
public static readonly byte[] VersionNumber_Min = { 0x00, 0x00, 0x00, 0x00 };
public static readonly byte[] VersionNumber_211 = { 0x02, 0x11, 0x00, 0x00 };
diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs
index 586bb818d..cf8cffb32 100644
--- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs
+++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs
@@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests
ProfileConnectionSpace = IccColorSpaceType.CieXyz,
RenderingIntent = IccRenderingIntent.AbsoluteColorimetric,
Size = size,
- Version = new Version(4, 3, 0),
+ Version = new IccVersion(4, 3, 0),
};
}