@@ -20,6 +20,16 @@ namespace Microsoft.Toolkit.Diagnostics
2020 /// </summary>
2121 public static partial class ThrowHelper
2222 {
23+ /// <summary>
24+ /// Throws a new <see cref="ArrayTypeMismatchException"/>.
25+ /// </summary>
26+ /// <exception cref="ArrayTypeMismatchException">Thrown with no parameters.</exception>
27+ [ DoesNotReturn ]
28+ public static void ThrowArrayTypeMismatchException ( )
29+ {
30+ throw new ArrayTypeMismatchException ( ) ;
31+ }
32+
2333 /// <summary>
2434 /// Throws a new <see cref="ArrayTypeMismatchException"/>.
2535 /// </summary>
@@ -43,6 +53,16 @@ public static void ThrowArrayTypeMismatchException(string message, Exception inn
4353 throw new ArrayTypeMismatchException ( message , innerException ) ;
4454 }
4555
56+ /// <summary>
57+ /// Throws a new <see cref="ArgumentException"/>.
58+ /// </summary>
59+ /// <exception cref="ArgumentException">Thrown with no parameters.</exception>
60+ [ DoesNotReturn ]
61+ public static void ThrowArgumentException ( )
62+ {
63+ throw new ArgumentException ( ) ;
64+ }
65+
4666 /// <summary>
4767 /// Throws a new <see cref="ArgumentException"/>.
4868 /// </summary>
@@ -91,6 +111,16 @@ public static void ThrowArgumentException(string name, string message, Exception
91111 throw new ArgumentException ( message , name , innerException ) ;
92112 }
93113
114+ /// <summary>
115+ /// Throws a new <see cref="ArgumentNullException"/>.
116+ /// </summary>
117+ /// <exception cref="ArgumentNullException">Thrown with no parameters.</exception>
118+ [ DoesNotReturn ]
119+ public static void ThrowArgumentNullException ( )
120+ {
121+ throw new ArgumentNullException ( ) ;
122+ }
123+
94124 /// <summary>
95125 /// Throws a new <see cref="ArgumentNullException"/>.
96126 /// </summary>
@@ -126,6 +156,16 @@ public static void ThrowArgumentNullException(string name, string message)
126156 throw new ArgumentNullException ( name , message ) ;
127157 }
128158
159+ /// <summary>
160+ /// Throws a new <see cref="ArgumentOutOfRangeException"/>.
161+ /// </summary>
162+ /// <exception cref="ArgumentOutOfRangeException">Thrown with no parameters.</exception>
163+ [ DoesNotReturn ]
164+ public static void ThrowArgumentOutOfRangeException ( )
165+ {
166+ throw new ArgumentOutOfRangeException ( ) ;
167+ }
168+
129169 /// <summary>
130170 /// Throws a new <see cref="ArgumentOutOfRangeException"/>.
131171 /// </summary>
@@ -175,6 +215,16 @@ public static void ThrowArgumentOutOfRangeException(string name, object value, s
175215 }
176216
177217#if ! NETSTANDARD1_4
218+ /// <summary>
219+ /// Throws a new <see cref="COMException"/>.
220+ /// </summary>
221+ /// <exception cref="COMException">Thrown with no paarameters.</exception>
222+ [ DoesNotReturn ]
223+ public static void ThrowCOMException ( )
224+ {
225+ throw new COMException ( ) ;
226+ }
227+
178228 /// <summary>
179229 /// Throws a new <see cref="COMException"/>.
180230 /// </summary>
@@ -210,6 +260,16 @@ public static void ThrowCOMException(string message, int error)
210260 throw new COMException ( message , error ) ;
211261 }
212262
263+ /// <summary>
264+ /// Throws a new <see cref="ExternalException"/>.
265+ /// </summary>
266+ /// <exception cref="ExternalException">Thrown with no parameters.</exception>
267+ [ DoesNotReturn ]
268+ public static void ThrowExternalException ( )
269+ {
270+ throw new ExternalException ( ) ;
271+ }
272+
213273 /// <summary>
214274 /// Throws a new <see cref="ExternalException"/>.
215275 /// </summary>
@@ -246,6 +306,16 @@ public static void ThrowExternalException(string message, int error)
246306 }
247307#endif
248308
309+ /// <summary>
310+ /// Throws a new <see cref="FormatException"/>.
311+ /// </summary>
312+ /// <exception cref="FormatException">Thrown with no parameters.</exception>
313+ [ DoesNotReturn ]
314+ public static void ThrowFormatException ( )
315+ {
316+ throw new FormatException ( ) ;
317+ }
318+
249319 /// <summary>
250320 /// Throws a new <see cref="FormatException"/>.
251321 /// </summary>
@@ -270,6 +340,16 @@ public static void ThrowFormatException(string message, Exception innerException
270340 }
271341
272342#if ! NETSTANDARD1_4
343+ /// <summary>
344+ /// Throws a new <see cref="InsufficientMemoryException"/>.
345+ /// </summary>
346+ /// <exception cref="InsufficientMemoryException">Thrown with no parameters.</exception>
347+ [ DoesNotReturn ]
348+ public static void ThrowInsufficientMemoryException ( )
349+ {
350+ throw new InsufficientMemoryException ( ) ;
351+ }
352+
273353 /// <summary>
274354 /// Throws a new <see cref="InsufficientMemoryException"/>.
275355 /// </summary>
@@ -294,6 +374,16 @@ public static void ThrowInsufficientMemoryException(string message, Exception in
294374 }
295375#endif
296376
377+ /// <summary>
378+ /// Throws a new <see cref="InvalidDataException"/>.
379+ /// </summary>
380+ /// <exception cref="InvalidDataException">Thrown with no parameters.</exception>
381+ [ DoesNotReturn ]
382+ public static void ThrowInvalidDataException ( )
383+ {
384+ throw new InvalidDataException ( ) ;
385+ }
386+
297387 /// <summary>
298388 /// Throws a new <see cref="InvalidDataException"/>.
299389 /// </summary>
@@ -317,6 +407,16 @@ public static void ThrowInvalidDataException(string message, Exception innerExce
317407 throw new InvalidDataException ( message , innerException ) ;
318408 }
319409
410+ /// <summary>
411+ /// Throws a new <see cref="InvalidOperationException"/>.
412+ /// </summary>
413+ /// <exception cref="InvalidOperationException">Thrown with no parameters.</exception>
414+ [ DoesNotReturn ]
415+ public static void ThrowInvalidOperationException ( )
416+ {
417+ throw new InvalidOperationException ( ) ;
418+ }
419+
320420 /// <summary>
321421 /// Throws a new <see cref="InvalidOperationException"/>.
322422 /// </summary>
@@ -340,6 +440,16 @@ public static void ThrowInvalidOperationException(string message, Exception inne
340440 throw new InvalidOperationException ( message , innerException ) ;
341441 }
342442
443+ /// <summary>
444+ /// Throws a new <see cref="LockRecursionException"/>.
445+ /// </summary>
446+ /// <exception cref="LockRecursionException">Thrown with no parameters.</exception>
447+ [ DoesNotReturn ]
448+ public static void ThrowLockRecursionException ( )
449+ {
450+ throw new LockRecursionException ( ) ;
451+ }
452+
343453 /// <summary>
344454 /// Throws a new <see cref="LockRecursionException"/>.
345455 /// </summary>
@@ -363,6 +473,16 @@ public static void ThrowLockRecursionException(string message, Exception innerEx
363473 throw new LockRecursionException ( message , innerException ) ;
364474 }
365475
476+ /// <summary>
477+ /// Throws a new <see cref="MissingFieldException"/>.
478+ /// </summary>
479+ /// <exception cref="MissingFieldException">Thrown with no parameters.</exception>
480+ [ DoesNotReturn ]
481+ public static void ThrowMissingFieldException ( )
482+ {
483+ throw new MissingFieldException ( ) ;
484+ }
485+
366486 /// <summary>
367487 /// Throws a new <see cref="MissingFieldException"/>.
368488 /// </summary>
@@ -400,6 +520,16 @@ public static void ThrowMissingFieldException(string className, string fieldName
400520 }
401521#endif
402522
523+ /// <summary>
524+ /// Throws a new <see cref="MissingMemberException"/>.
525+ /// </summary>
526+ /// <exception cref="MissingMemberException">Thrown with no parameters.</exception>
527+ [ DoesNotReturn ]
528+ public static void ThrowMissingMemberException ( )
529+ {
530+ throw new MissingMemberException ( ) ;
531+ }
532+
403533 /// <summary>
404534 /// Throws a new <see cref="MissingMemberException"/>.
405535 /// </summary>
@@ -437,6 +567,16 @@ public static void ThrowMissingMemberException(string className, string memberNa
437567 }
438568#endif
439569
570+ /// <summary>
571+ /// Throws a new <see cref="MissingMethodException"/>.
572+ /// </summary>
573+ /// <exception cref="MissingMethodException">Thrown with no parameters.</exception>
574+ [ DoesNotReturn ]
575+ public static void ThrowMissingMethodException ( )
576+ {
577+ throw new MissingMethodException ( ) ;
578+ }
579+
440580 /// <summary>
441581 /// Throws a new <see cref="MissingMethodException"/>.
442582 /// </summary>
@@ -474,6 +614,16 @@ public static void ThrowMissingMethodException(string className, string methodNa
474614 }
475615#endif
476616
617+ /// <summary>
618+ /// Throws a new <see cref="NotSupportedException"/>.
619+ /// </summary>
620+ /// <exception cref="NotSupportedException">Thrown with no parameters.</exception>
621+ [ DoesNotReturn ]
622+ public static void ThrowNotSupportedException ( )
623+ {
624+ throw new NotSupportedException ( ) ;
625+ }
626+
477627 /// <summary>
478628 /// Throws a new <see cref="NotSupportedException"/>.
479629 /// </summary>
@@ -532,6 +682,16 @@ public static void ThrowObjectDisposedException(string objectName, string messag
532682 throw new ObjectDisposedException ( objectName , message ) ;
533683 }
534684
685+ /// <summary>
686+ /// Throws a new <see cref="OperationCanceledException"/>.
687+ /// </summary>
688+ /// <exception cref="OperationCanceledException">Thrown with no parameters.</exception>
689+ [ DoesNotReturn ]
690+ public static void ThrowOperationCanceledException ( )
691+ {
692+ throw new OperationCanceledException ( ) ;
693+ }
694+
535695 /// <summary>
536696 /// Throws a new <see cref="OperationCanceledException"/>.
537697 /// </summary>
@@ -591,6 +751,16 @@ public static void ThrowOperationCanceledException(string message, Exception inn
591751 throw new OperationCanceledException ( message , innerException , token ) ;
592752 }
593753
754+ /// <summary>
755+ /// Throws a new <see cref="PlatformNotSupportedException"/>.
756+ /// </summary>
757+ /// <exception cref="PlatformNotSupportedException">Thrown with no parameters.</exception>
758+ [ DoesNotReturn ]
759+ public static void ThrowPlatformNotSupportedException ( )
760+ {
761+ throw new PlatformNotSupportedException ( ) ;
762+ }
763+
594764 /// <summary>
595765 /// Throws a new <see cref="PlatformNotSupportedException"/>.
596766 /// </summary>
@@ -614,6 +784,16 @@ public static void ThrowPlatformNotSupportedException(string message, Exception
614784 throw new PlatformNotSupportedException ( message , innerException ) ;
615785 }
616786
787+ /// <summary>
788+ /// Throws a new <see cref="SynchronizationLockException"/>.
789+ /// </summary>
790+ /// <exception cref="SynchronizationLockException">Thrown with no parameters.</exception>
791+ [ DoesNotReturn ]
792+ public static void ThrowSynchronizationLockException ( )
793+ {
794+ throw new SynchronizationLockException ( ) ;
795+ }
796+
617797 /// <summary>
618798 /// Throws a new <see cref="SynchronizationLockException"/>.
619799 /// </summary>
@@ -637,6 +817,16 @@ public static void ThrowSynchronizationLockException(string message, Exception i
637817 throw new SynchronizationLockException ( message , innerException ) ;
638818 }
639819
820+ /// <summary>
821+ /// Throws a new <see cref="TimeoutException"/>.
822+ /// </summary>
823+ /// <exception cref="TimeoutException">Thrown with no parameters.</exception>
824+ [ DoesNotReturn ]
825+ public static void ThrowTimeoutException ( )
826+ {
827+ throw new TimeoutException ( ) ;
828+ }
829+
640830 /// <summary>
641831 /// Throws a new <see cref="TimeoutException"/>.
642832 /// </summary>
@@ -660,6 +850,16 @@ public static void ThrowTimeoutException(string message, Exception innerExceptio
660850 throw new TimeoutException ( message , innerException ) ;
661851 }
662852
853+ /// <summary>
854+ /// Throws a new <see cref="UnauthorizedAccessException"/>.
855+ /// </summary>
856+ /// <exception cref="UnauthorizedAccessException">Thrown with no parameters.</exception>
857+ [ DoesNotReturn ]
858+ public static void ThrowUnauthorizedAccessException ( )
859+ {
860+ throw new UnauthorizedAccessException ( ) ;
861+ }
862+
663863 /// <summary>
664864 /// Throws a new <see cref="UnauthorizedAccessException"/>.
665865 /// </summary>
@@ -683,6 +883,16 @@ public static void ThrowUnauthorizedAccessException(string message, Exception in
683883 throw new UnauthorizedAccessException ( message , innerException ) ;
684884 }
685885
886+ /// <summary>
887+ /// Throws a new <see cref="Win32Exception"/>.
888+ /// </summary>
889+ /// <exception cref="Win32Exception">Thrown with no parameters.</exception>
890+ [ DoesNotReturn ]
891+ public static void ThrowWin32Exception ( )
892+ {
893+ throw new Win32Exception ( ) ;
894+ }
895+
686896 /// <summary>
687897 /// Throws a new <see cref="Win32Exception"/>.
688898 /// </summary>
0 commit comments