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 list, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size less than {size}, had a size of {list.Count.ToAssertString()}"); @@ -572,6 +634,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(List list, int /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(List list, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size less than or equal to {size}, had a size of {list.Count.ToAssertString()}"); @@ -581,6 +644,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(List /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(List source, List destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -590,6 +654,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(List source, Li /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(List source, List destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(List).ToTypeString()}) must have a size less than or equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -599,6 +664,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(List /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, List list, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {list.Count.ToAssertString()} to be a valid index for the target collection ({typeof(List).ToTypeString()}), was {index.ToAssertString()}"); @@ -608,6 +674,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, List list, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {list.Count.ToAssertString()} to be an invalid index for the target collection ({typeof(List).ToTypeString()}), was {index.ToAssertString()}"); @@ -617,6 +684,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsEmpty(ICollection collection, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must be empty, had a size of {collection.Count.ToAssertString()}"); @@ -626,6 +694,7 @@ public static void ThrowArgumentExceptionForIsEmpty(ICollection collection /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -635,6 +704,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ICollection col /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size not equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -644,6 +714,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(ICollection /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThan(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size over {size}, had a size of {collection.Count.ToAssertString()}"); @@ -653,6 +724,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(ICollection /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size of at least {size}, had a size of {collection.Count.ToAssertString()}"); @@ -662,6 +734,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(IColl /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThan(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size less than {size}, had a size of {collection.Count.ToAssertString()}"); @@ -671,6 +744,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(ICollection co /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ICollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size less than or equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -680,6 +754,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ICollect /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(ICollection source, ICollection destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -689,6 +764,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(ICollection sou /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ICollection source, ICollection destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(ICollection).ToTypeString()}) must have a size less than or equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -698,6 +774,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(ICollect /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, ICollection collection, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {collection.Count.ToAssertString()} to be a valid index for the target collection ({typeof(ICollection).ToTypeString()}), was {index.ToAssertString()}"); @@ -707,6 +784,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, ICollection collection, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {collection.Count.ToAssertString()} to be an invalid index for the target collection ({typeof(ICollection).ToTypeString()}), was {index.ToAssertString()}"); @@ -716,6 +794,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int ind /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsEmpty(IReadOnlyCollection collection, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must be empty, had a size of {collection.Count.ToAssertString()}"); @@ -725,6 +804,7 @@ public static void ThrowArgumentExceptionForIsEmpty(IReadOnlyCollection co /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -734,6 +814,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(IReadOnlyCollectio /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeNotEqualTo(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size not equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -743,6 +824,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(IReadOnlyCollec /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThan(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size over {size}, had a size of {collection.Count.ToAssertString()}"); @@ -752,6 +834,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(IReadOnlyColle /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size of at least {size}, had a size of {collection.Count.ToAssertString()}"); @@ -761,6 +844,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(IRead /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThan(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size less than {size}, had a size of {collection.Count.ToAssertString()}"); @@ -770,6 +854,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(IReadOnlyCollecti /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(IReadOnlyCollection collection, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size less than or equal to {size}, had a size of {collection.Count.ToAssertString()}"); @@ -779,6 +864,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(IReadOnl /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(IReadOnlyCollection source, ICollection destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -788,6 +874,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(IReadOnlyCollectio /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(IReadOnlyCollection source, ICollection destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(IReadOnlyCollection).ToTypeString()}) must have a size less than or equal to {destination.Count.ToAssertString()} (the destination), had a size of {source.Count.ToAssertString()}"); @@ -797,6 +884,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(IReadOnl /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, IReadOnlyCollection collection, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {collection.Count.ToAssertString()} to be a valid index for the target collection ({typeof(IReadOnlyCollection).ToTypeString()}), was {index.ToAssertString()}"); @@ -806,6 +894,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, IReadOnlyCollection collection, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {collection.Count.ToAssertString()} to be an invalid index for the target collection ({typeof(IReadOnlyCollection).ToTypeString()}), was {index.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.tt b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.tt index c27e68efbca..98d72977851 100644 --- a/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.tt +++ b/Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.tt @@ -4,6 +4,7 @@ <#@include file="TypeInfo.ttinclude" #> using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -24,6 +25,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsEmpty(<#=item.Type#> <#=item.Name#>, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must be empty, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -33,6 +35,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -42,6 +45,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeNotEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size not equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -51,6 +55,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThan(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size over {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -60,6 +65,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size of at least {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -69,6 +75,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThan(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -78,6 +85,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}"); @@ -87,6 +95,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {destination.<#=item.Size#>.ToAssertString()} (the destination), had a size of {source.<#=item.Size#>.ToAssertString()}"); @@ -96,6 +105,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {destination.<#=item.Size#>.ToAssertString()} (the destination), had a size of {source.<#=item.Size#>.ToAssertString()}"); @@ -105,6 +115,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, <#=item.Type#> <#=item.Name#>, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {<#=item.Name#>.<#=item.Size#>.ToAssertString()} to be a valid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {index.ToAssertString()}"); @@ -114,6 +125,7 @@ GenerateTextForItems(EnumerableTypes, item => /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, <#=item.Type#> <#=item.Name#>, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {<#=item.Name#>.<#=item.Size#>.ToAssertString()} to be an invalid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {index.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/Guard.String.cs b/Microsoft.Toolkit/Diagnostics/Guard.String.cs index bf4f56beb3b..20bbdab0114 100644 --- a/Microsoft.Toolkit/Diagnostics/Guard.String.cs +++ b/Microsoft.Toolkit/Diagnostics/Guard.String.cs @@ -43,7 +43,9 @@ public static void IsNotNullOrEmpty([NotNull] string? text, string name) { ThrowHelper.ThrowArgumentExceptionForIsNotNullOrEmpty(text, name); } +#pragma warning disable CS8777 // Does not return when text is null (.NET Standard 2.0 string.IsNullOrEmpty lacks flow attribute) } +#pragma warning restore CS8777 /// /// Asserts that the input instance must be or whitespace. @@ -73,7 +75,9 @@ public static void IsNotNullOrWhitespace([NotNull] string? text, string name) { ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhitespace(text, name); } +#pragma warning disable CS8777 // Does not return when text is null } +#pragma warning restore CS8777 /// /// Asserts that the input instance must be empty. diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Collection.Generic.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Collection.Generic.cs index 64a4ce44b48..db4b4037756 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Collection.Generic.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Collection.Generic.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -21,6 +22,7 @@ internal static partial class ThrowHelper /// The item of items in the input instance. /// This method is needed because can't be used as a generic type parameter. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotEmptyWithSpan(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must not be empty"); @@ -32,6 +34,7 @@ public static void ThrowArgumentExceptionForIsNotEmptyWithSpan(string name) /// The item of items in the input instance. /// This method is needed because can't be used as a generic type parameter. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must not be empty"); @@ -42,6 +45,7 @@ public static void ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan(string /// /// The item of items in the input collection. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotEmpty(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be empty"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Generic.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Generic.cs index ef901c3d136..b2dd7d2e4c6 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Generic.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Generic.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -20,6 +21,7 @@ internal static partial class ThrowHelper /// /// The type of value type being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsDefault(T value, string name) where T : struct { @@ -31,6 +33,7 @@ public static void ThrowArgumentExceptionForIsDefault(T value, string name) /// /// The type of value type being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotDefault(string name) where T : struct { @@ -42,6 +45,7 @@ public static void ThrowArgumentExceptionForIsNotDefault(string name) /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsEqualTo(T value, T target, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be equal to {target.ToAssertString()}, was {value.ToAssertString()}"); @@ -52,6 +56,7 @@ public static void ThrowArgumentExceptionForIsEqualTo(T value, T target, stri /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotEqualTo(T value, T target, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be equal to {target.ToAssertString()}, was {value.ToAssertString()}"); @@ -62,6 +67,7 @@ public static void ThrowArgumentExceptionForIsNotEqualTo(T value, T target, s /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsLessThan(T value, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be less than {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -72,6 +78,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsLessThan(T value, T m /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(T value, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be less than or equal to {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -82,6 +89,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsLessThanOrEqualTo(T v /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsGreaterThan(T value, T minimum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be greater than {minimum.ToAssertString()}, was {value.ToAssertString()}"); @@ -92,6 +100,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsGreaterThan(T value, /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo(T value, T minimum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be greater than or equal to {minimum.ToAssertString()}, was {value.ToAssertString()}"); @@ -102,6 +111,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsGreaterThanOrEqualTo( /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRange(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be in the range given by {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -112,6 +122,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRange(T value, T mi /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRange(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be in the range given by {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -122,6 +133,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotInRange(T value, T /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsBetween(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be between {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -132,6 +144,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsBetween(T value, T mi /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotBetween(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be between {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -142,6 +155,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsNotBetween(T value, T /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be between or equal to {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); @@ -152,6 +166,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsBetweenOrEqualTo(T va /// /// The type of values being tested. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotBetweenOrEqualTo(T value, T minimum, T maximum, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be between or equal to {minimum.ToAssertString()} and {maximum.ToAssertString()}, was {value.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Numeric.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Numeric.cs index 2db1ef888ab..d3a2171f6a1 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Numeric.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Comparable.Numeric.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -19,6 +20,7 @@ internal static partial class ThrowHelper /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCloseTo(int value, int target, uint delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(int).ToTypeString()}) must be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs((double)((long)value - target)).ToAssertString()}"); @@ -28,6 +30,7 @@ public static void ThrowArgumentExceptionForIsCloseTo(int value, int target, uin /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCloseTo(int value, int target, uint delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(int).ToTypeString()}) must not be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs((double)((long)value - target)).ToAssertString()}"); @@ -37,6 +40,7 @@ public static void ThrowArgumentExceptionForIsNotCloseTo(int value, int target, /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCloseTo(long value, long target, ulong delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(long).ToTypeString()}) must be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs((decimal)value - target).ToAssertString()}"); @@ -46,6 +50,7 @@ public static void ThrowArgumentExceptionForIsCloseTo(long value, long target, u /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCloseTo(long value, long target, ulong delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(long).ToTypeString()}) must not be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs((decimal)value - target).ToAssertString()}"); @@ -55,6 +60,7 @@ public static void ThrowArgumentExceptionForIsNotCloseTo(long value, long target /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCloseTo(float value, float target, float delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(float).ToTypeString()}) must be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs(value - target).ToAssertString()}"); @@ -64,6 +70,7 @@ public static void ThrowArgumentExceptionForIsCloseTo(float value, float target, /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCloseTo(float value, float target, float delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(float).ToTypeString()}) must not be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs(value - target).ToAssertString()}"); @@ -73,6 +80,7 @@ public static void ThrowArgumentExceptionForIsNotCloseTo(float value, float targ /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCloseTo(double value, double target, double delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(double).ToTypeString()}) must be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs(value - target).ToAssertString()}"); @@ -82,6 +90,7 @@ public static void ThrowArgumentExceptionForIsCloseTo(double value, double targe /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCloseTo(double value, double target, double delta, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(double).ToTypeString()}) must not be within a distance of {delta.ToAssertString()} from {target.ToAssertString()}, was {value.ToAssertString()} and had a distance of {Math.Abs(value - target).ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.IO.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.IO.cs index 218c1527480..a4f750b9b3e 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.IO.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.IO.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -20,6 +21,7 @@ internal static partial class ThrowHelper /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForCanRead(Stream stream, string name) { ThrowArgumentException(name, $"Stream {name.ToAssertString()} ({stream.GetType().ToTypeString()}) doesn't support reading"); @@ -29,6 +31,7 @@ public static void ThrowArgumentExceptionForCanRead(Stream stream, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForCanWrite(Stream stream, string name) { ThrowArgumentException(name, $"Stream {name.ToAssertString()} ({stream.GetType().ToTypeString()}) doesn't support writing"); @@ -38,6 +41,7 @@ public static void ThrowArgumentExceptionForCanWrite(Stream stream, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForCanSeek(Stream stream, string name) { ThrowArgumentException(name, $"Stream {name.ToAssertString()} ({stream.GetType().ToTypeString()}) doesn't support seeking"); @@ -47,6 +51,7 @@ public static void ThrowArgumentExceptionForCanSeek(Stream stream, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsAtStartPosition(Stream stream, string name) { ThrowArgumentException(name, $"Stream {name.ToAssertString()} ({stream.GetType().ToTypeString()}) must be at position {0.ToAssertString()}, was at {stream.Position.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.String.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.String.cs index 2835d1c4c0c..d986ebb67dd 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.String.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.String.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; #nullable enable @@ -18,6 +19,7 @@ internal static partial class ThrowHelper /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNullOrEmpty(string? text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must be null or empty, was {text.ToAssertString()}"); @@ -27,6 +29,7 @@ public static void ThrowArgumentExceptionForIsNullOrEmpty(string? text, string n /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotNullOrEmpty(string? text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must not be null or empty, was {(text is null ? "null" : "empty")}"); @@ -36,6 +39,7 @@ public static void ThrowArgumentExceptionForIsNotNullOrEmpty(string? text, strin /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNullOrWhitespace(string? text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must be null or whitespace, was {text.ToAssertString()}"); @@ -45,6 +49,7 @@ public static void ThrowArgumentExceptionForIsNullOrWhitespace(string? text, str /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotNullOrWhitespace(string? text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must not be null or whitespace, was {(text is null ? "null" : "whitespace")}"); @@ -54,6 +59,7 @@ public static void ThrowArgumentExceptionForIsNotNullOrWhitespace(string? text, /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsEmpty(string text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must be empty, was {text.ToAssertString()}"); @@ -63,6 +69,7 @@ public static void ThrowArgumentExceptionForIsEmpty(string text, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotEmpty(string text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must not be empty"); @@ -72,6 +79,7 @@ public static void ThrowArgumentExceptionForIsNotEmpty(string text, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsWhitespace(string text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must be whitespace, was {text.ToAssertString()}"); @@ -81,6 +89,7 @@ public static void ThrowArgumentExceptionForIsWhitespace(string text, string nam /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotWhitespace(string text, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must not be whitespace, was {text.ToAssertString()}"); @@ -90,6 +99,7 @@ public static void ThrowArgumentExceptionForIsNotWhitespace(string text, string /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must have a size equal to {size}, had a size of {text.Length} and was {text.ToAssertString()}"); @@ -99,6 +109,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(string text, int size /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeNotEqualTo(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must not have a size equal to {size}, was {text.ToAssertString()}"); @@ -108,6 +119,7 @@ public static void ThrowArgumentExceptionForHasSizeNotEqualTo(string text, int s /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThan(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must have a size over {size}, had a size of {text.Length} and was {text.ToAssertString()}"); @@ -117,6 +129,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThan(string text, int /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must have a size of at least {size}, had a size of {text.Length} and was {text.ToAssertString()}"); @@ -126,6 +139,7 @@ public static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(string t /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThan(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must have a size less than {size}, had a size of {text.Length} and was {text.ToAssertString()}"); @@ -135,6 +149,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThan(string text, int siz /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(string text, int size, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} (string) must have a size less than or equal to {size}, had a size of {text.Length} and was {text.ToAssertString()}"); @@ -144,6 +159,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(string text /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeEqualTo(string source, string destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} (string) must have a size equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}"); @@ -153,6 +169,7 @@ public static void ThrowArgumentExceptionForHasSizeEqualTo(string source, string /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(string source, string destination, string name) { ThrowArgumentException(name, $"The source {name.ToAssertString()} (string) must have a size less than or equal to {destination.Length.ToAssertString()} (the destination), had a size of {source.Length.ToAssertString()}"); @@ -162,6 +179,7 @@ public static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(string sour /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, string text, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {text.Length.ToAssertString()} to be a valid index for the target string, was {index.ToAssertString()}"); @@ -171,6 +189,7 @@ public static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor(int index, st /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(int index, string text, string name) { ThrowArgumentOutOfRangeException(name, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {text.Length.ToAssertString()} to be an invalid index for the target string, was {index.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Tasks.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Tasks.cs index 8b5a144d5e0..f25af5139d6 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.Tasks.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.Tasks.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.Toolkit.Extensions; @@ -20,6 +21,7 @@ internal static partial class ThrowHelper /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCompleted(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must be completed, had status {task.Status.ToAssertString()}"); @@ -29,6 +31,7 @@ public static void ThrowArgumentExceptionForIsCompleted(Task task, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCompleted(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must not be completed, had status {task.Status.ToAssertString()}"); @@ -38,6 +41,7 @@ public static void ThrowArgumentExceptionForIsNotCompleted(Task task, string nam /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCompletedSuccessfully(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must be completed successfully, had status {task.Status.ToAssertString()}"); @@ -47,6 +51,7 @@ public static void ThrowArgumentExceptionForIsCompletedSuccessfully(Task task, s /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCompletedSuccessfully(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must not be completed successfully, had status {task.Status.ToAssertString()}"); @@ -56,6 +61,7 @@ public static void ThrowArgumentExceptionForIsNotCompletedSuccessfully(Task task /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsFaulted(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must be faulted, had status {task.Status.ToAssertString()}"); @@ -65,6 +71,7 @@ public static void ThrowArgumentExceptionForIsFaulted(Task task, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotFaulted(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must not be faulted, had status {task.Status.ToAssertString()}"); @@ -74,6 +81,7 @@ public static void ThrowArgumentExceptionForIsNotFaulted(Task task, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsCanceled(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must be canceled, had status {task.Status.ToAssertString()}"); @@ -83,6 +91,7 @@ public static void ThrowArgumentExceptionForIsCanceled(Task task, string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotCanceled(Task task, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must not be canceled, had status {task.Status.ToAssertString()}"); @@ -92,6 +101,7 @@ public static void ThrowArgumentExceptionForIsNotCanceled(Task task, string name /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasStatusEqualTo(Task task, TaskStatus status, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must have status {status}, had status {task.Status.ToAssertString()}"); @@ -101,6 +111,7 @@ public static void ThrowArgumentExceptionForHasStatusEqualTo(Task task, TaskStat /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForHasStatusNotEqualTo(Task task, TaskStatus status, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({task.GetType().ToTypeString()}) must not have status {status.ToAssertString()}"); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.ThrowExceptions.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.ThrowExceptions.cs index 52e270677e9..eebb9f99b6e 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.ThrowExceptions.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.ThrowExceptions.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; @@ -38,6 +39,7 @@ private static string ToAssertString(this object? obj) /// The message to include in the exception. /// Thrown with and . [MethodImpl(MethodImplOptions.AggressiveInlining)] + [DoesNotReturn] private static void ThrowArgumentException(string name, string message) { throw new ArgumentException(message, name); @@ -50,6 +52,7 @@ private static void ThrowArgumentException(string name, string message) /// The message to include in the exception. /// Thrown with and . [MethodImpl(MethodImplOptions.AggressiveInlining)] + [DoesNotReturn] private static void ThrowArgumentNullException(string name, string message) { throw new ArgumentNullException(name, message); @@ -62,6 +65,7 @@ private static void ThrowArgumentNullException(string name, string message) /// The message to include in the exception. /// Thrown with and . [MethodImpl(MethodImplOptions.AggressiveInlining)] + [DoesNotReturn] private static void ThrowArgumentOutOfRangeException(string name, string message) { throw new ArgumentOutOfRangeException(name, message); diff --git a/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs b/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs index bbc307deb9d..aad8c57b9f0 100644 --- a/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs +++ b/Microsoft.Toolkit/Diagnostics/ThrowHelper.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; @@ -20,6 +21,7 @@ internal static partial class ThrowHelper /// /// The type of the input value. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNull(T value, string name) where T : class { @@ -31,6 +33,7 @@ public static void ThrowArgumentExceptionForIsNull(T value, string name) /// /// The type of the input value. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNull(T? value, string name) where T : struct { @@ -42,6 +45,7 @@ public static void ThrowArgumentExceptionForIsNull(T? value, string name) /// /// The type of the input value. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentNullExceptionForIsNotNull(string name) { ThrowArgumentNullException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must be not null)"); @@ -52,6 +56,7 @@ public static void ThrowArgumentNullExceptionForIsNotNull(string name) /// /// The type of the input value. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsOfType(object value, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be of type {typeof(T).ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -62,6 +67,7 @@ public static void ThrowArgumentExceptionForIsOfType(object value, string nam /// /// The type of the input value. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotOfType(object value, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must not be of type {typeof(T).ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -71,6 +77,7 @@ public static void ThrowArgumentExceptionForIsNotOfType(object value, string /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsOfType(object value, Type type, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be of type {type.ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -80,6 +87,7 @@ public static void ThrowArgumentExceptionForIsOfType(object value, Type type, st /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotOfType(object value, Type type, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must not be of type {type.ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -90,6 +98,7 @@ public static void ThrowArgumentExceptionForIsNotOfType(object value, Type type, /// /// The type being checked against. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsAssignableToType(object value, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be assignable to type {typeof(T).ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -100,6 +109,7 @@ public static void ThrowArgumentExceptionForIsAssignableToType(object value, /// /// The type being checked against. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotAssignableToType(object value, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must not be assignable to type {typeof(T).ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -109,6 +119,7 @@ public static void ThrowArgumentExceptionForIsNotAssignableToType(object valu /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsAssignableToType(object value, Type type, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be assignable to type {type.ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -118,6 +129,7 @@ public static void ThrowArgumentExceptionForIsAssignableToType(object value, Typ /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsNotAssignableToType(object value, Type type, string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must not be assignable to type {type.ToTypeString()}, was {value.GetType().ToTypeString()}"); @@ -128,6 +140,7 @@ public static void ThrowArgumentExceptionForIsNotAssignableToType(object value, /// /// The type of input values being compared. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForsBitwiseEqualTo(T value, T target, string name) where T : unmanaged { @@ -139,6 +152,7 @@ public static void ThrowArgumentExceptionForsBitwiseEqualTo(T value, T target /// /// The type of input value being compared. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsReferenceEqualTo(string name) where T : class { @@ -150,6 +164,7 @@ public static void ThrowArgumentExceptionForIsReferenceEqualTo(string name) /// /// The type of input value being compared. [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsReferenceNotEqualTo(string name) where T : class { @@ -160,6 +175,7 @@ public static void ThrowArgumentExceptionForIsReferenceNotEqualTo(string name /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsTrue(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be true, was false"); @@ -169,6 +185,7 @@ public static void ThrowArgumentExceptionForIsTrue(string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsTrue(string name, string message) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be true, was false: {message.ToAssertString()}"); @@ -178,6 +195,7 @@ public static void ThrowArgumentExceptionForIsTrue(string name, string message) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsFalse(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be false, was true"); @@ -187,6 +205,7 @@ public static void ThrowArgumentExceptionForIsFalse(string name) /// Throws an when fails. /// [MethodImpl(MethodImplOptions.NoInlining)] + [DoesNotReturn] public static void ThrowArgumentExceptionForIsFalse(string name, string message) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} must be false, was true: {message.ToAssertString()}");