Use C# 9 target-typed new expressions (#3376) · npgsql/npgsql@d42cc68 · GitHub
Skip to content

Commit d42cc68

Browse files
authored
Use C# 9 target-typed new expressions (#3376)
1 parent 36ae5ca commit d42cc68

82 files changed

Lines changed: 797 additions & 783 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/Npgsql.GeoJSON/CrsMap.WellKnown.cs‎

Lines changed: 576 additions & 576 deletions
Large diffs are not rendered by default.

‎src/Npgsql.GeoJSON/GeoJSONHandler.cs‎

Lines changed: 1 addition & 1 deletion

‎src/Npgsql.NetTopologySuite/NetTopologySuiteHandler.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NetTopologySuiteHandler : NpgsqlTypeHandler<Geometry>,
2323
{
2424
readonly PostGisReader _reader;
2525
readonly PostGisWriter _writer;
26-
readonly LengthStream _lengthStream = new LengthStream();
26+
readonly LengthStream _lengthStream = new();
2727

2828
internal NetTopologySuiteHandler(PostgresType postgresType, PostGisReader reader, PostGisWriter writer)
2929
: base(postgresType)
@@ -60,7 +60,7 @@ ValueTask<GeometryCollection> INpgsqlTypeHandler<GeometryCollection>.Read(Npgsql
6060

6161
ValueTask<T> ReadCore<T>(NpgsqlReadBuffer buf, int len)
6262
where T : Geometry
63-
=> new ValueTask<T>((T)_reader.Read(buf.GetStream(len, false)));
63+
=> new((T)_reader.Read(buf.GetStream(len, false)));
6464

6565
#endregion
6666

‎src/Npgsql.NodaTime/TimeTzHandler.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal TimeTzHandler(PostgresType postgresType) : base(postgresType)
2828

2929
// Adjust from 1 microsecond to 100ns. Time zone (in seconds) is inverted.
3030
public override OffsetTime Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription = null)
31-
=> new OffsetTime(
31+
=> new(
3232
LocalTime.FromTicksSinceMidnight(buf.ReadInt64() * 10),
3333
Offset.FromSeconds(-buf.ReadInt32()));
3434

‎src/Npgsql/BackendMessages/AuthenticationMessages.cs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ class AuthenticationOkMessage : AuthenticationRequestMessage
1414
{
1515
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationOk;
1616

17-
internal static readonly AuthenticationOkMessage Instance = new AuthenticationOkMessage();
17+
internal static readonly AuthenticationOkMessage Instance = new();
1818
AuthenticationOkMessage() { }
1919
}
2020

2121
class AuthenticationKerberosV5Message : AuthenticationRequestMessage
2222
{
2323
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationKerberosV5;
2424

25-
internal static readonly AuthenticationKerberosV5Message Instance = new AuthenticationKerberosV5Message();
25+
internal static readonly AuthenticationKerberosV5Message Instance = new();
2626
AuthenticationKerberosV5Message() { }
2727
}
2828

2929
class AuthenticationCleartextPasswordMessage : AuthenticationRequestMessage
3030
{
3131
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationCleartextPassword;
3232

33-
internal static readonly AuthenticationCleartextPasswordMessage Instance = new AuthenticationCleartextPasswordMessage();
33+
internal static readonly AuthenticationCleartextPasswordMessage Instance = new();
3434
AuthenticationCleartextPasswordMessage() { }
3535
}
3636

@@ -57,15 +57,15 @@ class AuthenticationSCMCredentialMessage : AuthenticationRequestMessage
5757
{
5858
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationSCMCredential;
5959

60-
internal static readonly AuthenticationSCMCredentialMessage Instance = new AuthenticationSCMCredentialMessage();
60+
internal static readonly AuthenticationSCMCredentialMessage Instance = new();
6161
AuthenticationSCMCredentialMessage() { }
6262
}
6363

6464
class AuthenticationGSSMessage : AuthenticationRequestMessage
6565
{
6666
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationGSS;
6767

68-
internal static readonly AuthenticationGSSMessage Instance = new AuthenticationGSSMessage();
68+
internal static readonly AuthenticationGSSMessage Instance = new();
6969
AuthenticationGSSMessage() { }
7070
}
7171

@@ -93,7 +93,7 @@ class AuthenticationSSPIMessage : AuthenticationRequestMessage
9393
{
9494
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationSSPI;
9595

96-
internal static readonly AuthenticationSSPIMessage Instance = new AuthenticationSSPIMessage();
96+
internal static readonly AuthenticationSSPIMessage Instance = new();
9797
AuthenticationSSPIMessage() { }
9898
}
9999

@@ -102,7 +102,7 @@ class AuthenticationSSPIMessage : AuthenticationRequestMessage
102102
class AuthenticationSASLMessage : AuthenticationRequestMessage
103103
{
104104
internal override AuthenticationRequestType AuthRequestType => AuthenticationRequestType.AuthenticationSASL;
105-
internal List<string> Mechanisms { get; } = new List<string>();
105+
internal List<string> Mechanisms { get; } = new();
106106

107107
internal AuthenticationSASLMessage(NpgsqlReadBuffer buf)
108108
{

‎src/Npgsql/BackendMessages/BindCompleteMessage.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class BindCompleteMessage : IBackendMessage
44
{
55
public BackendMessageCode Code => BackendMessageCode.BindComplete;
6-
internal static readonly BindCompleteMessage Instance = new BindCompleteMessage();
6+
internal static readonly BindCompleteMessage Instance = new();
77
BindCompleteMessage() { }
88
}
99
}

‎src/Npgsql/BackendMessages/CloseCompletedMessage.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class CloseCompletedMessage : IBackendMessage
44
{
55
public BackendMessageCode Code => BackendMessageCode.CloseComplete;
6-
internal static readonly CloseCompletedMessage Instance = new CloseCompletedMessage();
6+
internal static readonly CloseCompletedMessage Instance = new();
77
CloseCompletedMessage() { }
88
}
99
}

‎src/Npgsql/BackendMessages/CopyMessages.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal CopyDataMessage Load(int len)
8888
class CopyDoneMessage : IBackendMessage
8989
{
9090
public BackendMessageCode Code => BackendMessageCode.CopyDone;
91-
internal static readonly CopyDoneMessage Instance = new CopyDoneMessage();
91+
internal static readonly CopyDoneMessage Instance = new();
9292
CopyDoneMessage() { }
9393
}
9494
}

‎src/Npgsql/BackendMessages/EmptyQueryMessage.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class EmptyQueryMessage : IBackendMessage
44
{
55
public BackendMessageCode Code => BackendMessageCode.EmptyQueryResponse;
6-
internal static readonly EmptyQueryMessage Instance = new EmptyQueryMessage();
6+
internal static readonly EmptyQueryMessage Instance = new();
77
EmptyQueryMessage() { }
88
}
99
}

‎src/Npgsql/BackendMessages/NoDataMessage.cs‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)