chore(sonar): use ArgumentNullException.ThrowIfNull (CA1510)

Applied via `dotnet format analyzers --diagnostics CA1510 --severity info`.
Replaces `if (x == null) throw new ArgumentNullException(nameof(x));`
blocks with the one-line `ArgumentNullException.ThrowIfNull(x);` —
same behavior, same parameter name, much less noise.

6 files touched across SqlBreakdown, SqlServer, LinqToSql.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thom Lamb
2026-05-26 15:39:49 -05:00
co-authored by Claude Opus 4.7
parent 2c2a8b1193
commit 8b7fc1a327
6 changed files with 19 additions and 76 deletions
@@ -71,10 +71,7 @@ public class LinqQueryBreakdown : QueryBreakdown
/// <returns>A LinqQueryBreakdown representing the query structure.</returns>
public static LinqQueryBreakdown Analyze<T>(IQueryable<T> query)
{
if (query == null)
{
throw new ArgumentNullException(nameof(query));
}
ArgumentNullException.ThrowIfNull(query);
var breakdown = new LinqQueryBreakdown
{
@@ -232,10 +229,7 @@ public class LinqQueryBreakdown : QueryBreakdown
/// <returns>An InsertBreakdown representing the insert operation.</returns>
public static Breakdowns.SqlServer.InsertBreakdown AnalyzeInsert<T>(T entity) where T : class
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
ArgumentNullException.ThrowIfNull(entity);
var breakdown = new Breakdowns.SqlServer.InsertBreakdown();
breakdown.TableName.Clause = typeof(T).Name;
@@ -312,10 +306,7 @@ public class LinqQueryBreakdown : QueryBreakdown
/// <returns>A DeleteBreakdown representing the delete operation.</returns>
public static Breakdowns.SqlServer.DeleteBreakdown AnalyzeDelete<T>(Expression<Func<T, bool>> filterExpression) where T : class
{
if (filterExpression == null)
{
throw new ArgumentNullException(nameof(filterExpression));
}
ArgumentNullException.ThrowIfNull(filterExpression);
var breakdown = new Breakdowns.SqlServer.DeleteBreakdown();
breakdown.FromClause.Clause = typeof(T).Name;
@@ -343,14 +334,8 @@ public class LinqQueryBreakdown : QueryBreakdown
Expression<Func<T, bool>> filterExpression,
Expression<Func<T, T>> updateExpression) where T : class
{
if (filterExpression == null)
{
throw new ArgumentNullException(nameof(filterExpression));
}
if (updateExpression == null)
{
throw new ArgumentNullException(nameof(updateExpression));
}
ArgumentNullException.ThrowIfNull(filterExpression);
ArgumentNullException.ThrowIfNull(updateExpression);
var breakdown = new Breakdowns.SqlServer.UpdateBreakdown();
breakdown.TableName.Clause = typeof(T).Name;
@@ -425,10 +410,7 @@ public class LinqQueryBreakdown : QueryBreakdown
/// <returns>A string representation of the trace analysis.</returns>
public static string AnalyzeTrace<T>(IQueryable<T> query, string? executionContext = null) where T : class
{
if (query == null)
{
throw new ArgumentNullException(nameof(query));
}
ArgumentNullException.ThrowIfNull(query);
var lines = new List<string>
{