Skip to content

Commit 5516807

Browse files
committed
Use expression-bodied property accessors.
1 parent 9dd55dd commit 5516807

File tree

5 files changed

+58
-61
lines changed

5 files changed

+58
-61
lines changed

src/MySqlConnector/ByteArrayReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public ByteArrayReader(ArraySegment<byte> arraySegment)
1818

1919
public int Offset
2020
{
21-
get { return m_offset; }
22-
set { m_offset = value >= 0 && value <= m_maxOffset ? value : throw new ArgumentOutOfRangeException(nameof(value), "value must be between 0 and {0}".FormatInvariant(m_maxOffset)); }
21+
get => m_offset;
22+
set => m_offset = value >= 0 && value <= m_maxOffset ? value : throw new ArgumentOutOfRangeException(nameof(value), "value must be between 0 and {0}".FormatInvariant(m_maxOffset));
2323
}
2424

2525
public byte ReadByte()

src/MySqlConnector/MySqlClient/MySqlConnectionStringBuilder.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,149 +19,149 @@ public MySqlConnectionStringBuilder(string connectionString)
1919
// Base Options
2020
public string Server
2121
{
22-
get { return MySqlConnectionStringOption.Server.GetValue(this); }
23-
set { MySqlConnectionStringOption.Server.SetValue(this, value); }
22+
get => MySqlConnectionStringOption.Server.GetValue(this);
23+
set => MySqlConnectionStringOption.Server.SetValue(this, value);
2424
}
2525

2626
public uint Port
2727
{
28-
get { return MySqlConnectionStringOption.Port.GetValue(this); }
29-
set { MySqlConnectionStringOption.Port.SetValue(this, value); }
28+
get => MySqlConnectionStringOption.Port.GetValue(this);
29+
set => MySqlConnectionStringOption.Port.SetValue(this, value);
3030
}
3131

3232
public string UserID
3333
{
34-
get { return MySqlConnectionStringOption.UserID.GetValue(this); }
35-
set { MySqlConnectionStringOption.UserID.SetValue(this, value); }
34+
get => MySqlConnectionStringOption.UserID.GetValue(this);
35+
set => MySqlConnectionStringOption.UserID.SetValue(this, value);
3636
}
3737

3838
public string Password
3939
{
40-
get { return MySqlConnectionStringOption.Password.GetValue(this); }
41-
set { MySqlConnectionStringOption.Password.SetValue(this, value); }
40+
get => MySqlConnectionStringOption.Password.GetValue(this);
41+
set => MySqlConnectionStringOption.Password.SetValue(this, value);
4242
}
4343

4444
public string Database
4545
{
46-
get { return MySqlConnectionStringOption.Database.GetValue(this); }
47-
set { MySqlConnectionStringOption.Database.SetValue(this, value); }
46+
get => MySqlConnectionStringOption.Database.GetValue(this);
47+
set => MySqlConnectionStringOption.Database.SetValue(this, value);
4848
}
4949

5050
// SSL/TLS Options
5151
public MySqlSslMode SslMode
5252
{
53-
get { return MySqlConnectionStringOption.SslMode.GetValue(this); }
54-
set { MySqlConnectionStringOption.SslMode.SetValue(this, value); }
53+
get => MySqlConnectionStringOption.SslMode.GetValue(this);
54+
set => MySqlConnectionStringOption.SslMode.SetValue(this, value);
5555
}
5656

5757
public string CertificateFile
5858
{
59-
get { return MySqlConnectionStringOption.CertificateFile.GetValue(this); }
60-
set { MySqlConnectionStringOption.CertificateFile.SetValue(this, value); }
59+
get => MySqlConnectionStringOption.CertificateFile.GetValue(this);
60+
set => MySqlConnectionStringOption.CertificateFile.SetValue(this, value);
6161
}
6262

6363
public string CertificatePassword
6464
{
65-
get { return MySqlConnectionStringOption.CertificatePassword.GetValue(this); }
66-
set { MySqlConnectionStringOption.CertificatePassword.SetValue(this, value); }
65+
get => MySqlConnectionStringOption.CertificatePassword.GetValue(this);
66+
set => MySqlConnectionStringOption.CertificatePassword.SetValue(this, value);
6767
}
6868

6969
// Connection Pooling Options
7070
public bool Pooling
7171
{
72-
get { return MySqlConnectionStringOption.Pooling.GetValue(this); }
73-
set { MySqlConnectionStringOption.Pooling.SetValue(this, value); }
72+
get => MySqlConnectionStringOption.Pooling.GetValue(this);
73+
set => MySqlConnectionStringOption.Pooling.SetValue(this, value);
7474
}
7575

