Skip to content

Commit

Permalink
Corrected nullability for world coordinates in .NET 6+.
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Jul 26, 2024
1 parent bc20a8c commit 13e0728
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Weatherstack/WorldCoordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,24 @@ public struct WorldCoordinate
[JsonPropertyName("lon")]
public double Longitude { get; set; }

#if NET6_0_OR_GREATER

/// <inheritdoc/>
[SuppressMessage(
category: "Style",
checkId: "IDE0046",
Justification = Justifications.GuardClausesShouldNotBeTerse)]
public override bool Equals(object? obj)
{
if (obj is not WorldCoordinate other)
return false;

return Equals(other);
}

#else

/// <inheritdoc/>
[SuppressMessage(
category: "Style",
checkId: "IDE0046",
Expand All @@ -36,6 +53,8 @@ public override bool Equals(object obj)
return Equals(other);
}

#endif

public bool Equals(WorldCoordinate other) => Latitude == other.Latitude
&& Longitude == other.Longitude;

Expand Down

0 comments on commit 13e0728

Please sign in to comment.