Skip to content

Commit b5b1abf

Browse files
authored
Automatic use of C# collection initializers (#32736)
1 parent a7a1019 commit b5b1abf

526 files changed

Lines changed: 5387 additions & 5749 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/EFCore.Analyzers/InterpolatedStringUsageInRawQueriesDiagnosticAnalyzer.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ private static bool AnalyzeInterpolatedString(IInterpolatedStringOperation inter
216216
private static IEnumerable<IMethodSymbol> ExecuteSqlRawMethods(Compilation compilation)
217217
{
218218
var type = compilation.RelationalDatabaseFacadeExtensionsType();
219-
return type?.GetMembers("ExecuteSqlRaw").Where(s => s is IMethodSymbol).Cast<IMethodSymbol>() ?? Array.Empty<IMethodSymbol>();
219+
return type?.GetMembers("ExecuteSqlRaw").Where(s => s is IMethodSymbol).Cast<IMethodSymbol>() ?? [];
220220
}
221221

222222
private static IEnumerable<IMethodSymbol> ExecuteSqlRawAsyncMethods(Compilation compilation)
223223
{
224224
var type = compilation.RelationalDatabaseFacadeExtensionsType();
225-
return type?.GetMembers("ExecuteSqlRawAsync").Where(s => s is IMethodSymbol).Cast<IMethodSymbol>() ?? Array.Empty<IMethodSymbol>();
225+
return type?.GetMembers("ExecuteSqlRawAsync").Where(s => s is IMethodSymbol).Cast<IMethodSymbol>() ?? [];
226226
}
227227

228228
private static IMethodSymbol? SqlQueryRawMethod(Compilation compilation)

‎src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected virtual void ValidateSharedContainerCompatibility(
107107

108108
if (!containers.TryGetValue(container, out var mappedTypes))
109109
{
110-
mappedTypes = new List<IEntityType>();
110+
mappedTypes = [];
111111
containers[container] = mappedTypes;
112112
}
113113

‎src/EFCore.Cosmos/Query/Internal/CosmosDateTimeMemberTranslator.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public CosmosDateTimeMemberTranslator(ISqlExpressionFactory sqlExpressionFactory
4343
{
4444
return _sqlExpressionFactory.Function(
4545
"GetCurrentDateTime",
46-
Array.Empty<SqlExpression>(),
46+
[],
4747
returnType);
4848
}
4949

‎src/EFCore.Cosmos/Query/Internal/CosmosMathTranslator.cs‎

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,62 @@ public class CosmosMathTranslator : IMethodCallTranslator
1313
{
1414
private static readonly Dictionary<MethodInfo, string> SupportedMethodTranslations = new()
1515
{
16-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(decimal) })!, "ABS" },
17-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(double) })!, "ABS" },
18-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(float) })!, "ABS" },
19-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(int) })!, "ABS" },
20-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(long) })!, "ABS" },
21-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(sbyte) })!, "ABS" },
22-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(short) })!, "ABS" },
23-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(decimal) })!, "CEILING" },
24-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(double) })!, "CEILING" },
25-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(decimal) })!, "FLOOR" },
26-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(double) })!, "FLOOR" },
27-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) })!, "POWER" },
28-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Exp), new[] { typeof(double) })!, "EXP" },
29-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log10), new[] { typeof(double) })!, "LOG10" },
30-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log), new[] { typeof(double) })!, "LOG" },
31-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log), new[] { typeof(double), typeof(double) })!, "LOG" },
32-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), new[] { typeof(double) })!, "SQRT" },
33-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Acos), new[] { typeof(double) })!, "ACOS" },
34-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Asin), new[] { typeof(double) })!, "ASIN" },
35-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan), new[] { typeof(double) })!, "ATAN" },
36-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan2), new[] { typeof(double), typeof(double) })!, "ATN2" },
37-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Cos), new[] { typeof(double) })!, "COS" },
38-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sin), new[] { typeof(double) })!, "SIN" },
39-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Tan), new[] { typeof(double) })!, "TAN" },
40-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(decimal) })!, "SIGN" },
41-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(double) })!, "SIGN" },
42-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(float) })!, "SIGN" },
43-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(int) })!, "SIGN" },
44-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(long) })!, "SIGN" },
45-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(sbyte) })!, "SIGN" },
46-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(short) })!, "SIGN" },
47-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Truncate), new[] { typeof(decimal) })!, "TRUNC" },
48-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Truncate), new[] { typeof(double) })!, "TRUNC" },
49-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal) })!, "ROUND" },
50-
{ typeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(double) })!, "ROUND" },
51-
{ typeof(double).GetRuntimeMethod(nameof(double.DegreesToRadians), new[] { typeof(double) })!, "RADIANS" },
52-
{ typeof(double).GetRuntimeMethod(nameof(double.RadiansToDegrees), new[] { typeof(double) })!, "DEGREES" },
53-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Ceiling), new[] { typeof(float) })!, "CEILING" },
54-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Floor), new[] { typeof(float) })!, "FLOOR" },
55-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Pow), new[] { typeof(float), typeof(float) })!, "POWER" },
56-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Exp), new[] { typeof(float) })!, "EXP" },
57-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log10), new[] { typeof(float) })!, "LOG10" },
58-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), new[] { typeof(float) })!, "LOG" },
59-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), new[] { typeof(float), typeof(float) })!, "LOG" },
60-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), new[] { typeof(float) })!, "SQRT" },
61-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Acos), new[] { typeof(float) })!, "ACOS" },
62-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Asin), new[] { typeof(float) })!, "ASIN" },
63-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan), new[] { typeof(float) })!, "ATAN" },
64-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan2), new[] { typeof(float), typeof(float) })!, "ATN2" },
65-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Cos), new[] { typeof(float) })!, "COS" },
66-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Sin), new[] { typeof(float) })!, "SIN" },
67-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Tan), new[] { typeof(float) })!, "TAN" },
68-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Truncate), new[] { typeof(float) })!, "TRUNC" },
69-
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Round), new[] { typeof(float) })!, "ROUND" },
70-
{ typeof(float).GetRuntimeMethod(nameof(float.DegreesToRadians), new[] { typeof(float) })!, "RADIANS" },
71-
{ typeof(float).GetRuntimeMethod(nameof(float.RadiansToDegrees), new[] { typeof(float) })!, "DEGREES" },
16+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(decimal)])!, "ABS" },
17+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(double)])!, "ABS" },
18+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(float)])!, "ABS" },
19+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(int)])!, "ABS" },
20+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(long)])!, "ABS" },
21+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(sbyte)])!, "ABS" },
22+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(short)])!, "ABS" },
23+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), [typeof(decimal)])!, "CEILING" },
24+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), [typeof(double)])!, "CEILING" },
25+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), [typeof(decimal)])!, "FLOOR" },
26+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), [typeof(double)])!, "FLOOR" },
27+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Pow), [typeof(double), typeof(double)])!, "POWER" },
28+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Exp), [typeof(double)])!, "EXP" },
29+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log10), [typeof(double)])!, "LOG10" },
30+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log), [typeof(double)])!, "LOG" },
31+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Log), [typeof(double), typeof(double)])!, "LOG" },
32+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), [typeof(double)])!, "SQRT" },
33+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Acos), [typeof(double)])!, "ACOS" },
34+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Asin), [typeof(double)])!, "ASIN" },
35+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan), [typeof(double)])!, "ATAN" },
36+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan2), [typeof(double), typeof(double)])!, "ATN2" },
37+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Cos), [typeof(double)])!, "COS" },
38+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sin), [typeof(double)])!, "SIN" },
39+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Tan), [typeof(double)])!, "TAN" },
40+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(decimal)])!, "SIGN" },
41+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(double)])!, "SIGN" },
42+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(float)])!, "SIGN" },
43+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(int)])!, "SIGN" },
44+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(long)])!, "SIGN" },
45+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(sbyte)])!, "SIGN" },
46+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(short)])!, "SIGN" },
47+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Truncate), [typeof(decimal)])!, "TRUNC" },
48+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Truncate), [typeof(double)])!, "TRUNC" },
49+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Round), [typeof(decimal)])!, "ROUND" },
50+
{ typeof(Math).GetRuntimeMethod(nameof(Math.Round), [typeof(double)])!, "ROUND" },
51+
{ typeof(double).GetRuntimeMethod(nameof(double.DegreesToRadians), [typeof(double)])!, "RADIANS" },
52+
{ typeof(double).GetRuntimeMethod(nameof(double.RadiansToDegrees), [typeof(double)])!, "DEGREES" },
53+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Ceiling), [typeof(float)])!, "CEILING" },
54+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Floor), [typeof(float)])!, "FLOOR" },
55+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Pow), [typeof(float), typeof(float)])!, "POWER" },
56+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Exp), [typeof(float)])!, "EXP" },
57+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log10), [typeof(float)])!, "LOG10" },
58+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), [typeof(float)])!, "LOG" },
59+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), [typeof(float), typeof(float)])!, "LOG" },
60+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), [typeof(float)])!, "SQRT" },
61+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Acos), [typeof(float)])!, "ACOS" },
62+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Asin), [typeof(float)])!, "ASIN" },
63+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan), [typeof(float)])!, "ATAN" },
64+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan2), [typeof(float), typeof(float)])!, "ATN2" },
65+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Cos), [typeof(float)])!, "COS" },
66+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Sin), [typeof(float)])!, "SIN" },
67+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Tan), [typeof(float)])!, "TAN" },
68+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Truncate), [typeof(float)])!, "TRUNC" },
69+
{ typeof(MathF).GetRuntimeMethod(nameof(MathF.Round), [typeof(float)])!, "ROUND" },
70+
{ typeof(float).GetRuntimeMethod(nameof(float.DegreesToRadians), [typeof(float)])!, "RADIANS" },
71+
{ typeof(float).GetRuntimeMethod(nameof(float.RadiansToDegrees), [typeof(float)])!, "DEGREES" },
7272
};
7373

