Browse Source

Use null operators

af/merge-core
Jason Nelson 8 years ago
parent
commit
a77bd21f61
  1. 4
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
  2. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  3. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
  4. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
  5. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  6. 8
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
  7. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  8. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
  9. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  10. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  11. 10
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  12. 8
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  13. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
  14. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
  15. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
  16. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
  17. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
  18. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
  19. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
  20. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
  21. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
  22. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  23. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
  24. 11
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
  25. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
  26. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
  27. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
  28. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
  29. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
  30. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
  31. 10
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
  32. 8
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
  33. 2
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
  34. 7
      tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs

4
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;
}
}

2
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;
}
}

4
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

4
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

12
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);
}
/// <inheritdoc/>
@ -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;
}
}

8
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;
/// <summary>
/// Gets a value indicating whether the curve maps input directly to output
/// Gets a value indicating whether the curve maps input directly to output.
/// </summary>
public bool IsIdentityResponse => this.CurveData.Length == 0;
/// <summary>
/// Gets a value indicating whether the curve is a gamma curve
/// Gets a value indicating whether the curve is a gamma curve.
/// </summary>
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

6
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs

@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -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;
}

4
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

6
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;
}
}

6
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;
}
}

10
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);
}
/// <inheritdoc/>
@ -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;
}
}

8
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;
}
}

2
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);
}
}
}

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

@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -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;
}
}

6
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;
}
}

4
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);
}
/// <inheritdoc />
@ -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);
}
}
}

2
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);
}
}
}

2
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);
}
}
}

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

@ -53,8 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc />
@ -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;
}
}

4
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);
}
/// <inheritdoc/>
@ -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;
}
}

4
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);
}
/// <inheritdoc />
@ -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);
}
}
}

6
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;

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

@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc />
@ -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);
}
/// <inheritdoc />
@ -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);
}
}
}

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

@ -33,15 +33,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
/// <summary>
/// Gets the array data
/// Gets the array data.
/// </summary>
public float[] Data { get; }
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

4
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);
}
/// <inheritdoc/>
@ -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);
}
}
}

2
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);
}
}
}

2
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);
}
}
}

2
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);
}
}
}

12
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs

@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public bool Equals(IccUcrBgTagDataEntry other)
{
if (ReferenceEquals(null, other))
if (other == null)
{
return false;
}
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -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;
}
}

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

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
/// <summary>
/// Gets the raw data of the entry
/// Gets the raw data of the entry.
/// </summary>
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);
}
}
}

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

@ -94,9 +94,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public float[][] Values { get; }
/// <summary>
/// Gets or sets the CLUT data type (important when writing a profile)
/// Gets the CLUT data type (important when writing a profile)
/// </summary>
public IccClutDataType DataType { get; set; }
public IccClutDataType DataType { get; }
/// <summary>
/// Gets the number of input channels
@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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;
}
}

8
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
internal readonly struct IccProfileDescription : IEquatable<IccProfileDescription>
{
/// <summary>
/// Initializes a new instance of the <see cref="IccProfileDescription"/> class.
/// Initializes a new instance of the <see cref="IccProfileDescription"/> struct.
/// </summary>
/// <param name="deviceManufacturer">Device Manufacturer</param>
/// <param name="deviceModel">Device Model</param>
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
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;
}
}

2
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);
}
}
}

7
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);
}
}

Loading…
Cancel
Save