7676
public bool ConnectionReset
7777
{
78-
get { return MySqlConnectionStringOption.ConnectionReset.GetValue(this); }
79-
set { MySqlConnectionStringOption.ConnectionReset.SetValue(this, value); }
78+
get => MySqlConnectionStringOption.ConnectionReset.GetValue(this);
79+
set => MySqlConnectionStringOption.ConnectionReset.SetValue(this, value);
8080
}
8181

8282
public uint MinimumPoolSize
8383
{
84-
get { return MySqlConnectionStringOption.MinimumPoolSize.GetValue(this); }
85-
set { MySqlConnectionStringOption.MinimumPoolSize.SetValue(this, value); }
84+
get => MySqlConnectionStringOption.MinimumPoolSize.GetValue(this);
85+
set => MySqlConnectionStringOption.MinimumPoolSize.SetValue(this, value);
8686
}
8787

8888
public uint MaximumPoolSize
8989
{
90-
get { return MySqlConnectionStringOption.MaximumPoolSize.GetValue(this); }
91-
set { MySqlConnectionStringOption.MaximumPoolSize.SetValue(this, value); }
90+
get => MySqlConnectionStringOption.MaximumPoolSize.GetValue(this);
91+
set => MySqlConnectionStringOption.MaximumPoolSize.SetValue(this, value);
9292
}
9393

9494
// Other Options
9595
public bool AllowUserVariables
9696
{
97-
get { return MySqlConnectionStringOption.AllowUserVariables.GetValue(this); }
98-
set { MySqlConnectionStringOption.AllowUserVariables.SetValue(this, value); }
97+
get => MySqlConnectionStringOption.AllowUserVariables.GetValue(this);
98+
set => MySqlConnectionStringOption.AllowUserVariables.SetValue(this, value);
9999
}
100100

101101
public bool BufferResultSets
102102
{
103-
get { return MySqlConnectionStringOption.BufferResultSets.GetValue(this); }
104-
set { MySqlConnectionStringOption.BufferResultSets.SetValue(this, value); }
103+
get => MySqlConnectionStringOption.BufferResultSets.GetValue(this);
104+
set => MySqlConnectionStringOption.BufferResultSets.SetValue(this, value);
105105
}
106106

107107
public string CharacterSet
108108
{
109-
get { return MySqlConnectionStringOption.CharacterSet.GetValue(this); }
110-
set { MySqlConnectionStringOption.CharacterSet.SetValue(this, value); }
109+
get => MySqlConnectionStringOption.CharacterSet.GetValue(this);
110+
set => MySqlConnectionStringOption.CharacterSet.SetValue(this, value);
111111
}
112112

113113
public uint ConnectionTimeout
114114
{
115-
get { return MySqlConnectionStringOption.ConnectionTimeout.GetValue(this); }
116-
set { MySqlConnectionStringOption.ConnectionTimeout.SetValue(this, value); }
115+
get => MySqlConnectionStringOption.ConnectionTimeout.GetValue(this);
116+
set => MySqlConnectionStringOption.ConnectionTimeout.SetValue(this, value);
117117
}
118118

119119
public bool ConvertZeroDateTime
120120
{
121-
get { return MySqlConnectionStringOption.ConvertZeroDateTime.GetValue(this); }
122-
set { MySqlConnectionStringOption.ConvertZeroDateTime.SetValue(this, value); }
121+
get => MySqlConnectionStringOption.ConvertZeroDateTime.GetValue(this);
122+
set => MySqlConnectionStringOption.ConvertZeroDateTime.SetValue(this, value);
123123
}
124124

125125
public bool ForceSynchronous
126126
{
127-
get { return MySqlConnectionStringOption.ForceSynchronous.GetValue(this); }
128-
set { MySqlConnectionStringOption.ForceSynchronous.SetValue(this, value); }
127+
get => MySqlConnectionStringOption.ForceSynchronous.GetValue(this);
128+
set => MySqlConnectionStringOption.ForceSynchronous.SetValue(this, value);
129129
}
130130

131131
public uint Keepalive
132132
{
133-
get { return MySqlConnectionStringOption.Keepalive.GetValue(this); }
134-
set { MySqlConnectionStringOption.Keepalive.SetValue(this, value); }
133+
get => MySqlConnectionStringOption.Keepalive.GetValue(this);
134+
set => MySqlConnectionStringOption.Keepalive.SetValue(this, value);
135135
}
136136

