Skip to content

Commit 85a87fb

Browse files
committed
updated vectorized Max()
1 parent f52af1e commit 85a87fb

File tree

2 files changed

+149
-42
lines changed

2 files changed

+149
-42
lines changed

src/ExceptionHelpers.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,24 @@ internal static void ThrowIfNegative(int value,
139139
}
140140
#endif
141141

142+
internal static void ThrowIfNull([NotNull] object? value,
143+
#if NET8_0_OR_GREATER
144+
[CallerArgumentExpression(nameof(value))]
145+
#endif
146+
string? paramName = null)
147+
{
148+
if(value is null)
149+
{
150+
ThrowNull(value, paramName);
151+
}
152+
}
153+
142154
[DoesNotReturn]
143155
static void ThrowGreaterThanOrEqual<T>(T value, T other, string? paramName)
144156
{
145157
throw new ArgumentOutOfRangeException(paramName, value, $"{paramName} ('{value}') must be less than '{other}'. (Parameter '{paramName}')");
146158
}
159+
147160
[DoesNotReturn]
148161
static void ThrowLessThan<T>(T value, T other, string? paramName)
149162
{
@@ -155,4 +168,10 @@ static void ThrowNegative<T>(T value, string? paramName)
155168
{
156169
throw new ArgumentOutOfRangeException(paramName, value, $"{paramName} ('{value}') must be a non-negative value. (Parameter '{paramName}')");
157170
}
171+
172+
[DoesNotReturn]
173+
static void ThrowNull(object? value, string? paramName)
174+
{
175+
throw new ArgumentNullException(paramName);
176+
}
158177
}

0 commit comments

Comments
 (0)