Skip to content

Commit c7bfe08

Browse files
committed
Replace Array.Empty with C# 12 collection expression.
1 parent 264d5ec commit c7bfe08

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

src/MySqlConnector/MySqlDataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public ReadOnlyCollection<DbColumn> GetColumnSchema()
347347
{
348348
var hasNoSchema = !m_resultSet.HasResultSet || m_resultSet.ContainsCommandParameters;
349349
if (hasNoSchema)
350-
return new ReadOnlyCollection<DbColumn>(Array.Empty<DbColumn>());
350+
return new ReadOnlyCollection<DbColumn>([]);
351351

352352
var columnDefinitions = m_resultSet.ColumnDefinitions;
353353
var resultSet = GetResultSet();

src/MySqlConnector/Protocol/Payloads/AuthenticationMethodSwitchRequestPayload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static AuthenticationMethodSwitchRequestPayload Create(ReadOnlySpan<byte>
2222
// if the packet is just the header byte (0xFE), it's an "Old Authentication Method Switch Request Packet"
2323
// (possibly sent by a server that doesn't support CLIENT_PLUGIN_AUTH)
2424
name = "mysql_old_password";
25-
data = Array.Empty<byte>();
25+
data = [];
2626
}
2727
else
2828
{

src/MySqlConnector/Protocol/Payloads/EmptyPayload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace MySqlConnector.Protocol.Payloads;
22

33
internal static class EmptyPayload
44
{
5-
public static PayloadData Instance { get; } = new(Array.Empty<byte>());
5+
public static PayloadData Instance { get; } = new([]);
66
}

src/MySqlConnector/Protocol/Serialization/AuthenticationUtility.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace MySqlConnector.Protocol.Serialization;
1010
internal static class AuthenticationUtility
1111
{
1212
public static byte[] CreateAuthenticationResponse(ReadOnlySpan<byte> challenge, string password) =>
13-
string.IsNullOrEmpty(password) ? Array.Empty<byte>() : HashPassword(challenge, password);
13+
string.IsNullOrEmpty(password) ? [] : HashPassword(challenge, password);
1414

1515
/// <summary>
1616
/// Hashes a password with the "Secure Password Authentication" method.
@@ -54,14 +54,8 @@ public static byte[] HashPassword(ReadOnlySpan<byte> challenge, string password)
5454
return hashedPassword.ToArray();
5555
}
5656

57-
public static byte[] CreateScrambleResponse(ReadOnlySpan<byte> nonce, string password)
58-
{
59-
var scrambleResponse = string.IsNullOrEmpty(password)
60-
? Array.Empty<byte>()
61-
: HashPasswordWithNonce(nonce, password);
62-
63-
return scrambleResponse;
64-
}
57+
public static byte[] CreateScrambleResponse(ReadOnlySpan<byte> nonce, string password) =>
58+
string.IsNullOrEmpty(password) ? [] : HashPasswordWithNonce(nonce, password);
6559

6660
#if NET5_0_OR_GREATER
6761
[SkipLocalsInit]

0 commit comments

Comments
 (0)