diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs index 6f825e61e..02a817b8c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs @@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc unchecked { int hashCode = (int)this.CurveType; - hashCode = (hashCode * 397) ^ (this.XyzValues != null ? this.XyzValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.ResponseArrays != null ? this.ResponseArrays.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.XyzValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.ResponseArrays?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs index 945ba40c4..b400e1bd7 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (int)this.ColorantType; - hashCode = (hashCode * 397) ^ (this.ChannelValues != null ? this.ChannelValues.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.ChannelValues?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs index 1c44335a1..73024ee12 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccColorantOrderTagDataEntry && this.Equals((IccColorantOrderTagDataEntry)obj); + return obj is IccColorantOrderTagDataEntry other && this.Equals(other); } /// @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.ColorantNumber != null ? this.ColorantNumber.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.ColorantNumber?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs index 7b1ba138a..353dab604 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccColorantTableTagDataEntry && this.Equals((IccColorantTableTagDataEntry)obj); + return obj is IccColorantTableTagDataEntry other && this.Equals(other); } /// @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.ColorantData != null ? this.ColorantData.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.ColorantData?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs index aa9d23dae..848418f95 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccCrdInfoTagDataEntry && this.Equals((IccCrdInfoTagDataEntry)obj); + return obj is IccCrdInfoTagDataEntry other && this.Equals(other); } /// @@ -134,11 +134,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc unchecked { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.PostScriptProductName != null ? this.PostScriptProductName.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd != null ? this.RenderingIntent0Crd.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd != null ? this.RenderingIntent1Crd.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd != null ? this.RenderingIntent2Crd.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd != null ? this.RenderingIntent3Crd.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.PostScriptProductName?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs index c7e768baf..c9a59bb32 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs @@ -79,12 +79,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public float Gamma => this.IsGamma ? this.CurveData[0] : 0; /// - /// Gets a value indicating whether the curve maps input directly to output + /// Gets a value indicating whether the curve maps input directly to output. /// public bool IsIdentityResponse => this.CurveData.Length == 0; /// - /// Gets a value indicating whether the curve is a gamma curve + /// Gets a value indicating whether the curve is a gamma curve. /// public bool IsGamma => this.CurveData.Length == 1; @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccCurveTagDataEntry && this.Equals((IccCurveTagDataEntry)obj); + return obj is IccCurveTagDataEntry other && this.Equals(other); } /// @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.CurveData != null ? this.CurveData.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.CurveData?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs index bb2848ba5..c8f5f8b7c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs @@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) + if (obj == null) { return false; } @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccDataTagDataEntry && this.Equals((IccDataTagDataEntry)obj); + return obj is IccDataTagDataEntry other && this.Equals(other); } /// @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc unchecked { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode(); return hashCode; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs index 92902ee3b..afe4e0bd3 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccFix16ArrayTagDataEntry && this.Equals((IccFix16ArrayTagDataEntry)obj); + return obj is IccFix16ArrayTagDataEntry other && this.Equals(other); } /// @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index 9a9266c69..d98e45ace 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -157,9 +157,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs index 9611e3a3a..e57e0f543 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs @@ -160,9 +160,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs index 046995c34..59c80d409 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs @@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccLutAToBTagDataEntry && this.Equals((IccLutAToBTagDataEntry)obj); + return obj is IccLutAToBTagDataEntry other && this.Equals(other); } /// @@ -200,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs index 43002f057..57b17c452 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs @@ -200,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc hashCode = (hashCode * 397) ^ this.OutputChannelCount; hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode(); hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs index da7701936..d1745faac 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Texts != null ? this.Texts.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Texts?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs index 437c6734b..8b0c06568 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMultiProcessElementsTagDataEntry other) { - if (ReferenceEquals(null, other)) + if (other == null) { return false; } @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccMultiProcessElementsTagDataEntry && this.Equals((IccMultiProcessElementsTagDataEntry)obj); + return obj is IccMultiProcessElementsTagDataEntry other && this.Equals(other); } /// @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ this.InputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount; - hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs index d3e73b018..07021bfca 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs @@ -169,10 +169,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ this.CoordinateCount; - hashCode = (hashCode * 397) ^ (this.Prefix != null ? this.Prefix.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.Suffix != null ? this.Suffix.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Prefix?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.Suffix?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ this.VendorFlags; - hashCode = (hashCode * 397) ^ (this.Colors != null ? this.Colors.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Colors?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs index 192be52a1..e22223ebf 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccParametricCurveTagDataEntry && this.Equals((IccParametricCurveTagDataEntry)obj); + return obj is IccParametricCurveTagDataEntry other && this.Equals(other); } /// @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Curve != null ? this.Curve.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Curve?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs index 7e16e9271..cde7c4043 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs @@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Descriptions != null ? this.Descriptions.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Descriptions?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs index 555fcb202..2309a460e 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs index 7faad30f3..5925454a3 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs @@ -53,8 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(IccTagDataEntry other) { - var entry = other as IccResponseCurveSet16TagDataEntry; - return entry != null && this.Equals(entry); + return other is IccResponseCurveSet16TagDataEntry entry && this.Equals(entry); } /// @@ -98,7 +97,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.Curves != null ? this.Curves.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Curves?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs index 7a5062707..89b5638aa 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs @@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccScreeningTagDataEntry && this.Equals((IccScreeningTagDataEntry)obj); + return obj is IccScreeningTagDataEntry other && this.Equals(other); } /// @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (int)this.Flags; - hashCode = (hashCode * 397) ^ (this.Channels != null ? this.Channels.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Channels?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs index 82462afa3..b2191f587 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccSignatureTagDataEntry && this.Equals((IccSignatureTagDataEntry)obj); + return obj is IccSignatureTagDataEntry other && this.Equals(other); } /// @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.SignatureData != null ? this.SignatureData.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.SignatureData?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs index 6d9c42511..c509197e4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs @@ -179,9 +179,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc unchecked { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.Ascii != null ? this.Ascii.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.Unicode != null ? this.Unicode.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.ScriptCode != null ? this.ScriptCode.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.Ascii?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.Unicode?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.ScriptCode?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode; hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode(); return hashCode; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs index 8127fae29..f5e31ea87 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs @@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(IccTagDataEntry other) { - var entry = other as IccTextTagDataEntry; - return entry != null && this.Equals(entry); + return other is IccTextTagDataEntry entry && this.Equals(entry); } /// @@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccTextTagDataEntry && this.Equals((IccTextTagDataEntry)obj); + return obj is IccTextTagDataEntry other && this.Equals(other); } /// @@ -80,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Text != null ? this.Text.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Text?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs index 709106a52..c619b40d4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs @@ -33,15 +33,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc } /// - /// Gets the array data + /// Gets the array data. /// public float[] Data { get; } /// public override bool Equals(IccTagDataEntry other) { - var entry = other as IccUFix16ArrayTagDataEntry; - return entry != null && this.Equals(entry); + return other is IccUFix16ArrayTagDataEntry entry && this.Equals(entry); } /// @@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) + if (obj == null) { return false; } @@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccUFix16ArrayTagDataEntry && this.Equals((IccUFix16ArrayTagDataEntry)obj); + return obj is IccUFix16ArrayTagDataEntry other && this.Equals(other); } /// @@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs index bcd991cea..d3f0eb524 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccUInt16ArrayTagDataEntry && this.Equals((IccUInt16ArrayTagDataEntry)obj); + return obj is IccUInt16ArrayTagDataEntry other && this.Equals(other); } /// @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs index 15eaf6090..00ca43084 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs index e3eaa3317..27c273e42 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs index cf445d13e..bf6fdd662 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs index 0f8bd6c33..25752b171 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUcrBgTagDataEntry other) { - if (ReferenceEquals(null, other)) + if (other == null) { return false; } @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) + if (obj == null) { return false; } @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return true; } - return obj is IccUcrBgTagDataEntry && this.Equals((IccUcrBgTagDataEntry)obj); + return obj is IccUcrBgTagDataEntry other && this.Equals(other); } /// @@ -105,9 +105,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc unchecked { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.UcrCurve != null ? this.UcrCurve.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.BgCurve != null ? this.BgCurve.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.UcrCurve?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.BgCurve?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.Description?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs index 382a3dcf3..ce3be9b69 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc } /// - /// Gets the raw data of the entry + /// Gets the raw data of the entry. /// public byte[] Data { get; } @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0); + return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0); } } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs index 20a436885..c42d85134 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs @@ -94,9 +94,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public float[][] Values { get; } /// - /// Gets or sets the CLUT data type (important when writing a profile) + /// Gets the CLUT data type (important when writing a profile) /// - public IccClutDataType DataType { get; set; } + public IccClutDataType DataType { get; } /// /// Gets the number of input channels @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccClut other) { - if (ReferenceEquals(null, other)) + if (other == null) { return false; } @@ -154,11 +154,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - int hashCode = this.Values != null ? this.Values.GetHashCode() : 0; + int hashCode = this.Values?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (int)this.DataType; hashCode = (hashCode * 397) ^ this.InputChannelCount; hashCode = (hashCode * 397) ^ this.OutputChannelCount; - hashCode = (hashCode * 397) ^ (this.GridPointCount != null ? this.GridPointCount.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.GridPointCount?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs index 685319fe4..9db4bb9c4 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc internal readonly struct IccProfileDescription : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the struct. /// /// Device Manufacturer /// Device Model @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccProfileDescription other) => - this.DeviceManufacturer == other.DeviceManufacturer && + this.DeviceManufacturer == other.DeviceManufacturer && this.DeviceModel == other.DeviceModel && this.DeviceAttributes == other.DeviceAttributes && this.TechnologyInformation == other.TechnologyInformation && @@ -93,8 +93,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc hashCode = (hashCode * 397) ^ (int)this.DeviceModel; hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode(); hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation; - hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo != null ? this.DeviceManufacturerInfo.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.DeviceModelInfo != null ? this.DeviceModelInfo.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo?.GetHashCode() ?? 0); + hashCode = (hashCode * 397) ^ (this.DeviceModelInfo?.GetHashCode() ?? 0); return hashCode; } } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs index 63dd0cfc5..d5362ad70 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { unchecked { - return (this.Id.GetHashCode() * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0); + return (this.Id.GetHashCode() * 397) ^ (this.Description?.GetHashCode() ?? 0); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs index 8ce1f111d..d11b3d79b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs @@ -123,17 +123,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public override bool Equals(object obj) { - if (object.ReferenceEquals(null, obj)) return false; - if (object.ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return this.Equals((SpectralData)obj); + return obj is SpectralData other && this.Equals(other); } public override int GetHashCode() { unchecked { - return (this.ComponentCount * 397) ^ (this.Components != null ? this.Components[0].GetHashCode() : 0); + return (this.ComponentCount * 397) ^ (this.Components?[0].GetHashCode() ?? 0); } }