chore(sonar): apply collection-expression syntax across all sites (IDE0028)
SonarQube Analysis / sonarqube (pull_request) Successful in 2m47s

Manual sweep of all 42 IDE0028 sites flagged by SonarQube — `dotnet format
analyzers --diagnostics IDE0028` declined to fix these (no .editorconfig
opt-in for `dotnet_style_prefer_collection_expression`), so applied by
hand. The repo already targets `<LangVersion>latest</LangVersion>` on
net8.0, so C# 12 collection expressions are available.

Pattern: `new List<T>()` / `new Dictionary<K,V>()` / `new ArrayList()` /
`new()` -> `[]` for empty; `new List<T> { ... }` -> `[...]` for literal.

24 files touched in src/{EFCore, LinqToSql, Query, Snowflake, SqlBreakdown,
SqlServer}; tests untouched (no IDE0028 sites in test code).

Build clean (35 warnings unchanged from baseline, 0 errors). All tests
remain green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thom Lamb
2026-05-26 17:01:30 -05:00
co-authored by Claude Opus 4.7
parent c38d122d76
commit 0f8d505616
24 changed files with 46 additions and 46 deletions
@@ -20,7 +20,7 @@ public class RawSqlBreakdown : ISqlBreakdown
/// <summary>
/// Gets or sets the setup clauses to execute before the main statement.
/// </summary>
public List<string> SetupClauses { get; set; } = new List<string>();
public List<string> SetupClauses { get; set; } = [];
/// <summary>
/// Gets a value indicating whether setup clauses are being used.
@@ -30,7 +30,7 @@ public class RawSqlBreakdown : ISqlBreakdown
/// <summary>
/// Gets or sets the finish clauses to execute after the main statement.
/// </summary>
public ArrayList FinishClauses { get; set; } = new ArrayList();
public ArrayList FinishClauses { get; set; } = [];
/// <summary>
/// Gets a value indicating whether finish clauses are being used.
@@ -14,8 +14,8 @@ public abstract class SqlBreakdownBase : ISqlBreakdown
/// </summary>
protected SqlBreakdownBase()
{
SetupClauses = new List<string>();
FinishClauses = new ArrayList();
SetupClauses = [];
FinishClauses = [];
}
/// <summary>
@@ -22,7 +22,7 @@ public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
/// </summary>
public SqlBreakdownCollection()
{
_breakdowns = new List<ISqlBreakdown>();
_breakdowns = [];
}
/// <summary>
@@ -18,7 +18,7 @@ public class SqlFilter : ISqlAppendable
public SqlFilter()
{
_sqlExpression = new StringBuilder();
_parameterValues = new Dictionary<string, object>();
_parameterValues = [];
}
/// <summary>
@@ -29,7 +29,7 @@ public class SqlFilter : ISqlAppendable
public SqlFilter(string expression, params object[] parameterNameValue)
{
_sqlExpression = new StringBuilder(expression);
_parameterValues = new Dictionary<string, object>();
_parameterValues = [];
if (parameterNameValue.Length % 2 != 0)
{
@@ -49,7 +49,7 @@ public class SqlFilter : ISqlAppendable
public SqlFilter(SqlFilter filter)
{
_sqlExpression = new StringBuilder(filter.SqlExpression);
_parameterValues = new Dictionary<string, object>();
_parameterValues = [];
foreach (var key in filter.ParameterValues.Keys)
{
@@ -18,7 +18,7 @@ public class SqlFrom
public SqlFrom(string tableExpression, string tableAlias)
{
_firstTable = new SqlTable(tableExpression, tableAlias);
_joins = new List<SqlJoin>();
_joins = [];
}
/// <summary>
@@ -348,13 +348,13 @@ public class HierarchicalData : IHierarchicalData
private Dictionary<Guid, List<IHierarchicalData>> _childDataMap;
[JsonConstructor]
public HierarchicalData() : this(Guid.Empty, default!, new List<IHierarchicalData>())
public HierarchicalData() : this(Guid.Empty, default!, [])
{
}
public HierarchicalData(Guid dataSourceGuid, IFlatData rootData) : this(dataSourceGuid, rootData,
new List<IHierarchicalData>())
[])
{
}
@@ -388,7 +388,7 @@ public class HierarchicalData : IHierarchicalData
return _childDataMap[dataSourceGuid];
}
return new List<IHierarchicalData>();
return [];
}
public bool TryAddChildData(Guid datasourceGuid, IEnumerable<IHierarchicalData> data)
@@ -114,7 +114,7 @@ public static class ArrayUtils
{
if (string.IsNullOrEmpty(csv))
{
return new List<Guid>();
return [];
}
try
@@ -392,7 +392,7 @@ public static class ArrayUtils
{
if (string.IsNullOrEmpty(guidListAsString))
{
return new List<Guid>();
return [];
}
var list = new List<Guid>();
@@ -61,8 +61,8 @@ public static partial class SqlUtils
/// </summary>
/// <returns>A list of system schema names.</returns>
public static List<string> GetSystemSchemas()
=> new List<string>
{
=>
[
DEFAULT_SCHEMA,
"int", // integration
"perf",
@@ -73,6 +73,6 @@ public static partial class SqlUtils
"upg",
"irc", // irc chat rooms
"migration"
};
];
}
@@ -450,13 +450,13 @@ public static partial class SqlUtils
/// </summary>
/// <returns>An enumerable collection of SQL data types suitable for identity columns.</returns>
public static IEnumerable<SqlDataType> IdentityColumnTypes()
=> new List<SqlDataType>
{
=>
[
SqlDataType.BigInt,
SqlDataType.TinyInt,
SqlDataType.Int,
SqlDataType.SmallInt
};
];
/// <summary>
/// Gets the SQL sort direction string for a given sort direction enumeration.