Skip to content

Commit 4f7cdf9

Browse files
committed
Off-topic: Replace ArgumentValidator checks with built-in
1 parent db586ac commit 4f7cdf9

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

Orm/Xtensive.Orm/Sql/SqlDml.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,15 @@ public static SqlBinary DateTimePlusInterval(SqlExpression left, SqlExpression r
636636

637637
public static SqlBinary TimePlusInterval(SqlExpression left, SqlExpression right)
638638
{
639-
ArgumentValidator.EnsureArgumentNotNull(left, "left");
640-
ArgumentValidator.EnsureArgumentNotNull(right, "right");
639+
ArgumentNullException.ThrowIfNull(left, nameof(left));
640+
ArgumentNullException.ThrowIfNull(right, nameof(right));
641641
return new SqlBinary(SqlNodeType.TimePlusInterval, left, right);
642642
}
643643

644644
public static SqlBinary TimeMinusTime(SqlExpression left, SqlExpression right)
645645
{
646-
ArgumentValidator.EnsureArgumentNotNull(left, "left");
647-
ArgumentValidator.EnsureArgumentNotNull(right, "right");
646+
ArgumentNullException.ThrowIfNull(left, nameof(left));
647+
ArgumentNullException.ThrowIfNull(right, nameof(right));
648648
return new SqlBinary(SqlNodeType.TimeMinusTime, left, right);
649649
}
650650
#endif
@@ -680,78 +680,80 @@ public static SqlFunctionCall DateTimeAddMonths(SqlExpression source, SqlExpress
680680
#if NET6_0_OR_GREATER
681681
public static SqlFunctionCall DateTimeToTime(SqlExpression expression)
682682
{
683-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
683+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
684684
return new SqlFunctionCall(SqlFunctionType.DateTimeToTime, expression);
685685
}
686686

687687
public static SqlFunctionCall DateAddYears(SqlExpression source, SqlExpression years)
688688
{
689-
ArgumentValidator.EnsureArgumentNotNull(source, "source");
690-
ArgumentValidator.EnsureArgumentNotNull(years, "years");
689+
ArgumentNullException.ThrowIfNull(source, nameof(source));
690+
ArgumentNullException.ThrowIfNull(years, nameof(years));
691691
return new SqlFunctionCall(SqlFunctionType.DateAddYears, source, years);
692692
}
693693

694694
public static SqlFunctionCall DateAddMonths(SqlExpression source, SqlExpression months)
695695
{
696-
ArgumentValidator.EnsureArgumentNotNull(source, "source");
697-
ArgumentValidator.EnsureArgumentNotNull(months, "months");
696+
ArgumentNullException.ThrowIfNull(source, nameof(source));
697+
ArgumentNullException.ThrowIfNull(months, nameof(months));
698698
return new SqlFunctionCall(SqlFunctionType.DateAddMonths, source, months);
699699
}
700700

701701
public static SqlFunctionCall DateAddDays(SqlExpression source, SqlExpression days)
702702
{
703-
ArgumentValidator.EnsureArgumentNotNull(source, "source");
704-
ArgumentValidator.EnsureArgumentNotNull(days, "days");
703+
ArgumentNullException.ThrowIfNull(source, nameof(source));
704+
ArgumentNullException.ThrowIfNull(days, nameof(days));
705705
return new SqlFunctionCall(SqlFunctionType.DateAddDays, source, days);
706706
}
707707

708708
public static SqlFunctionCall DateToString(SqlExpression expression)
709709
{
710-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
710+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
711711
return new SqlFunctionCall(SqlFunctionType.DateToString, expression);
712712
}
713713

714714
public static SqlFunctionCall DateToDateTime(SqlExpression expression)
715715
{
716-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
716+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
717717
return new SqlFunctionCall(SqlFunctionType.DateToDateTime, expression);
718718
}
719719

720720
public static SqlFunctionCall DateTimeToDate(SqlExpression expression)
721721
{
722-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
722+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
723723
return new SqlFunctionCall(SqlFunctionType.DateTimeToDate, expression);
724724
}
725725

726726
public static SqlFunctionCall DateToDateTimeOffset(SqlExpression expression)
727727
{
728-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
728+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
729729
return new SqlFunctionCall(SqlFunctionType.DateToDateTimeOffset, expression);
730730
}
731731

732732
public static SqlFunctionCall TimeAddHours(SqlExpression source, SqlExpression hours)
733733
{
734734
ArgumentValidator.EnsureArgumentNotNull(source, "source");
735735
ArgumentValidator.EnsureArgumentNotNull(hours, "hours");
736+
ArgumentNullException.ThrowIfNull(source, nameof(source));
737+
ArgumentNullException.ThrowIfNull(hours, nameof(hours));
736738
return new SqlFunctionCall(SqlFunctionType.TimeAddHours, source, hours);
737739
}
738740

739741
public static SqlFunctionCall TimeAddMinutes(SqlExpression source, SqlExpression minutes)
740742
{
741-
ArgumentValidator.EnsureArgumentNotNull(source, "source");
742-
ArgumentValidator.EnsureArgumentNotNull(minutes, "minutes");
743+
ArgumentNullException.ThrowIfNull(source, nameof(source));
744+
ArgumentNullException.ThrowIfNull(minutes, nameof(minutes));
743745
return new SqlFunctionCall(SqlFunctionType.TimeAddMinutes, source, minutes);
744746
}
745747

746748
public static SqlFunctionCall TimeToString(SqlExpression expression)
747749
{
748-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
750+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
749751
return new SqlFunctionCall(SqlFunctionType.TimeToString, expression);
750752
}
751753

752754
public static SqlFunctionCall TimeToDateTime(SqlExpression expression)
753755
{
754-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
756+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
755757
return new SqlFunctionCall(SqlFunctionType.TimeToDateTime, expression);
756758
}
757759

@@ -763,7 +765,7 @@ public static SqlExpression TimeToNanoseconds(SqlExpression source)
763765

764766
public static SqlFunctionCall TimeToDateTimeOffset(SqlExpression expression)
765767
{
766-
ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
768+
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
767769
return new SqlFunctionCall(SqlFunctionType.TimeToDateTimeOffset, expression);
768770
}
769771
#endif
@@ -904,13 +906,14 @@ public static SqlFunctionCall DateTimeOffsetToDateTime(SqlExpression dateTimeOff
904906

905907
public static SqlFunctionCall DateTimeOffsetToTime(SqlExpression dateTimeOffset)
906908
{
907-
ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, nameof(dateTimeOffset));
909+
ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset));
908910
return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToTime, dateTimeOffset);
909911
}
910912

911913
public static SqlFunctionCall DateTimeOffsetToDate(SqlExpression dateTimeOffset)
912914
{
913915
ArgumentValidator.EnsureArgumentNotNull(dateTimeOffset, nameof(dateTimeOffset));
916+
ArgumentNullException.ThrowIfNull(dateTimeOffset, nameof(dateTimeOffset));
914917
return new SqlFunctionCall(SqlFunctionType.DateTimeOffsetToDate, dateTimeOffset);
915918
}
916919
#endif

0 commit comments

Comments
 (0)