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:
co-authored by
Claude Opus 4.7
parent
2c2a8b1193
commit
8b7fc1a327
@@ -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>
|
||||
{
|
||||
|
||||
@@ -18,10 +18,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new LinqQueryBreakdown with the same clauses.</returns>
|
||||
public static LinqQueryBreakdown ToLinqQueryBreakdown(this QueryBreakdown breakdown)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
var linq = new LinqQueryBreakdown(
|
||||
breakdown.SelectClause?.Clause ?? "*",
|
||||
@@ -54,10 +51,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new LinqQueryBreakdown with the same clauses.</returns>
|
||||
public static LinqQueryBreakdown ToLinqQueryBreakdown(this PostgreSqlBreakdown breakdown)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
var linq = new LinqQueryBreakdown(
|
||||
breakdown.SelectClause?.Clause ?? "*",
|
||||
@@ -90,10 +84,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new LinqQueryBreakdown with the same clauses.</returns>
|
||||
public static LinqQueryBreakdown ToLinqQueryBreakdown(this SnowflakeBreakdown breakdown)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
var linq = new LinqQueryBreakdown(
|
||||
breakdown.SelectClause?.Clause ?? "*",
|
||||
@@ -127,10 +118,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new breakdown in the target dialect format.</returns>
|
||||
public static object ConvertToDialect(this QueryBreakdown breakdown, string targetDialect)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
return targetDialect.ToLowerInvariant() switch
|
||||
{
|
||||
@@ -150,10 +138,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new breakdown in the target dialect format.</returns>
|
||||
public static object ConvertToDialect(this PostgreSqlBreakdown breakdown, string targetDialect)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
return targetDialect.ToLowerInvariant() switch
|
||||
{
|
||||
@@ -173,10 +158,7 @@ public static class ReverseConverterExtensions
|
||||
/// <returns>A new breakdown in the target dialect format.</returns>
|
||||
public static object ConvertToDialect(this SnowflakeBreakdown breakdown, string targetDialect)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
return targetDialect.ToLowerInvariant() switch
|
||||
{
|
||||
|
||||
@@ -71,10 +71,7 @@ public class QueryValidator
|
||||
/// <returns>This validator for method chaining.</returns>
|
||||
public QueryValidator Validate(LinqQueryBreakdown breakdown)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
_issues.Clear();
|
||||
|
||||
|
||||
@@ -88,10 +88,7 @@ public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
|
||||
/// <exception cref="ArgumentNullException">Thrown when breakdown is null.</exception>
|
||||
public void Add(ISqlBreakdown breakdown)
|
||||
{
|
||||
if (breakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdown);
|
||||
|
||||
_breakdowns.Add(breakdown);
|
||||
}
|
||||
@@ -103,10 +100,7 @@ public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
|
||||
/// <exception cref="ArgumentNullException">Thrown when breakdowns is null.</exception>
|
||||
public void AddRange(IEnumerable<ISqlBreakdown> breakdowns)
|
||||
{
|
||||
if (breakdowns == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(breakdowns));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(breakdowns);
|
||||
|
||||
_breakdowns.AddRange(breakdowns);
|
||||
}
|
||||
@@ -142,10 +136,7 @@ public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
|
||||
/// <exception cref="ArgumentNullException">Thrown when sqlBatch is null.</exception>
|
||||
public void ParseBatch(string sqlBatch, string? separator = null)
|
||||
{
|
||||
if (sqlBatch == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(sqlBatch));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(sqlBatch);
|
||||
|
||||
Clear();
|
||||
|
||||
|
||||
@@ -269,10 +269,7 @@ public static class FlatDataUtils
|
||||
|
||||
public static object GetValue(this IFlatData data, string key)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (!data.ContainsKey(key))
|
||||
{
|
||||
|
||||
@@ -51,10 +51,7 @@ public abstract class QueryBreakdownCollectionBase<TQuery> : SqlBreakdownCollect
|
||||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="queryBreakdown"/> is null.</exception>
|
||||
public void Add(TQuery queryBreakdown)
|
||||
{
|
||||
if (queryBreakdown == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(queryBreakdown));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(queryBreakdown);
|
||||
|
||||
QueryBreakdownList.Add(queryBreakdown);
|
||||
base.Add(queryBreakdown);
|
||||
@@ -67,10 +64,7 @@ public abstract class QueryBreakdownCollectionBase<TQuery> : SqlBreakdownCollect
|
||||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="queryBreakdowns"/> is null.</exception>
|
||||
public void AddRange(IEnumerable<TQuery> queryBreakdowns)
|
||||
{
|
||||
if (queryBreakdowns == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(queryBreakdowns));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(queryBreakdowns);
|
||||
|
||||
foreach (var breakdown in queryBreakdowns)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user