137137
public bool OldGuids
138138
{
139-
get { return MySqlConnectionStringOption.OldGuids.GetValue(this); }
140-
set { MySqlConnectionStringOption.OldGuids.SetValue(this, value); }
139+
get => MySqlConnectionStringOption.OldGuids.GetValue(this);
140+
set => MySqlConnectionStringOption.OldGuids.SetValue(this, value);
141141
}
142142

143143
public bool PersistSecurityInfo
144144
{
145-
get { return MySqlConnectionStringOption.PersistSecurityInfo.GetValue(this); }
146-
set { MySqlConnectionStringOption.PersistSecurityInfo.SetValue(this, value); }
145+
get => MySqlConnectionStringOption.PersistSecurityInfo.GetValue(this);
146+
set => MySqlConnectionStringOption.PersistSecurityInfo.SetValue(this, value);
147147
}
148148

149149
public bool TreatTinyAsBoolean
150150
{
151-
get { return MySqlConnectionStringOption.TreatTinyAsBoolean.GetValue(this); }
152-
set { MySqlConnectionStringOption.TreatTinyAsBoolean.SetValue(this, value); }
151+
get => MySqlConnectionStringOption.TreatTinyAsBoolean.GetValue(this);
152+
set => MySqlConnectionStringOption.TreatTinyAsBoolean.SetValue(this, value);
153153
}
154154

155155
public bool UseAffectedRows
156156
{
157-
get { return MySqlConnectionStringOption.UseAffectedRows.GetValue(this); }
158-
set { MySqlConnectionStringOption.UseAffectedRows.SetValue(this, value); }
157+
get => MySqlConnectionStringOption.UseAffectedRows.GetValue(this);
158+
set => MySqlConnectionStringOption.UseAffectedRows.SetValue(this, value);
159159
}
160160

161161
public bool UseCompression
162162
{
163-
get { return MySqlConnectionStringOption.UseCompression.GetValue(this); }
164-
set { MySqlConnectionStringOption.UseCompression.SetValue(this, value); }
163+
get => MySqlConnectionStringOption.UseCompression.GetValue(this);
164+
set => MySqlConnectionStringOption.UseCompression.SetValue(this, value);
165165
}
166166

167167
// Other Methods
@@ -179,8 +179,8 @@ public override bool Remove(string key)
179179

180180
public override object this[string key]
181181
{
182-
get { return MySqlConnectionStringOption.GetOptionForKey(key).GetObject(this); }
183-
set { base[MySqlConnectionStringOption.GetOptionForKey(key).Key] = Convert.ToString(value, CultureInfo.InvariantCulture); }
182+
get => MySqlConnectionStringOption.GetOptionForKey(key).GetObject(this);
183+
set => base[MySqlConnectionStringOption.GetOptionForKey(key).Key] = Convert.ToString(value, CultureInfo.InvariantCulture);
184184
}
185185

186186
internal string GetConnectionString(bool includePassword)

src/MySqlConnector/MySqlClient/MySqlParameterCollection.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,12 @@ protected override void SetParameter(string parameterName, DbParameter value)
166166

167167
public override int Count => m_parameters.Count;
168168

169-
public override object SyncRoot
170-
{
171-
get { throw new NotSupportedException(); }
172-
}
169+
public override object SyncRoot => throw new NotSupportedException();
173170

174171
public new MySqlParameter this[int index]
175172
{
176-
get { return m_parameters[index]; }
177-
set { SetParameter(index, value); }
173+
get => m_parameters[index];
174+
set => SetParameter(index, value);
178175
}
179176

180177
// Finds the index of a parameter by name, regardless of whether 'parameterName' or the matching

src/MySqlConnector/Protocol/Serialization/CompressedPayloadHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public void StartNewConversation()
2626

2727
public IByteHandler ByteHandler
2828
{
29-
get { return m_byteHandler; }
30-
set { throw new NotSupportedException(); }
29+
get => m_byteHandler;
30+
set => throw new NotSupportedException();
3131
}
3232

3333
public ValueTask<ArraySegment<byte>> ReadPayloadAsync(ProtocolErrorBehavior protocolErrorBehavior, IOBehavior ioBehavior) =>

src/MySqlConnector/Protocol/Serialization/StandardPayloadHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void StartNewConversation()
1717

1818
public IByteHandler ByteHandler
1919
{
20-
get { return m_byteHandler; }
20+
get => m_byteHandler;
2121
set
2222
{
2323
m_byteHandler = value ?? throw new ArgumentNullException(nameof(value));

0 commit comments

Comments
 (0)