diff --git a/Microsoft.Toolkit/Diagnostics/Attributes/DoesNotReturnAttribute.cs b/Microsoft.Toolkit/Diagnostics/Attributes/DoesNotReturnAttribute.cs
new file mode 100644
index 00000000000..e1663e3cf66
--- /dev/null
+++ b/Microsoft.Toolkit/Diagnostics/Attributes/DoesNotReturnAttribute.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#if !NETSTANDARD2_1
+
+namespace System.Diagnostics.CodeAnalysis
+{
+ ///
+ /// Applied to a method that will never return under any circumstance.
+ ///
+ /// Internal copy of the .NET Standard 2.1 attribute.
+ [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+ internal sealed class DoesNotReturnAttribute : Attribute
+ {
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Microsoft.Toolkit/Diagnostics/Attributes/NotNullAttribute.cs b/Microsoft.Toolkit/Diagnostics/Attributes/NotNullAttribute.cs
index 80a3342c478..482a134daa4 100644
--- a/Microsoft.Toolkit/Diagnostics/Attributes/NotNullAttribute.cs
+++ b/Microsoft.Toolkit/Diagnostics/Attributes/NotNullAttribute.cs
@@ -14,12 +14,6 @@ namespace System.Diagnostics.CodeAnalysis
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
internal sealed class NotNullAttribute : Attribute
{
- ///
- /// Initializes a new instance of the class.
- ///
- public NotNullAttribute()
- {
- }
}
}
diff --git a/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs
index f6ee371e87f..b0df73a80e3 100644
--- a/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs
+++ b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Microsoft.Toolkit.Extensions;
@@ -23,6 +24,7 @@ internal static partial class ThrowHelper
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(Span span, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must be empty, had a size of {span.Length.ToAssertString()}");
@@ -32,6 +34,7 @@ public static void ThrowArgumentExceptionForIsEmpty(Span span, string name
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -41,6 +44,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(Span span, int
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size not equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -50,6 +54,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(Span span, i
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size over {size}, had a size of {span.Length.ToAssertString()}");
@@ -59,6 +64,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(Span span,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size of at least {size}, had a size of {span.Length.ToAssertString()}");
@@ -68,6 +74,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(Span<
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size less than {size}, had a size of {span.Length.ToAssertString()}");
@@ -77,6 +84,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(Span span, int
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Span span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size less than or equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -86,6 +94,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Span
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(Span source, Span destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -95,6 +104,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(Span source, Sp
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Span source, Span destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -104,6 +114,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Span
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, Span span, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {span.Length.ToAssertString()} to be a valid index for the target collection ({typeof(Span).ToTypeString()}), was {index.ToAssertString()}");
@@ -113,6 +124,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, Span span, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {span.Length.ToAssertString()} to be an invalid index for the target collection ({typeof(Span).ToTypeString()}), was {index.ToAssertString()}");
@@ -122,6 +134,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(ReadOnlySpan span, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must be empty, had a size of {span.Length.ToAssertString()}");
@@ -131,6 +144,7 @@ public static void ThrowArgumentExceptionForIsEmpty(ReadOnlySpan span, str
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -140,6 +154,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlySpan sp
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size not equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -149,6 +164,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ReadOnlySpan
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size over {size}, had a size of {span.Length.ToAssertString()}");
@@ -158,6 +174,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(ReadOnlySpan when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size of at least {size}, had a size of {span.Length.ToAssertString()}");
@@ -167,6 +184,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(ReadO
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size less than {size}, had a size of {span.Length.ToAssertString()}");
@@ -176,6 +194,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(ReadOnlySpan s
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnlySpan span, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size less than or equal to {size}, had a size of {span.Length.ToAssertString()}");
@@ -185,6 +204,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnly
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlySpan source, Span destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -194,6 +214,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlySpan so
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnlySpan source, Span destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -203,6 +224,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnly
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, ReadOnlySpan span, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {span.Length.ToAssertString()} to be a valid index for the target collection ({typeof(ReadOnlySpan).ToTypeString()}), was {index.ToAssertString()}");
@@ -212,6 +234,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, ReadOnlySpan span, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {span.Length.ToAssertString()} to be an invalid index for the target collection ({typeof(ReadOnlySpan).ToTypeString()}), was {index.ToAssertString()}");
@@ -221,6 +244,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(Memory memory, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must be empty, had a size of {memory.Length.ToAssertString()}");
@@ -230,6 +254,7 @@ public static void ThrowArgumentExceptionForIsEmpty(Memory memory, string
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -239,6 +264,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(Memory memory,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size not equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -248,6 +274,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(Memory memor
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size over {size}, had a size of {memory.Length.ToAssertString()}");
@@ -257,6 +284,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(Memory memo
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size of at least {size}, had a size of {memory.Length.ToAssertString()}");
@@ -266,6 +294,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(Memor
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size less than {size}, had a size of {memory.Length.ToAssertString()}");
@@ -275,6 +304,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(Memory memory,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Memory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size less than or equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -284,6 +314,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Memory when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(Memory source, Memory destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -293,6 +324,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(Memory source,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Memory source, Memory destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(Memory).ToTypeString()}) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -302,6 +334,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(Memory when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, Memory memory, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {memory.Length.ToAssertString()} to be a valid index for the target collection ({typeof(Memory).ToTypeString()}), was {index.ToAssertString()}");
@@ -311,6 +344,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, Memory memory, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {memory.Length.ToAssertString()} to be an invalid index for the target collection ({typeof(Memory).ToTypeString()}), was {index.ToAssertString()}");
@@ -320,6 +354,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(ReadOnlyMemory memory, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must be empty, had a size of {memory.Length.ToAssertString()}");
@@ -329,6 +364,7 @@ public static void ThrowArgumentExceptionForIsEmpty(ReadOnlyMemory memory,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -338,6 +374,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlyMemory
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size not equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -347,6 +384,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ReadOnlyMemory<
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size over {size}, had a size of {memory.Length.ToAssertString()}");
@@ -356,6 +394,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(ReadOnlyMemory
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size of at least {size}, had a size of {memory.Length.ToAssertString()}");
@@ -365,6 +404,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(ReadO
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size less than {size}, had a size of {memory.Length.ToAssertString()}");
@@ -374,6 +414,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(ReadOnlyMemory
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnlyMemory memory, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size less than or equal to {size}, had a size of {memory.Length.ToAssertString()}");
@@ -383,6 +424,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnly
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlyMemory source, Memory destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -392,6 +434,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ReadOnlyMemory
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnlyMemory source, Memory destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ReadOnlyMemory).ToTypeString()}) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -401,6 +444,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ReadOnly
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, ReadOnlyMemory memory, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {memory.Length.ToAssertString()} to be a valid index for the target collection ({typeof(ReadOnlyMemory).ToTypeString()}), was {index.ToAssertString()}");
@@ -410,6 +454,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, ReadOnlyMemory memory, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {memory.Length.ToAssertString()} to be an invalid index for the target collection ({typeof(ReadOnlyMemory).ToTypeString()}), was {index.ToAssertString()}");
@@ -419,6 +464,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(T[] array, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must be empty, had a size of {array.Length.ToAssertString()}");
@@ -428,6 +474,7 @@ public static void ThrowArgumentExceptionForIsEmpty(T[] array, string name)
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size equal to {size}, had a size of {array.Length.ToAssertString()}");
@@ -437,6 +484,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(T[] array, int siz
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size not equal to {size}, had a size of {array.Length.ToAssertString()}");
@@ -446,6 +494,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(T[] array, int
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size over {size}, had a size of {array.Length.ToAssertString()}");
@@ -455,6 +504,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(T[] array, int
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size of at least {size}, had a size of {array.Length.ToAssertString()}");
@@ -464,6 +514,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(T[] a
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size less than {size}, had a size of {array.Length.ToAssertString()}");
@@ -473,6 +524,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(T[] array, int si
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(T[] array, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size less than or equal to {size}, had a size of {array.Length.ToAssertString()}");
@@ -482,6 +534,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(T[] arra
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(T[] source, T[] destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -491,6 +544,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(T[] source, T[] de
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(T[] source, T[] destination, string name)
{
ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(T[]).ToTypeString()}) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}");
@@ -500,6 +554,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(T[] sour
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, T[] array, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {array.Length.ToAssertString()} to be a valid index for the target collection ({typeof(T[]).ToTypeString()}), was {index.ToAssertString()}");
@@ -509,6 +564,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, T[] array, string name)
{
ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {array.Length.ToAssertString()} to be an invalid index for the target collection ({typeof(T[]).ToTypeString()}), was {index.ToAssertString()}");
@@ -518,6 +574,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForIsEmpty(List list, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must be empty, had a size of {list.Count.ToAssertString()}");
@@ -527,6 +584,7 @@ public static void ThrowArgumentExceptionForIsEmpty(List list, string name
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeEqualTo(List list, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size equal to {size}, had a size of {list.Count.ToAssertString()}");
@@ -536,6 +594,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(List list, int
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeNotEqualTo(List list, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size not equal to {size}, had a size of {list.Count.ToAssertString()}");
@@ -545,6 +604,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(List list, i
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThan(List list, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size over {size}, had a size of {list.Count.ToAssertString()}");
@@ -554,6 +614,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(List list,
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(List list, int size, string name)
{
ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size of at least {size}, had a size of {list.Count.ToAssertString()}");
@@ -563,6 +624,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(List<
/// Throws an when (or an overload) fails.
///
[MethodImpl(MethodImplOptions.NoInlining)]
+ [DoesNotReturn]
public static void ThrowArgumentExceptionForHasSizeLessThan(List