diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Generic.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Generic.cs
index a4f0dcb7245..680972dada4 100644
--- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Generic.cs
+++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Generic.cs
@@ -20,6 +20,18 @@ namespace Microsoft.Toolkit.Diagnostics
///
public static partial class ThrowHelper
{
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowArrayTypeMismatchException()
+ {
+ throw new ArrayTypeMismatchException();
+ }
+
///
/// Throws a new .
///
@@ -47,6 +59,18 @@ public static T ThrowArrayTypeMismatchException(string message, Exception inn
throw new ArrayTypeMismatchException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowArgumentException()
+ {
+ throw new ArgumentException();
+ }
+
///
/// Throws a new .
///
@@ -103,6 +127,18 @@ public static T ThrowArgumentException(string name, string message, Exception
throw new ArgumentException(message, name, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowArgumentNullException()
+ {
+ throw new ArgumentNullException();
+ }
+
///
/// Throws a new .
///
@@ -144,6 +180,18 @@ public static T ThrowArgumentNullException(string name, string message)
throw new ArgumentNullException(name, message);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowArgumentOutOfRangeException()
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+
///
/// Throws a new .
///
@@ -201,6 +249,18 @@ public static T ThrowArgumentOutOfRangeException(string name, object value, s
}
#if !NETSTANDARD1_4
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowCOMException()
+ {
+ throw new COMException();
+ }
+
///
/// Throws a new .
///
@@ -242,6 +302,18 @@ public static T ThrowCOMException(string message, int error)
throw new COMException(message, error);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowExternalException()
+ {
+ throw new ExternalException();
+ }
+
///
/// Throws a new .
///
@@ -284,6 +356,18 @@ public static T ThrowExternalException(string message, int error)
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowFormatException()
+ {
+ throw new FormatException();
+ }
+
///
/// Throws a new .
///
@@ -312,6 +396,18 @@ public static T ThrowFormatException(string message, Exception innerException
}
#if !NETSTANDARD1_4
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowInsufficientMemoryException()
+ {
+ throw new InsufficientMemoryException();
+ }
+
///
/// Throws a new .
///
@@ -340,6 +436,18 @@ public static T ThrowInsufficientMemoryException(string message, Exception in
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowInvalidDataException()
+ {
+ throw new InvalidDataException();
+ }
+
///
/// Throws a new .
///
@@ -367,6 +475,18 @@ public static T ThrowInvalidDataException(string message, Exception innerExce
throw new InvalidDataException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowInvalidOperationException()
+ {
+ throw new InvalidOperationException();
+ }
+
///
/// Throws a new .
///
@@ -394,6 +514,18 @@ public static T ThrowInvalidOperationException(string message, Exception inne
throw new InvalidOperationException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowLockRecursionException()
+ {
+ throw new LockRecursionException();
+ }
+
///
/// Throws a new .
///
@@ -421,6 +553,18 @@ public static T ThrowLockRecursionException(string message, Exception innerEx
throw new LockRecursionException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowMissingFieldException()
+ {
+ throw new MissingFieldException();
+ }
+
///
/// Throws a new .
///
@@ -464,6 +608,18 @@ public static T ThrowMissingFieldException(string className, string fieldName
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowMissingMemberException()
+ {
+ throw new MissingMemberException();
+ }
+
///
/// Throws a new .
///
@@ -507,6 +663,18 @@ public static T ThrowMissingMemberException(string className, string memberNa
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowMissingMethodException()
+ {
+ throw new MissingMethodException();
+ }
+
///
/// Throws a new .
///
@@ -550,6 +718,18 @@ public static T ThrowMissingMethodException(string className, string methodNa
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowNotSupportedException()
+ {
+ throw new NotSupportedException();
+ }
+
///
/// Throws a new .
///
@@ -618,6 +798,18 @@ public static T ThrowObjectDisposedException(string objectName, string messag
throw new ObjectDisposedException(objectName, message);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowOperationCanceledException()
+ {
+ throw new OperationCanceledException();
+ }
+
///
/// Throws a new .
///
@@ -687,6 +879,18 @@ public static T ThrowOperationCanceledException(string message, Exception inn
throw new OperationCanceledException(message, innerException, token);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowPlatformNotSupportedException()
+ {
+ throw new PlatformNotSupportedException();
+ }
+
///
/// Throws a new .
///
@@ -714,6 +918,18 @@ public static T ThrowPlatformNotSupportedException(string message, Exception
throw new PlatformNotSupportedException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowSynchronizationLockException()
+ {
+ throw new SynchronizationLockException();
+ }
+
///
/// Throws a new .
///
@@ -741,6 +957,18 @@ public static T ThrowSynchronizationLockException(string message, Exception i
throw new SynchronizationLockException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowTimeoutException()
+ {
+ throw new TimeoutException();
+ }
+
///
/// Throws a new .
///
@@ -768,6 +996,18 @@ public static T ThrowTimeoutException(string message, Exception innerExceptio
throw new TimeoutException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowUnauthorizedAccessException()
+ {
+ throw new UnauthorizedAccessException();
+ }
+
///
/// Throws a new .
///
@@ -795,6 +1035,18 @@ public static T ThrowUnauthorizedAccessException(string message, Exception in
throw new UnauthorizedAccessException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// The type of expected result.
+ /// Thrown with no parameters.
+ /// This method always throws, so it actually never returns a value.
+ [DoesNotReturn]
+ public static T ThrowWin32Exception()
+ {
+ throw new Win32Exception();
+ }
+
///
/// Throws a new .
///
diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs
index 516301b434e..152ce08e426 100644
--- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs
+++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs
@@ -20,6 +20,16 @@ namespace Microsoft.Toolkit.Diagnostics
///
public static partial class ThrowHelper
{
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowArrayTypeMismatchException()
+ {
+ throw new ArrayTypeMismatchException();
+ }
+
///
/// Throws a new .
///
@@ -43,6 +53,16 @@ public static void ThrowArrayTypeMismatchException(string message, Exception inn
throw new ArrayTypeMismatchException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowArgumentException()
+ {
+ throw new ArgumentException();
+ }
+
///
/// Throws a new .
///
@@ -91,6 +111,16 @@ public static void ThrowArgumentException(string name, string message, Exception
throw new ArgumentException(message, name, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowArgumentNullException()
+ {
+ throw new ArgumentNullException();
+ }
+
///
/// Throws a new .
///
@@ -126,6 +156,16 @@ public static void ThrowArgumentNullException(string name, string message)
throw new ArgumentNullException(name, message);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowArgumentOutOfRangeException()
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+
///
/// Throws a new .
///
@@ -175,6 +215,16 @@ public static void ThrowArgumentOutOfRangeException(string name, object value, s
}
#if !NETSTANDARD1_4
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no paarameters.
+ [DoesNotReturn]
+ public static void ThrowCOMException()
+ {
+ throw new COMException();
+ }
+
///
/// Throws a new .
///
@@ -210,6 +260,16 @@ public static void ThrowCOMException(string message, int error)
throw new COMException(message, error);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowExternalException()
+ {
+ throw new ExternalException();
+ }
+
///
/// Throws a new .
///
@@ -246,6 +306,16 @@ public static void ThrowExternalException(string message, int error)
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowFormatException()
+ {
+ throw new FormatException();
+ }
+
///
/// Throws a new .
///
@@ -270,6 +340,16 @@ public static void ThrowFormatException(string message, Exception innerException
}
#if !NETSTANDARD1_4
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowInsufficientMemoryException()
+ {
+ throw new InsufficientMemoryException();
+ }
+
///
/// Throws a new .
///
@@ -294,6 +374,16 @@ public static void ThrowInsufficientMemoryException(string message, Exception in
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowInvalidDataException()
+ {
+ throw new InvalidDataException();
+ }
+
///
/// Throws a new .
///
@@ -317,6 +407,16 @@ public static void ThrowInvalidDataException(string message, Exception innerExce
throw new InvalidDataException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowInvalidOperationException()
+ {
+ throw new InvalidOperationException();
+ }
+
///
/// Throws a new .
///
@@ -340,6 +440,16 @@ public static void ThrowInvalidOperationException(string message, Exception inne
throw new InvalidOperationException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowLockRecursionException()
+ {
+ throw new LockRecursionException();
+ }
+
///
/// Throws a new .
///
@@ -363,6 +473,16 @@ public static void ThrowLockRecursionException(string message, Exception innerEx
throw new LockRecursionException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowMissingFieldException()
+ {
+ throw new MissingFieldException();
+ }
+
///
/// Throws a new .
///
@@ -400,6 +520,16 @@ public static void ThrowMissingFieldException(string className, string fieldName
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowMissingMemberException()
+ {
+ throw new MissingMemberException();
+ }
+
///
/// Throws a new .
///
@@ -437,6 +567,16 @@ public static void ThrowMissingMemberException(string className, string memberNa
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowMissingMethodException()
+ {
+ throw new MissingMethodException();
+ }
+
///
/// Throws a new .
///
@@ -474,6 +614,16 @@ public static void ThrowMissingMethodException(string className, string methodNa
}
#endif
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowNotSupportedException()
+ {
+ throw new NotSupportedException();
+ }
+
///
/// Throws a new .
///
@@ -532,6 +682,16 @@ public static void ThrowObjectDisposedException(string objectName, string messag
throw new ObjectDisposedException(objectName, message);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowOperationCanceledException()
+ {
+ throw new OperationCanceledException();
+ }
+
///
/// Throws a new .
///
@@ -591,6 +751,16 @@ public static void ThrowOperationCanceledException(string message, Exception inn
throw new OperationCanceledException(message, innerException, token);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowPlatformNotSupportedException()
+ {
+ throw new PlatformNotSupportedException();
+ }
+
///
/// Throws a new .
///
@@ -614,6 +784,16 @@ public static void ThrowPlatformNotSupportedException(string message, Exception
throw new PlatformNotSupportedException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowSynchronizationLockException()
+ {
+ throw new SynchronizationLockException();
+ }
+
///
/// Throws a new .
///
@@ -637,6 +817,16 @@ public static void ThrowSynchronizationLockException(string message, Exception i
throw new SynchronizationLockException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowTimeoutException()
+ {
+ throw new TimeoutException();
+ }
+
///
/// Throws a new .
///
@@ -660,6 +850,16 @@ public static void ThrowTimeoutException(string message, Exception innerExceptio
throw new TimeoutException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowUnauthorizedAccessException()
+ {
+ throw new UnauthorizedAccessException();
+ }
+
///
/// Throws a new .
///
@@ -683,6 +883,16 @@ public static void ThrowUnauthorizedAccessException(string message, Exception in
throw new UnauthorizedAccessException(message, innerException);
}
+ ///
+ /// Throws a new .
+ ///
+ /// Thrown with no parameters.
+ [DoesNotReturn]
+ public static void ThrowWin32Exception()
+ {
+ throw new Win32Exception();
+ }
+
///
/// Throws a new .
///