Skip to content

Commit 7a069b3

Browse files
committed
Enable SA1519: require braces for multi-line child statements.
1 parent 6213388 commit 7a069b3

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ dotnet_diagnostic.SA1500.severity = none # Braces for multi-line statements shou
8989
dotnet_diagnostic.SA1503.severity = none # Braces should not be omitted.
9090
dotnet_diagnostic.SA1513.severity = none # Closing brace should be followed by blank line.
9191
dotnet_diagnostic.SA1516.severity = none # Elements should be separated by blank line.
92-
dotnet_diagnostic.SA1519.severity = silent # Braces should not be omitted from multi-line child statements.
9392
dotnet_diagnostic.SA1600.severity = none # Elements should be documented.
9493
dotnet_diagnostic.SA1602.severity = none # Enumeration items should be documented.
9594
dotnet_diagnostic.SA1611.severity = none # Element parameters should be documented.

src/MySqlConnector/Core/ConnectionPool.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,13 @@ private async Task CleanPoolAsync(IOBehavior ioBehavior, Func<ServerSession, boo
259259
{
260260
// if respectMinPoolSize is true, return if (leased sessions + waiting sessions <= minPoolSize)
261261
if (respectMinPoolSize)
262+
{
262263
lock (m_sessions)
264+
{
263265
if (ConnectionSettings.MaximumPoolSize - m_sessionSemaphore.CurrentCount + m_sessions.Count <= ConnectionSettings.MinimumPoolSize)
264266
return;
267+
}
268+
}
265269

266270
// try to get an open slot; if this fails, connection pool is full and sessions will be disposed when returned to pool
267271
if (ioBehavior == IOBehavior.Asynchronous)

src/MySqlConnector/Core/TypeMapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ private DbTypeMapping AddDbTypeMapping(DbTypeMapping dbTypeMapping)
136136
m_dbTypeMappingsByClrType[dbTypeMapping.ClrType] = dbTypeMapping;
137137

138138
if (dbTypeMapping.DbTypes is not null)
139+
{
139140
foreach (var dbType in dbTypeMapping.DbTypes)
140141
m_dbTypeMappingsByDbType[dbType] = dbTypeMapping;
142+
}
141143

142144
return dbTypeMapping;
143145
}

src/MySqlConnector/MySqlAttributeCollection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public void Add(MySqlAttribute attribute)
2323
if (string.IsNullOrEmpty((attribute ?? throw new ArgumentNullException(nameof(attribute))).AttributeName))
2424
throw new ArgumentException("Attribute name must not be empty", nameof(attribute));
2525
foreach (var existingAttribute in m_attributes)
26+
{
2627
if (existingAttribute.AttributeName == attribute.AttributeName)
2728
throw new ArgumentException("An attribute with the name {0} already exists in the collection".FormatInvariant(attribute.AttributeName), nameof(attribute));
29+
}
2830
m_attributes.Add(attribute);
2931
}
3032

src/MySqlConnector/MySqlConnectionStringBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,13 @@ internal string GetConnectionString(bool includePassword)
839839
{
840840
var csb = new MySqlConnectionStringBuilder(connectionString);
841841
foreach (string? key in Keys)
842+
{
842843
foreach (var passwordKey in MySqlConnectionStringOption.Password.Keys)
844+
{
843845
if (string.Equals(key, passwordKey, StringComparison.OrdinalIgnoreCase))
844846
csb.Remove(key!);
847+
}
848+
}
845849
m_cachedConnectionStringWithoutPassword = csb.ConnectionString;
846850
m_cachedConnectionString = connectionString;
847851
}

src/MySqlConnector/Utilities/Adler32.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ private static unsafe uint CalculateSse(ReadOnlySpan<byte> buffer)
8080
length -= blocks * BLOCK_SIZE;
8181

8282
int index = 0;
83-
fixed (byte* bufferPtr = buffer)
84-
fixed (byte* tapPtr = Tap1Tap2)
83+
fixed (byte* bufferPtr = buffer, tapPtr = Tap1Tap2)
8584
{
8685
index += (int)blocks * BLOCK_SIZE;
8786
var localBufferPtr = bufferPtr;

src/MySqlConnector/Utilities/Utility.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ public static unsafe int GetByteCount(this Encoding encoding, ReadOnlySpan<char>
5656
public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, Span<byte> bytes)
5757
{
5858
fixed (char* charsPtr = &MemoryMarshal.GetReference(chars))
59-
fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes))
6059
{
61-
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
60+
fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes))
61+
{
62+
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
63+
}
6264
}
6365
}
6466
#endif
@@ -67,11 +69,13 @@ public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan<char> cha
6769
public static unsafe void Convert(this Encoder encoder, ReadOnlySpan<char> chars, Span<byte> bytes, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
6870
{
6971
fixed (char* charsPtr = &MemoryMarshal.GetReference(chars))
70-
fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes))
7172
{
72-
// MemoryMarshal.GetNonNullPinnableReference is internal, so fake it by using an invalid but non-null pointer; this
73-
// prevents Convert from throwing an exception when the output buffer is empty
74-
encoder.Convert(charsPtr, chars.Length, bytesPtr is null ? (byte*) 1 : bytesPtr, bytes.Length, flush, out charsUsed, out bytesUsed, out completed);
73+
fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes))
74+
{
75+
// MemoryMarshal.GetNonNullPinnableReference is internal, so fake it by using an invalid but non-null pointer; this
76+
// prevents Convert from throwing an exception when the output buffer is empty
77+
encoder.Convert(charsPtr, chars.Length, bytesPtr is null ? (byte*) 1 : bytesPtr, bytes.Length, flush, out charsUsed, out bytesUsed, out completed);
78+
}
7579
}
7680
}
7781

0 commit comments

Comments
 (0)