Migrate ArgumentException/InvalidOperationException throw helpers

このコミットが含まれているのは:
Sergio Pedri committed 2023-02-25 18:00:08 +01:00
1 親 e27fb13a01
コミット fe41277fe7
13ファイル変更
+77 -51

検索条件に一致するファイルはありません

+27 -1
ファイルの表示
@@ -8,6 +8,32 @@ namespace System;
/// </summary>
internal static class ArgumentExceptionExtensions
{
/// <summary>
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
/// </summary>
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
[DoesNotReturn]
public static void Throw(this ArgumentException? _, string? parameterName)
{
throw new ArgumentException(null, parameterName);
}
/// <summary>
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
/// </summary>
/// <typeparam name="T">The type to let the compiler assume it returns.</typeparam>
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
/// <returns>This method never returns any values.</returns>
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
[DoesNotReturn]
public static T Throw<T>(this ArgumentException? _, string? parameterName)
{
throw new ArgumentException(null, parameterName);
}
/// <summary>
/// Throws an <see cref="ArgumentException"/> if <paramref name="condition"/> is <see langword="true"/>.
/// </summary>
@@ -31,6 +57,6 @@ internal static class ArgumentExceptionExtensions
[DoesNotReturn]
private static void Throw(string? parameterName)
{
throw new ArgumentException(parameterName);
throw new ArgumentException(null, parameterName);
}
}