7474
private readonly ISqlExpressionFactory _sqlExpressionFactory;

‎src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
1111
/// </summary>
1212
public class CosmosMemberTranslatorProvider : IMemberTranslatorProvider
1313
{
14-
private readonly List<IMemberTranslator> _plugins = new();
15-
private readonly List<IMemberTranslator> _translators = new();
14+
private readonly List<IMemberTranslator> _plugins = [];
15+
private readonly List<IMemberTranslator> _translators = [];
1616

1717
/// <summary>
1818
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to

‎src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
1111
/// </summary>
1212
public class CosmosMethodCallTranslatorProvider : IMethodCallTranslatorProvider
1313
{
14-
private readonly List<IMethodCallTranslator> _plugins = new();
15-
private readonly List<IMethodCallTranslator> _translators = new();
14+
private readonly List<IMethodCallTranslator> _plugins = [];
15+
private readonly List<IMethodCallTranslator> _translators = [];
1616

1717
/// <summary>
1818
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to

‎src/EFCore.Cosmos/Query/Internal/CosmosRandomTranslator.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
1414
public class CosmosRandomTranslator : IMethodCallTranslator
1515
{
1616
private static readonly MethodInfo MethodInfo = typeof(DbFunctionsExtensions).GetRuntimeMethod(
17-
nameof(DbFunctionsExtensions.Random), new[] { typeof(DbFunctions) });
17+
nameof(DbFunctionsExtensions.Random), [typeof(DbFunctions)]);
1818

1919
private readonly ISqlExpressionFactory _sqlExpressionFactory;
2020

‎src/EFCore.Cosmos/Query/Internal/CosmosRegexTranslator.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
1414
public class CosmosRegexTranslator : IMethodCallTranslator
1515
{
1616
private static readonly MethodInfo IsMatch =
17-
typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), new[] { typeof(string), typeof(string) })!;
17+
typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), [typeof(string), typeof(string)])!;
1818

