Skip to content

Commit e893b22

Browse files
committed
C# 7 expression-bodied properties
1 parent c800503 commit e893b22

21 files changed

Lines changed: 138 additions & 186 deletions

src/Npgsql/BackendMessages/RowDescriptionMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ internal void Populate(
205205
/// </summary>
206206
internal FormatCode FormatCode
207207
{
208-
get { return _formatCode; }
208+
get => _formatCode;
209209
set
210210
{
211211
_formatCode = value;

src/Npgsql/FrontendMessages/StartupMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class StartupMessage : SimpleFrontendMessage
3737

3838
internal string this[string key]
3939
{
40-
set { _parameters[key] = value; }
40+
set => _parameters[key] = value;
4141
}
4242

4343
internal override int Length

src/Npgsql/NpgsqlCommand.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public NpgsqlCommand(string cmdText, [CanBeNull] NpgsqlConnection connection, [C
147147
[Category("Data")]
148148
public override string CommandText
149149
{
150-
get { return _commandText; }
150+
get => _commandText;
151151
set
152152
{
153153
if (value == null)
@@ -166,10 +166,7 @@ public override string CommandText
166166
[DefaultValue(DefaultTimeout)]
167167
public override int CommandTimeout
168168
{
169-
get
170-
{
171-
return _timeout ?? (_connection?.CommandTimeout ?? DefaultTimeout);
172-
}
169+
get => _timeout ?? (_connection?.CommandTimeout ?? DefaultTimeout);
173170
set
174171
{
175172
if (value < 0) {
@@ -194,8 +191,8 @@ public override int CommandTimeout
194191
/// </summary>
195192
protected override DbConnection DbConnection
196193
{
197-
get { return Connection; }
198-
set { Connection = (NpgsqlConnection)value; }
194+
get => Connection;
195+
set => Connection = (NpgsqlConnection)value;
199196
}
200197

201198
/// <summary>
@@ -208,7 +205,7 @@ protected override DbConnection DbConnection
208205
[CanBeNull]
209206
public new NpgsqlConnection Connection
210207
{
211-
get { return _connection; }
208+
get => _connection;
212209
set
213210
{
214211
if (_connection == value)
@@ -280,7 +277,7 @@ public override UpdateRowSource UpdatedRowSource
280277
/// </summary>
281278
public bool AllResultTypesAreUnknown
282279
{
283-
get { return _allResultTypesAreUnknown; }
280+
get => _allResultTypesAreUnknown;
284281
set
285282
{
286283
// TODO: Check that this isn't modified after calling prepare
@@ -305,7 +302,7 @@ public bool AllResultTypesAreUnknown
305302
/// </remarks>
306303
public bool[] UnknownResultTypeList
307304
{
308-
get { return _unknownResultTypeList; }
305+
get => _unknownResultTypeList;
309306
set
310307
{
311308
// TODO: Check that this isn't modified after calling prepare
@@ -1031,8 +1028,8 @@ async ValueTask<NpgsqlDataReader> ExecuteDbDataReader(CommandBehavior behavior,
10311028
/// </summary>
10321029
protected override DbTransaction DbTransaction
10331030
{
1034-
get { return Transaction; }
1035-
set { Transaction = (NpgsqlTransaction) value; }
1031+
get => Transaction;
1032+
set => Transaction = (NpgsqlTransaction) value;
10361033
}
10371034

10381035
/// <summary>
@@ -1051,7 +1048,7 @@ protected override DbTransaction DbTransaction
10511048
}
10521049
return _transaction;
10531050
}
1054-
set { _transaction = value; }
1051+
set => _transaction = value;
10551052
}
10561053

10571054
#endregion Transactions

src/Npgsql/NpgsqlConnection.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#endregion
2323

2424
using System;
25-
using System.Collections.Concurrent;
26-
using System.Collections.Generic;
2725
using System.ComponentModel;
2826
using System.Data;
2927
using System.Data.Common;
@@ -32,7 +30,6 @@
3230
using System.Net.Security;
3331
using System.Net.Sockets;
3432
using System.Reflection;
35-
using System.Resources;
3633
using System.Security.Cryptography;
3734
using System.Security.Cryptography.X509Certificates;
3835
using System.Threading;
@@ -278,7 +275,7 @@ async Task Open(bool async, CancellationToken cancellationToken)
278275
[CanBeNull]
279276
public override string ConnectionString
280277
{
281-
get { return _userFacingConnectionString; }
278+
get => _userFacingConnectionString;
282279
set
283280
{
284281
CheckConnectionClosed();
@@ -1285,10 +1282,8 @@ public override DataTable GetSchema([CanBeNull] string collectionName)
12851282
/// <returns>The collection specified.</returns>
12861283
public override DataTable GetSchema([CanBeNull] string collectionName, [CanBeNull] string[] restrictions)
12871284
{
1288-
if (String.IsNullOrEmpty(collectionName))
1289-
{
1285+
if (string.IsNullOrEmpty(collectionName))
12901286
throw new ArgumentException("Collection name cannot be null or empty", nameof(collectionName));
1291-
}
12921287

12931288
switch (collectionName.ToUpperInvariant())
12941289
{
@@ -1447,7 +1442,7 @@ public void ReloadTypes()
14471442
/// </summary>
14481443
/// <param name="sender">The source of the event.</param>
14491444
/// <param name="e">A <see cref="NpgsqlNoticeEventArgs">NpgsqlNoticeEventArgs</see> that contains the event data.</param>
1450-
public delegate void NoticeEventHandler(Object sender, NpgsqlNoticeEventArgs e);
1445+
public delegate void NoticeEventHandler(object sender, NpgsqlNoticeEventArgs e);
14511446

14521447
/// <summary>
14531448
/// Represents the method that handles the <see cref="NpgsqlConnection.Notification">Notification</see> events.

0 commit comments

Comments
 (0)