From 762b488a49828239a6cf9164e73f2f09782ae921 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sat, 21 Dec 2024 13:44:41 +0100 Subject: [PATCH] Npgsql: Mitigate warnings (chore) --- by-language/csharp-npgsql/BasicPoco.cs | 6 +++--- by-language/csharp-npgsql/DemoTypes.cs | 4 ++-- by-language/csharp-npgsql/tests/DemoProgramTest.cs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/by-language/csharp-npgsql/BasicPoco.cs b/by-language/csharp-npgsql/BasicPoco.cs index bde7ff96..c4cfc670 100644 --- a/by-language/csharp-npgsql/BasicPoco.cs +++ b/by-language/csharp-npgsql/BasicPoco.cs @@ -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() diff --git a/by-language/csharp-npgsql/DemoTypes.cs b/by-language/csharp-npgsql/DemoTypes.cs index 132da821..a23b2a8d 100644 --- a/by-language/csharp-npgsql/DemoTypes.cs +++ b/by-language/csharp-npgsql/DemoTypes.cs @@ -426,7 +426,7 @@ INSERT INTO testdrive.example ( } - public async Task GeoJsonTypesExample() + public async Task GeoJsonTypesExample() { Console.WriteLine("Running GeoJsonTypesExample"); @@ -444,7 +444,7 @@ public async Task GeoJsonTypesExample() // Currently, `InsertGeoJsonTyped` does not work yet. var obj = reader.GetFieldValue("geoshape"); var geoJsonObject = JsonConvert.DeserializeObject(obj.RootElement.ToString()); - return (Point) geoJsonObject; + return (Point?) geoJsonObject; } } diff --git a/by-language/csharp-npgsql/tests/DemoProgramTest.cs b/by-language/csharp-npgsql/tests/DemoProgramTest.cs index 023db607..98f3a5c9 100644 --- a/by-language/csharp-npgsql/tests/DemoProgramTest.cs +++ b/by-language/csharp-npgsql/tests/DemoProgramTest.cs @@ -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); }