1919
private static readonly MethodInfo IsMatchWithRegexOptions =
20-
typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), new[] { typeof(string), typeof(string), typeof(RegexOptions) })!;
20+
typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), [typeof(string), typeof(string), typeof(RegexOptions)])!;
2121

2222
private readonly ISqlExpressionFactory _sqlExpressionFactory;
2323

‎src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private readonly IDictionary<Expression, Expression> _ordinalParameterBindings
5454
= new Dictionary<Expression, Expression>();
5555

5656
private List<IncludeExpression> _pendingIncludes
57-
= new();
57+
= [];
5858

5959
private static readonly MethodInfo ToObjectWithSerializerMethodInfo
6060
= typeof(CosmosProjectionBindingRemovingExpressionVisitorBase)
@@ -328,7 +328,7 @@ private BlockExpression AddIncludes(BlockExpression shaperBlock)
328328
shaperExpressions.RemoveAt(shaperExpressions.Count - 1);
329329

330330
var includesToProcess = _pendingIncludes;
331-
_pendingIncludes = new List<IncludeExpression>();
331+
_pendingIncludes = [];
332332

333333
foreach (var include in includesToProcess)
334334
{
@@ -565,7 +565,7 @@ private static readonly MethodInfo PopulateCollectionMethodInfo
565565
.GetDeclaredMethod(nameof(PopulateCollection));
566566

567567
private static readonly MethodInfo IsAssignableFromMethodInfo
568-
= typeof(IReadOnlyEntityType).GetMethod(nameof(IReadOnlyEntityType.IsAssignableFrom), new[] { typeof(IReadOnlyEntityType) })!;
568+
= typeof(IReadOnlyEntityType).GetMethod(nameof(IReadOnlyEntityType.IsAssignableFrom), [typeof(IReadOnlyEntityType)])!;
569569

570570
private static TCollection PopulateCollection<TEntity, TCollection>(
571571
IClrCollectionAccessor accessor,

‎src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public class CosmosSqlTranslatingExpressionVisitor : ExpressionVisitor
2525
typeof(CosmosSqlTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ParameterListValueExtractor));
2626

2727
private static readonly MethodInfo ConcatMethodInfo
28-
= typeof(string).GetRuntimeMethod(nameof(string.Concat), new[] { typeof(object), typeof(object) });
28+
= typeof(string).GetRuntimeMethod(nameof(string.Concat), [typeof(object), typeof(object)]);
2929

3030
private static readonly MethodInfo StringEqualsWithStringComparison
31-
= typeof(string).GetRuntimeMethod(nameof(string.Equals), new[] { typeof(string), typeof(StringComparison) });
31+
= typeof(string).GetRuntimeMethod(nameof(string.Equals), [typeof(string), typeof(StringComparison)]);
3232

3333
private static readonly MethodInfo StringEqualsWithStringComparisonStatic
34-
= typeof(string).GetRuntimeMethod(nameof(string.Equals), new[] { typeof(string), typeof(string), typeof(StringComparison) });
34+
= typeof(string).GetRuntimeMethod(nameof(string.Equals), [typeof(string), typeof(string), typeof(StringComparison)]);
3535

3636
private static readonly MethodInfo GetTypeMethodInfo = typeof(object).GetTypeInfo().GetDeclaredMethod(nameof(GetType))!;
3737

@@ -472,7 +472,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
472472
&& right is SqlExpression rightSql)
473473
{
474474
sqlObject = leftSql;
475-
arguments = new[] { rightSql };
475+
arguments = [rightSql];
476476
}
477477
else
478478
{
@@ -499,7 +499,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
499499
if (left is SqlExpression leftSql
500500
&& right is SqlExpression rightSql)
501501
{
502-
arguments = new[] { leftSql, rightSql };
502+
arguments = [leftSql, rightSql];
503503
}
504504
else
505505
{
@@ -579,7 +579,7 @@ Expression TranslateContains(Expression untranslatedItem, Expression untranslate
579579
{
580580
var translatedValues = values is IList iList
581581
? new List<SqlExpression>(iList.Count)
582-
: new List<SqlExpression>();
582+
: [];
583583
foreach (var value in values)
584584
{
585585
translatedValues.Add(_sqlExpressionFactory.Constant(value, typeMapping));

0 commit comments

Comments
 (0)