Skip to content

Commit d4a5939

Browse files
committed
Use more static lambdas.
1 parent 5695248 commit d4a5939

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/MySqlConnector.DependencyInjection/MySqlConnectorServiceCollectionExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ private static IServiceCollection DoAddMySqlDataSource(
100100
},
101101
dataSourceLifetime));
102102

103-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(MySqlConnection), x => x.GetRequiredService<MySqlDataSource>().CreateConnection(), connectionLifetime));
103+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(MySqlConnection), static x => x.GetRequiredService<MySqlDataSource>().CreateConnection(), connectionLifetime));
104104

105105
#if NET7_0_OR_GREATER
106-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbDataSource), x => x.GetRequiredService<MySqlDataSource>(), dataSourceLifetime));
106+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbDataSource), static x => x.GetRequiredService<MySqlDataSource>(), dataSourceLifetime));
107107
#endif
108108

109-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbConnection), x => x.GetRequiredService<MySqlConnection>(), connectionLifetime));
109+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbConnection), static x => x.GetRequiredService<MySqlConnection>(), connectionLifetime));
110110

111111
return serviceCollection;
112112
}
@@ -133,13 +133,13 @@ private static IServiceCollection DoAddMySqlDataSource(
133133
},
134134
dataSourceLifetime));
135135

136-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(MySqlConnection), serviceKey, (sp, sk) => sp.GetRequiredKeyedService<MySqlDataSource>(sk).CreateConnection(), connectionLifetime));
136+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(MySqlConnection), serviceKey, static (sp, sk) => sp.GetRequiredKeyedService<MySqlDataSource>(sk).CreateConnection(), connectionLifetime));
137137

138138
#if NET7_0_OR_GREATER
139-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbDataSource), serviceKey, (sp, sk) => sp.GetRequiredKeyedService<MySqlDataSource>(sk), dataSourceLifetime));
139+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbDataSource), serviceKey, static (sp, sk) => sp.GetRequiredKeyedService<MySqlDataSource>(sk), dataSourceLifetime));
140140
#endif
141141

142-
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbConnection), serviceKey, (sp, sk) => sp.GetRequiredKeyedService<MySqlConnection>(sk), connectionLifetime));
142+
serviceCollection.TryAdd(new ServiceDescriptor(typeof(DbConnection), serviceKey, static (sp, sk) => sp.GetRequiredKeyedService<MySqlConnection>(sk), connectionLifetime));
143143

144144
return serviceCollection;
145145
}

src/MySqlConnector/Core/MetricsReporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ static MetricsReporter()
3939
description: "The maximum number of open connections allowed; this corresponds to MaximumPoolSize in the connection string.");
4040

4141
static IEnumerable<Measurement<int>> GetMaximumConnections() =>
42-
ConnectionPool.GetAllPools().Select(x => new Measurement<int>(x.ConnectionSettings.MaximumPoolSize, x.PoolNameTagList));
42+
ConnectionPool.GetAllPools().Select(static x => new Measurement<int>(x.ConnectionSettings.MaximumPoolSize, x.PoolNameTagList));
4343

4444
static IEnumerable<Measurement<int>> GetMinimumConnections() =>
45-
ConnectionPool.GetAllPools().Select(x => new Measurement<int>(x.ConnectionSettings.MinimumPoolSize, x.PoolNameTagList));
45+
ConnectionPool.GetAllPools().Select(static x => new Measurement<int>(x.ConnectionSettings.MinimumPoolSize, x.PoolNameTagList));
4646
}
4747

4848
private static readonly UpDownCounter<int> s_connectionsUsageCounter = ActivitySourceHelper.Meter.CreateUpDownCounter<int>("db.client.connections.usage",

src/MySqlConnector/Core/SchemaProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ await FillDataTableAsync(ioBehavior, dataTable, command =>
391391
#pragma warning restore CA2100
392392
if (columns is { Count: > 0 })
393393
{
394-
command.CommandText += " WHERE " + string.Join(" AND ", columns.Select(x => $@"{x.Key} = @{x.Key}"));
394+
command.CommandText += " WHERE " + string.Join(" AND ", columns.Select(static x => $@"{x.Key} = @{x.Key}"));
395395
foreach (var column in columns)
396396
command.Parameters.AddWithValue("@" + column.Key, column.Value);
397397
}

src/MySqlConnector/Core/SingleCommandPayloadCreator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public bool WriteQueryCommand(ref CommandListPosition commandListPosition, IDict
3535
writer.Write((byte) 1);
3636

3737
if (attributes?.Count > 0)
38-
WriteBinaryParameters(writer, attributes.Select(x => x.ToParameter()).ToArray(), command, true, 0);
38+
WriteBinaryParameters(writer, attributes.Select(static x => x.ToParameter()).ToArray(), command, true, 0);
3939
}
4040
else if (command.RawAttributes?.Count > 0)
4141
{

src/MySqlConnector/MySqlConnectionStringBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ public bool UseXaTransactions
805805
/// <summary>
806806
/// Returns an <see cref="ICollection"/> that contains the keys in the <see cref="MySqlConnectionStringBuilder"/>.
807807
/// </summary>
808-
public override ICollection Keys => base.Keys.Cast<string>().OrderBy(x => MySqlConnectionStringOption.OptionNames.IndexOf(x)).ToList();
808+
public override ICollection Keys => base.Keys.Cast<string>().OrderBy(static x => MySqlConnectionStringOption.OptionNames.IndexOf(x)).ToList();
809809

810810
/// <summary>
811811
/// Whether this <see cref="MySqlConnectionStringBuilder"/> contains a set option with the specified name.
@@ -1165,7 +1165,7 @@ static MySqlConnectionStringOption()
11651165
AddOption(options, CancellationTimeout = new(
11661166
keys: ["Cancellation Timeout", "CancellationTimeout"],
11671167
defaultValue: 2,
1168-
coerce: x =>
1168+
coerce: static x =>
11691169
{
11701170
if (x < -1)
11711171
throw new ArgumentOutOfRangeException(nameof(CancellationTimeout), "CancellationTimeout must be greater than or equal to -1");

0 commit comments

Comments
 (0)