mirror of
https://github.com/CommunityToolkit/dotnet.git
synced 2026-10-29 03:27:07 +08:00
Parameterless ThrowHelper APIs (#3550)
<!-- 🚨 Please Do Not skip any instructions and information mentioned below as they are all required and essential to evaluate and test the PR. By fulfilling all the required information you will be able to reduce the volume of questions and most likely help merge the PR faster 🚨 --> ## Follow up for #3346 and #3455 <!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. --> <!-- Add a brief overview here of the feature/bug & fix. --> ## PR Type What kind of change does this PR introduce? <!-- Please uncomment one or more that apply to this PR. --> <!-- - Bugfix --> - Feature <!-- - Code style update (formatting) --> <!-- - Refactoring (no functional changes, no api changes) --> <!-- - Build or CI related changes --> <!-- - Documentation content changes --> <!-- - Sample app changes --> <!-- - Other... Please describe: --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> The `ThrowHelper` class exposes static throw-helper APIs that mirror the existing constructor for all the supported exception types. In the previous PRs though I had missed the parameterless constructors, so there were no APIs for that in the `ThrowHelper` class. ## What is the new behavior? <!-- Describe how was this issue resolved or changed? --> `ThrowHelper` now exposes a parameterless overload for all the supported exception types that are exposed. ## PR Checklist Please check if your PR fulfills the following requirements: - [X] Tested code with current [supported SDKs](../readme.md#supported) - [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->~~ - [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~ - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~ - [X] Tests for the changes have been added (for bug fixes / features) (if applicable) - [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*) - [X] Contains **NO** breaking changes
This commit is contained in:
@@ -20,6 +20,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
/// </summary>
|
||||
public static partial class ThrowHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArrayTypeMismatchException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="ArrayTypeMismatchException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowArrayTypeMismatchException<T>()
|
||||
{
|
||||
throw new ArrayTypeMismatchException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArrayTypeMismatchException"/>.
|
||||
/// </summary>
|
||||
@@ -47,6 +59,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArrayTypeMismatchException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="ArgumentException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowArgumentException<T>()
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
@@ -103,6 +127,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArgumentException(message, name, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentNullException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="ArgumentNullException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowArgumentNullException<T>()
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentNullException"/>.
|
||||
/// </summary>
|
||||
@@ -144,6 +180,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArgumentNullException(name, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowArgumentOutOfRangeException<T>()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
@@ -201,6 +249,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
|
||||
#if !NETSTANDARD1_4
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="COMException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="COMException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowCOMException<T>()
|
||||
{
|
||||
throw new COMException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="COMException"/>.
|
||||
/// </summary>
|
||||
@@ -242,6 +302,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new COMException(message, error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ExternalException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="ExternalException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowExternalException<T>()
|
||||
{
|
||||
throw new ExternalException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ExternalException"/>.
|
||||
/// </summary>
|
||||
@@ -284,6 +356,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="FormatException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="FormatException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowFormatException<T>()
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="FormatException"/>.
|
||||
/// </summary>
|
||||
@@ -312,6 +396,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
|
||||
#if !NETSTANDARD1_4
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InsufficientMemoryException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="InsufficientMemoryException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowInsufficientMemoryException<T>()
|
||||
{
|
||||
throw new InsufficientMemoryException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InsufficientMemoryException"/>.
|
||||
/// </summary>
|
||||
@@ -340,6 +436,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidDataException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="InvalidDataException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowInvalidDataException<T>()
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidDataException"/>.
|
||||
/// </summary>
|
||||
@@ -367,6 +475,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new InvalidDataException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="InvalidOperationException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowInvalidOperationException<T>()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
@@ -394,6 +514,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new InvalidOperationException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="LockRecursionException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="LockRecursionException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowLockRecursionException<T>()
|
||||
{
|
||||
throw new LockRecursionException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="LockRecursionException"/>.
|
||||
/// </summary>
|
||||
@@ -421,6 +553,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new LockRecursionException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingFieldException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="MissingFieldException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowMissingFieldException<T>()
|
||||
{
|
||||
throw new MissingFieldException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingFieldException"/>.
|
||||
/// </summary>
|
||||
@@ -464,6 +608,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMemberException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="MissingMemberException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowMissingMemberException<T>()
|
||||
{
|
||||
throw new MissingMemberException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMemberException"/>.
|
||||
/// </summary>
|
||||
@@ -507,6 +663,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMethodException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="MissingMethodException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowMissingMethodException<T>()
|
||||
{
|
||||
throw new MissingMethodException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMethodException"/>.
|
||||
/// </summary>
|
||||
@@ -550,6 +718,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="NotSupportedException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowNotSupportedException<T>()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
@@ -618,6 +798,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ObjectDisposedException(objectName, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="OperationCanceledException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="OperationCanceledException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowOperationCanceledException<T>()
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="OperationCanceledException"/>.
|
||||
/// </summary>
|
||||
@@ -687,6 +879,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new OperationCanceledException(message, innerException, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="PlatformNotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="PlatformNotSupportedException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowPlatformNotSupportedException<T>()
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="PlatformNotSupportedException"/>.
|
||||
/// </summary>
|
||||
@@ -714,6 +918,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new PlatformNotSupportedException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="SynchronizationLockException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="SynchronizationLockException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowSynchronizationLockException<T>()
|
||||
{
|
||||
throw new SynchronizationLockException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="SynchronizationLockException"/>.
|
||||
/// </summary>
|
||||
@@ -741,6 +957,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new SynchronizationLockException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="TimeoutException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="TimeoutException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowTimeoutException<T>()
|
||||
{
|
||||
throw new TimeoutException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="TimeoutException"/>.
|
||||
/// </summary>
|
||||
@@ -768,6 +996,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new TimeoutException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="UnauthorizedAccessException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="UnauthorizedAccessException">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowUnauthorizedAccessException<T>()
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="UnauthorizedAccessException"/>.
|
||||
/// </summary>
|
||||
@@ -795,6 +1035,18 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new UnauthorizedAccessException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <exception cref="Win32Exception">Thrown with no parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowWin32Exception<T>()
|
||||
{
|
||||
throw new Win32Exception();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
/// </summary>
|
||||
public static partial class ThrowHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArrayTypeMismatchException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArrayTypeMismatchException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArrayTypeMismatchException()
|
||||
{
|
||||
throw new ArrayTypeMismatchException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArrayTypeMismatchException"/>.
|
||||
/// </summary>
|
||||
@@ -43,6 +53,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArrayTypeMismatchException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentException()
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
@@ -91,6 +111,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArgumentException(message, name, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentNullException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentNullException()
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentNullException"/>.
|
||||
/// </summary>
|
||||
@@ -126,6 +156,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ArgumentNullException(name, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentOutOfRangeException()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
@@ -175,6 +215,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
|
||||
#if !NETSTANDARD1_4
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="COMException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="COMException">Thrown with no paarameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowCOMException()
|
||||
{
|
||||
throw new COMException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="COMException"/>.
|
||||
/// </summary>
|
||||
@@ -210,6 +260,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new COMException(message, error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ExternalException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ExternalException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowExternalException()
|
||||
{
|
||||
throw new ExternalException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ExternalException"/>.
|
||||
/// </summary>
|
||||
@@ -246,6 +306,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="FormatException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="FormatException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowFormatException()
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="FormatException"/>.
|
||||
/// </summary>
|
||||
@@ -270,6 +340,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
|
||||
#if !NETSTANDARD1_4
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InsufficientMemoryException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="InsufficientMemoryException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowInsufficientMemoryException()
|
||||
{
|
||||
throw new InsufficientMemoryException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InsufficientMemoryException"/>.
|
||||
/// </summary>
|
||||
@@ -294,6 +374,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidDataException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidDataException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowInvalidDataException()
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidDataException"/>.
|
||||
/// </summary>
|
||||
@@ -317,6 +407,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new InvalidDataException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowInvalidOperationException()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
@@ -340,6 +440,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new InvalidOperationException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="LockRecursionException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="LockRecursionException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowLockRecursionException()
|
||||
{
|
||||
throw new LockRecursionException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="LockRecursionException"/>.
|
||||
/// </summary>
|
||||
@@ -363,6 +473,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new LockRecursionException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingFieldException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="MissingFieldException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowMissingFieldException()
|
||||
{
|
||||
throw new MissingFieldException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingFieldException"/>.
|
||||
/// </summary>
|
||||
@@ -400,6 +520,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMemberException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="MissingMemberException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowMissingMemberException()
|
||||
{
|
||||
throw new MissingMemberException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMemberException"/>.
|
||||
/// </summary>
|
||||
@@ -437,6 +567,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMethodException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="MissingMethodException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowMissingMethodException()
|
||||
{
|
||||
throw new MissingMethodException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="MissingMethodException"/>.
|
||||
/// </summary>
|
||||
@@ -474,6 +614,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowNotSupportedException()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
@@ -532,6 +682,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new ObjectDisposedException(objectName, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="OperationCanceledException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="OperationCanceledException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowOperationCanceledException()
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="OperationCanceledException"/>.
|
||||
/// </summary>
|
||||
@@ -591,6 +751,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new OperationCanceledException(message, innerException, token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="PlatformNotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="PlatformNotSupportedException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowPlatformNotSupportedException()
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="PlatformNotSupportedException"/>.
|
||||
/// </summary>
|
||||
@@ -614,6 +784,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new PlatformNotSupportedException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="SynchronizationLockException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="SynchronizationLockException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowSynchronizationLockException()
|
||||
{
|
||||
throw new SynchronizationLockException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="SynchronizationLockException"/>.
|
||||
/// </summary>
|
||||
@@ -637,6 +817,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new SynchronizationLockException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="TimeoutException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="TimeoutException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowTimeoutException()
|
||||
{
|
||||
throw new TimeoutException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="TimeoutException"/>.
|
||||
/// </summary>
|
||||
@@ -660,6 +850,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new TimeoutException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="UnauthorizedAccessException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="UnauthorizedAccessException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowUnauthorizedAccessException()
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="UnauthorizedAccessException"/>.
|
||||
/// </summary>
|
||||
@@ -683,6 +883,16 @@ namespace Microsoft.Toolkit.Diagnostics
|
||||
throw new UnauthorizedAccessException(message, innerException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="Win32Exception">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowWin32Exception()
|
||||
{
|
||||
throw new Win32Exception();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user