Remove ThrowHelper APIs in D2D1 projects, switch to new extensions
このコミットが含まれているのは:
1 親
5a4fd9a4ce
コミット
92fbf75185
17ファイル変更
+87
-194
検索条件に一致するファイルはありません
@@ -20,6 +20,19 @@ internal static class ArgumentExceptionExtensions
|
||||
throw new ArgumentException(null, parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name and message.
|
||||
/// </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>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this ArgumentException? _, string? parameterName, string? message)
|
||||
{
|
||||
throw new ArgumentException(message, parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,19 @@ namespace System;
|
||||
/// </summary>
|
||||
internal static class InvalidOperationExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> 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>
|
||||
/// <returns>This method never returns any values.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static T Throw<T>(this InvalidOperationException? _)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
@@ -30,4 +31,28 @@ internal static class NotSupportedExceptionExtensions
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this NotSupportedException? _, [DoesNotReturnIf(true)] bool condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">Always thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする