Skip to content

Commit 9241e14

Browse files
committed
Add empty constructors to Npgsql{Path,Polygon} (#5114)
(cherry picked from commit 1b8bb7e)
1 parent 5531fb3 commit 9241e14

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Npgsql/NpgsqlTypes/NpgsqlTypes.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ public struct NpgsqlPath : IList<NpgsqlPoint>, IEquatable<NpgsqlPath>
233233
readonly List<NpgsqlPoint> _points;
234234
public bool Open { get; set; }
235235

236-
public NpgsqlPath(IEnumerable<NpgsqlPoint> points, bool open) : this()
236+
public NpgsqlPath()
237+
=> _points = new();
238+
239+
public NpgsqlPath(IEnumerable<NpgsqlPoint> points, bool open)
237240
{
238241
_points = new List<NpgsqlPoint>(points);
239242
Open = open;
@@ -354,12 +357,15 @@ public struct NpgsqlPolygon : IList<NpgsqlPoint>, IEquatable<NpgsqlPolygon>
354357
{
355358
readonly List<NpgsqlPoint> _points;
356359

360+
public NpgsqlPolygon()
361+
=> _points = new();
362+
357363
public NpgsqlPolygon(IEnumerable<NpgsqlPoint> points)
358364
{
359365
_points = new List<NpgsqlPoint>(points);
360366
}
361367

362-
public NpgsqlPolygon(params NpgsqlPoint[] points) : this ((IEnumerable<NpgsqlPoint>) points) {}
368+
public NpgsqlPolygon(params NpgsqlPoint[] points) : this((IEnumerable<NpgsqlPoint>) points) {}
363369

364370
public NpgsqlPolygon(int capacity)
365371
{

test/Npgsql.Tests/Types/GeometricTypeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ void AssertPointsEqual(NpgsqlPoint actual, NpgsqlPoint expected)
163163
}
164164

165165
public GeometricTypeTests(MultiplexingMode multiplexingMode) : base(multiplexingMode) {}
166-
}
166+
}

test/Npgsql.Tests/TypesTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,14 @@ public void TsQueryOperatorPrecedence()
581581
Assert.AreEqual(expectedGrouping.ToString(), query.ToString());
582582
}
583583

584+
[Test]
585+
public void NpgsqlPath_empty()
586+
=> Assert.That(new NpgsqlPath { new(1, 2) }, Is.EqualTo(new NpgsqlPath(new NpgsqlPoint(1, 2))));
587+
588+
[Test]
589+
public void NpgsqlPolygon_empty()
590+
=> Assert.That(new NpgsqlPolygon { new(1, 2) }, Is.EqualTo(new NpgsqlPolygon(new NpgsqlPoint(1, 2))));
591+
584592
[Test]
585593
public void Bug1011018()
586594
{

0 commit comments

Comments
 (0)