Skip to content

Commit 0dfb25c

Browse files
author
Martin Boje Carpentier
committed
Updated code in regards to recommendations
1 parent c94a77c commit 0dfb25c

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

src/GeoJSON.Text.Test.Benchmark/SerializeAndDeserialize.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public class SerializeAndDeserialize
1111
string fileContents = "";
1212

1313
// GeoJson.NET
14-
private Net.Feature.FeatureCollection featureCollectionGeoJsonNET = new Net.Feature.FeatureCollection();
14+
private readonly Net.Feature.FeatureCollection featureCollectionGeoJsonNET = new Net.Feature.FeatureCollection();
1515

1616
// GeoJson.Text
17-
private Text.Feature.FeatureCollection featureCollectionGeoJsonTEXT = new Text.Feature.FeatureCollection();
17+
private readonly Text.Feature.FeatureCollection featureCollectionGeoJsonTEXT = new Text.Feature.FeatureCollection();
1818

1919
[Params(1000, 10000)]
2020
public int N;

src/GeoJSON.Text/Converters/PositionEnumerableConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace GeoJSON.Text.Converters
1414
/// </summary>
1515
public class PositionEnumerableConverter : JsonConverter<IReadOnlyCollection<IPosition>>
1616
{
17-
private static readonly PositionConverter PositionConverter = new PositionConverter();
17+
private static readonly PositionConverter PositionConverter = new();
1818

1919
/// <summary>
2020
/// Determines whether this instance can convert the specified object type.

src/GeoJSON.Text/Feature/Feature.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private static Dictionary<string, object> GetDictionaryOfPublicProperties(object
271271

272272
public bool Equals(Feature<TGeometry> other)
273273
{
274-
if (ReferenceEquals(null, other)) return false;
274+
if (other is null) return false;
275275
if (ReferenceEquals(this, other)) return true;
276276

277277
if (Geometry == null && other.Geometry == null)
@@ -294,7 +294,7 @@ public bool Equals(Feature<TGeometry> other)
294294

295295
public override bool Equals(object obj)
296296
{
297-
if (ReferenceEquals(null, obj)) return false;
297+
if (obj is null) return false;
298298
if (ReferenceEquals(this, obj)) return true;
299299
return obj.GetType() == GetType() && Equals((Feature<TGeometry>) obj);
300300
}
@@ -311,7 +311,7 @@ public override int GetHashCode()
311311

312312
public static bool operator !=(Feature<TGeometry> left, Feature<TGeometry> right)
313313
{
314-
return !(left?.Equals(right) ?? ReferenceEquals(null, right));
314+
return !(left?.Equals(right) ?? right is null);
315315
}
316316
}
317317
}

src/GeoJSON.Text/GeoJSONObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace GeoJSON.Text
1515
/// </summary>
1616
public abstract class GeoJSONObject : IGeoJSONObject, IEqualityComparer<GeoJSONObject>, IEquatable<GeoJSONObject>
1717
{
18-
internal static readonly DoubleTenDecimalPlaceComparer DoubleComparer = new DoubleTenDecimalPlaceComparer();
18+
internal static readonly DoubleTenDecimalPlaceComparer DoubleComparer = new();
1919

2020
/// <summary>
2121
/// Gets or sets the (optional)

src/GeoJSON.Text/Geometry/GeometryCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GeometryCollection : GeoJSONObject, IGeometryObject, IEqualityCompa
2020
/// <summary>
2121
/// Initializes a new instance of the <see cref="GeometryCollection" /> class.
2222
/// </summary>
23-
public GeometryCollection() : this(new Array.Empty[0])
23+
public GeometryCollection() : this(Array.Empty<IGeometryObject>())
2424
{
2525
}
2626

@@ -85,7 +85,7 @@ public bool Equals(GeometryCollection left, GeometryCollection right)
8585
{
8686
return true;
8787
}
88-
if (ReferenceEquals(null, right))
88+
if (right is null)
8989
{
9090
return false;
9191
}

src/GeoJSON.Text/Geometry/LineString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public LineString()
2929
//[JsonConstructor]
3030
public LineString(IEnumerable<IEnumerable<double>> coordinates)
3131
: this(coordinates?.Select(latLongAlt => (IPosition)latLongAlt.ToPosition())
32-
?? throw new ArgumentException(nameof(coordinates)))
32+
?? throw new ArgumentNullException(nameof(coordinates)))
3333
{
3434
}
3535

@@ -131,7 +131,7 @@ public bool Equals(LineString left, LineString right)
131131
{
132132
return true;
133133
}
134-
if (ReferenceEquals(null, right))
134+
if (right is null)
135135
{
136136
return false;
137137
}

src/GeoJSON.Text/Geometry/MultiLineString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public bool Equals(MultiLineString left, MultiLineString right)
9595
{
9696
return true;
9797
}
98-
if (ReferenceEquals(null, right))
98+
if (right is null)
9999
{
100100
return false;
101101
}

src/GeoJSON.Text/Geometry/MultiPoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public bool Equals(MultiPoint left, MultiPoint right)
8989
{
9090
return true;
9191
}
92-
if (ReferenceEquals(null, right))
92+
if (right is null)
9393
{
9494
return false;
9595
}

src/GeoJSON.Text/Geometry/Position.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace GeoJSON.Text.Geometry
1212
/// </summary>
1313
public class Position : IPosition, IEqualityComparer<Position>, IEquatable<Position>
1414
{
15-
private static readonly DoubleTenDecimalPlaceComparer DoubleComparer = new DoubleTenDecimalPlaceComparer();
15+
private static readonly DoubleTenDecimalPlaceComparer DoubleComparer = new();
1616

1717
/// <summary>
1818
/// Initializes a new instance of the <see cref="Position" /> class.

0 commit comments

Comments
 (0)