Skip to content

Commit

Permalink
Npgsql: Mitigate warnings (chore)
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Dec 21, 2024
1 parent ba814ca commit 762b488
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions by-language/csharp-npgsql/BasicPoco.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ public class BasicPoco
public string? name { get; set; }
public int? age { get; set; }

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var other = (BasicPoco) obj;
return name == other.name && age == other.age;
var other = (BasicPoco?) obj;
return name == other?.name && age == other?.age;
}

public override int GetHashCode()
Expand Down
4 changes: 2 additions & 2 deletions by-language/csharp-npgsql/DemoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ INSERT INTO testdrive.example (

}

public async Task<Point> GeoJsonTypesExample()
public async Task<Point?> GeoJsonTypesExample()
{
Console.WriteLine("Running GeoJsonTypesExample");

Expand All @@ -444,7 +444,7 @@ public async Task<Point> GeoJsonTypesExample()
// Currently, `InsertGeoJsonTyped` does not work yet.
var obj = reader.GetFieldValue<JsonDocument>("geoshape");
var geoJsonObject = JsonConvert.DeserializeObject<Point>(obj.RootElement.ToString());
return (Point) geoJsonObject;
return (Point?) geoJsonObject;
}
}

Expand Down
4 changes: 2 additions & 2 deletions by-language/csharp-npgsql/tests/DemoProgramTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public async Task TestGeoJsonTypesExample()

// Validate the outcome.
var coords = new Point(new Position(85.43, 66.23)).Coordinates;
Assert.Equal(coords.Latitude, point.Coordinates.Latitude);
Assert.Equal(coords.Longitude, point.Coordinates.Longitude);
Assert.Equal(coords.Latitude, point?.Coordinates.Latitude);
Assert.Equal(coords.Longitude, point?.Coordinates.Longitude);

}

Expand Down

0 comments on commit 762b488

Please sign in to comment.