From 15da57b8b3c4563f6f5d4def539449ad8b8bd4fc Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 23 Sep 2022 22:05:51 +0200 Subject: [PATCH 1/6] Bump HighPerformance package to .NET 7 --- .../CommunityToolkit.HighPerformance.csproj | 4 +- .../Extensions/SpinLockExtensions.cs | 22 ++--- .../NullableReadOnlyRef{T}.cs | 41 +++------- .../NullableRef{T}.cs | 41 ++-------- .../RequiresPreviewFeaturesAttribute.cs | 55 ------------- .../ReadOnlyRef{T}.cs | 81 ++----------------- CommunityToolkit.HighPerformance/Ref{T}.cs | 60 ++------------ build/Community.Toolkit.Common.props | 2 +- ...tyToolkit.HighPerformance.UnitTests.csproj | 2 +- .../Extensions/Test_SpinLockExtensions.cs | 4 +- .../Test_NullableReadOnlyRef{T}.cs | 2 +- .../Test_NullableRef{T}.cs | 4 +- .../Test_ReadOnlyRef{T}.cs | 22 +---- .../Test_Ref{T}.cs | 26 +----- 14 files changed, 58 insertions(+), 308 deletions(-) delete mode 100644 CommunityToolkit.HighPerformance/Properties/Polyfills/RequiresPreviewFeaturesAttribute.cs diff --git a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index f41d8c86..5324fa47 100644 --- a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0 @@ -45,7 +45,7 @@ - + diff --git a/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs b/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs index 9f30a694..c9cd360d 100644 --- a/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs +++ b/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs @@ -2,11 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.ComponentModel; using System.Runtime.CompilerServices; -#if NETSTANDARD2_1_OR_GREATER -using System.Runtime.Versioning; -#endif using System.Threading; namespace CommunityToolkit.HighPerformance; @@ -33,6 +31,8 @@ public static class SpinLockExtensions /// A wrapper type that will release when its method is called. /// The returned value shouldn't be used directly: use this extension in a block or statement. [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Obsolete("Use SpinLockExtensions.Enter(ref SpinLock) instead.")] + [EditorBrowsable(EditorBrowsableState.Never)] public static unsafe UnsafeLock Enter(SpinLock* spinLock) { return new(spinLock); @@ -80,7 +80,7 @@ public void Dispose() } } -#if NETSTANDARD2_1_OR_GREATER +#if NET7_0_OR_GREATER /// /// Enters a specified instance and returns a wrapper to use to release the lock. /// This extension should be used though a block or statement: @@ -97,9 +97,6 @@ public void Dispose() /// The target to use /// A wrapper type that will release when its method is called. /// The returned value shouldn't be used directly: use this extension in a block or statement. - [RequiresPreviewFeatures( - "The Lock type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Lock Enter(ref this SpinLock spinLock) { @@ -110,15 +107,12 @@ public static Lock Enter(ref this SpinLock spinLock) /// A that is used to enter and hold a through a block or statement. /// [EditorBrowsable(EditorBrowsableState.Never)] - [RequiresPreviewFeatures( - "The Lock type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] public readonly ref struct Lock { /// - /// The instance pointing to the target value to use. + /// The reference to the target value to use. /// - private readonly Ref spinLock; + private readonly ref SpinLock spinLock; /// /// A value indicating whether or not the lock is taken by this instance. @@ -132,7 +126,7 @@ public readonly ref struct Lock [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Lock(ref SpinLock spinLock) { - this.spinLock = new Ref(ref spinLock); + this.spinLock = ref spinLock; this.lockTaken = false; spinLock.Enter(ref this.lockTaken); @@ -146,7 +140,7 @@ public void Dispose() { if (this.lockTaken) { - this.spinLock.Value.Exit(); + this.spinLock.Exit(); } } } diff --git a/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs b/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs index 104b96bc..298dc0f7 100644 --- a/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs +++ b/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs @@ -2,12 +2,10 @@ // 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_OR_GREATER +#if NET7_0_OR_GREATER using System; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; namespace CommunityToolkit.HighPerformance; @@ -15,15 +13,12 @@ namespace CommunityToolkit.HighPerformance; /// A that can store an optional readonly reference to a value of a specified type. /// /// The type of value to reference. -[RequiresPreviewFeatures( - "The NullableReadOnlyRef type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] public readonly ref struct NullableReadOnlyRef { /// - /// The 1-length instance used to track the target value. + /// The reference to the target value. /// - private readonly ReadOnlySpan span; + private readonly ref readonly T value; /// /// Initializes a new instance of the struct. @@ -32,19 +27,7 @@ public readonly ref struct NullableReadOnlyRef [MethodImpl(MethodImplOptions.AggressiveInlining)] public NullableReadOnlyRef(in T value) { - ref T r0 = ref Unsafe.AsRef(value); - - this.span = MemoryMarshal.CreateReadOnlySpan(ref r0, 1); - } - - /// - /// Initializes a new instance of the struct. - /// - /// The instance to track the target reference. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private NullableReadOnlyRef(ReadOnlySpan span) - { - this.span = span; + this.value = ref value; } /// @@ -62,13 +45,7 @@ public static NullableReadOnlyRef Null public unsafe bool HasValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - // See comment in NullableRef about this - byte length = unchecked((byte)this.span.Length); - - return *(bool*)&length; - } + get => !Unsafe.IsNullRef(ref Unsafe.AsRef(in this.value)); } /// @@ -85,7 +62,7 @@ public ref readonly T Value ThrowInvalidOperationException(); } - return ref MemoryMarshal.GetReference(this.span); + return ref this.value; } } @@ -96,7 +73,7 @@ public ref readonly T Value [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef(Ref reference) { - return new(reference.Span); + return new(in reference.Value); } /// @@ -106,7 +83,7 @@ public static implicit operator NullableReadOnlyRef(Ref reference) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef(ReadOnlyRef reference) { - return new(reference.Span); + return new(in reference.Value); } /// @@ -116,7 +93,7 @@ public static implicit operator NullableReadOnlyRef(ReadOnlyRef reference) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef(NullableRef reference) { - return new(reference.Span); + return new(in reference.Value); } /// diff --git a/CommunityToolkit.HighPerformance/NullableRef{T}.cs b/CommunityToolkit.HighPerformance/NullableRef{T}.cs index 5b7163f1..9e31c0bb 100644 --- a/CommunityToolkit.HighPerformance/NullableRef{T}.cs +++ b/CommunityToolkit.HighPerformance/NullableRef{T}.cs @@ -2,12 +2,10 @@ // 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_OR_GREATER +#if NET7_0_OR_GREATER using System; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; namespace CommunityToolkit.HighPerformance; @@ -15,15 +13,12 @@ namespace CommunityToolkit.HighPerformance; /// A that can store an optional reference to a value of a specified type. /// /// The type of value to reference. -[RequiresPreviewFeatures( - "The NullableRef type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] public readonly ref struct NullableRef { /// - /// The 1-length instance used to track the target value. + /// The reference to the target value. /// - internal readonly Span Span; + private readonly ref T value; /// /// Initializes a new instance of the struct. @@ -32,17 +27,7 @@ public readonly ref struct NullableRef [MethodImpl(MethodImplOptions.AggressiveInlining)] public NullableRef(ref T value) { - this.Span = MemoryMarshal.CreateSpan(ref value, 1); - } - - /// - /// Initializes a new instance of the struct. - /// - /// The instance to track the target reference. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private NullableRef(Span span) - { - this.Span = span; + this.value = ref value; } /// @@ -60,19 +45,7 @@ public static NullableRef Null public unsafe bool HasValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - // We know that the span will always have a length of either - // 1 or 0, so instead of using a cmp instruction and setting the - // zero flag to produce our boolean value, we can just cast - // the length to byte without overflow checks (doing a cast will - // also account for the byte endianness of the current system), - // and then reinterpret that value to a bool flag. - // This results in a single movzx instruction on x86-64. - byte length = unchecked((byte)this.Span.Length); - - return *(bool*)&length; - } + get => !Unsafe.IsNullRef(ref this.value); } /// @@ -89,7 +62,7 @@ public ref T Value ThrowInvalidOperationException(); } - return ref MemoryMarshal.GetReference(this.Span); + return ref this.value; } } @@ -100,7 +73,7 @@ public ref T Value [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableRef(Ref reference) { - return new(reference.Span); + return new(ref reference.Value); } /// diff --git a/CommunityToolkit.HighPerformance/Properties/Polyfills/RequiresPreviewFeaturesAttribute.cs b/CommunityToolkit.HighPerformance/Properties/Polyfills/RequiresPreviewFeaturesAttribute.cs deleted file mode 100644 index 103d6f06..00000000 --- a/CommunityToolkit.HighPerformance/Properties/Polyfills/RequiresPreviewFeaturesAttribute.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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 !NET6_0_OR_GREATER - -namespace System.Runtime.Versioning; - -/// -/// Indicates that an API is in preview. -/// -[AttributeUsage( - AttributeTargets.Assembly | - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Interface | - AttributeTargets.Delegate | - AttributeTargets.Struct | - AttributeTargets.Enum | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Field | - AttributeTargets.Event, - Inherited = false)] -internal sealed class RequiresPreviewFeaturesAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - public RequiresPreviewFeaturesAttribute() - { - } - - /// - /// Initializes a new instance of the class with the specified message. - /// - /// An optional message associated with this attribute instance. - public RequiresPreviewFeaturesAttribute(string? message) - { - Message = message; - } - - /// - /// Returns the optional message associated with this attribute instance. - /// - public string? Message { get; } - - /// - /// Returns the optional URL associated with this attribute instance. - /// - public string? Url { get; set; } -} - -#endif \ No newline at end of file diff --git a/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs b/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs index 0f643c8e..31ac75b3 100644 --- a/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs +++ b/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs @@ -2,14 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +#if NET7_0_OR_GREATER + using System.Runtime.CompilerServices; -using System.Runtime.Versioning; -#if NETSTANDARD2_1_OR_GREATER -using System.Runtime.InteropServices; -#else -using CommunityToolkit.HighPerformance.Helpers; -#endif namespace CommunityToolkit.HighPerformance; @@ -17,16 +12,12 @@ namespace CommunityToolkit.HighPerformance; /// A that can store a readonly reference to a value of a specified type. /// /// The type of value to reference. -[RequiresPreviewFeatures( - "The ReadOnlyRef type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] public readonly ref struct ReadOnlyRef { -#if NETSTANDARD2_1_OR_GREATER /// - /// The 1-length instance used to track the target value. + /// The reference to the target value. /// - internal readonly ReadOnlySpan Span; + private readonly ref readonly T value; /// /// Initializes a new instance of the struct. @@ -35,9 +26,7 @@ public readonly ref struct ReadOnlyRef [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyRef(in T value) { - ref T r0 = ref Unsafe.AsRef(value); - - this.Span = MemoryMarshal.CreateReadOnlySpan(ref r0, 1); + this.value = ref value; } /// @@ -56,7 +45,7 @@ public unsafe ReadOnlyRef(void* pointer) public ref readonly T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref MemoryMarshal.GetReference(this.Span); + get => ref this.value; } /// @@ -68,62 +57,6 @@ public static implicit operator ReadOnlyRef(Ref reference) { return new(in reference.Value); } -#else - /// - /// The owner the current instance belongs to - /// - private readonly object owner; - - /// - /// The target offset within the current instance is pointing to - /// - private readonly IntPtr offset; - - /// - /// Initializes a new instance of the struct. - /// - /// The owner to create a portable reference for. - /// The target offset within for the target reference. - /// The parameter is not validated, and it's responsibility of the caller to ensure it's valid. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ReadOnlyRef(object owner, IntPtr offset) - { - this.owner = owner; - this.offset = offset; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The owner to create a portable reference for. - /// The target reference to point to (it must be within ). - /// The parameter is not validated, and it's responsibility of the caller to ensure it's valid. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ReadOnlyRef(object owner, in T value) - { - this.owner = owner; - this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(owner, ref Unsafe.AsRef(value)); - } - - /// - /// Gets the readonly reference represented by the current instance. - /// - public ref readonly T Value - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref ObjectMarshal.DangerousGetObjectDataReferenceAt(this.owner, this.offset); - } - - /// - /// Implicitly converts a instance into a one. - /// - /// The input instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlyRef(Ref reference) - { - return new(reference.Owner, reference.Offset); - } -#endif /// /// Implicitly gets the value from a given instance. @@ -135,3 +68,5 @@ public static implicit operator T(ReadOnlyRef reference) return reference.Value; } } + +#endif diff --git a/CommunityToolkit.HighPerformance/Ref{T}.cs b/CommunityToolkit.HighPerformance/Ref{T}.cs index 8deec6c4..59ac6246 100644 --- a/CommunityToolkit.HighPerformance/Ref{T}.cs +++ b/CommunityToolkit.HighPerformance/Ref{T}.cs @@ -2,14 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +#if NET7_0_OR_GREATER + using System.Runtime.CompilerServices; -using System.Runtime.Versioning; -#if NETSTANDARD2_1_OR_GREATER -using System.Runtime.InteropServices; -#else -using CommunityToolkit.HighPerformance.Helpers; -#endif namespace CommunityToolkit.HighPerformance; @@ -17,16 +12,12 @@ namespace CommunityToolkit.HighPerformance; /// A that can store a reference to a value of a specified type. /// /// The type of value to reference. -[RequiresPreviewFeatures( - "The Ref type has no compiler support to ensure the lifetime of referenced values is respected, and as such using it incorrectly may lead to GC holes.", - Url = "https://github.com/dotnet/runtime/issues/46104")] public readonly ref struct Ref { -#if NETSTANDARD2_1_OR_GREATER /// - /// The 1-length instance used to track the target value. + /// The reference to the target value. /// - internal readonly Span Span; + private readonly ref T value; /// /// Initializes a new instance of the struct. @@ -35,7 +26,7 @@ public readonly ref struct Ref [MethodImpl(MethodImplOptions.AggressiveInlining)] public Ref(ref T value) { - this.Span = MemoryMarshal.CreateSpan(ref value, 1); + this.value = ref value; } /// @@ -54,45 +45,8 @@ public unsafe Ref(void* pointer) public ref T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref MemoryMarshal.GetReference(this.Span); + get => ref this.value; } -#else - /// - /// The owner the current instance belongs to - /// - internal readonly object Owner; - - /// - /// The target offset within the current instance is pointing to - /// - /// - /// Using an instead of to avoid the int to - /// native int conversion in the generated asm (an extra movsxd on x64). - /// - internal readonly IntPtr Offset; - - /// - /// Initializes a new instance of the struct. - /// - /// The owner to create a portable reference for. - /// The target reference to point to (it must be within ). - /// The parameter is not validated, and it's responsibility of the caller to ensure it's valid. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Ref(object owner, ref T value) - { - this.Owner = owner; - this.Offset = ObjectMarshal.DangerousGetObjectDataByteOffset(owner, ref value); - } - - /// - /// Gets the reference represented by the current instance. - /// - public ref T Value - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref ObjectMarshal.DangerousGetObjectDataReferenceAt(this.Owner, this.Offset); - } -#endif /// /// Implicitly gets the value from a given instance. @@ -104,3 +58,5 @@ public static implicit operator T(Ref reference) return reference.Value; } } + +#endif diff --git a/build/Community.Toolkit.Common.props b/build/Community.Toolkit.Common.props index 12288dab..1775ea7d 100644 --- a/build/Community.Toolkit.Common.props +++ b/build/Community.Toolkit.Common.props @@ -20,7 +20,7 @@ true - 10.0 + 11.0 enable diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj index 50ad26c7..18066ff3 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;netcoreapp3.1;net6.0;net7.0 true $(NoWarn);CA2252 diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs index 8991a741..6857393f 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_SpinLockExtensions.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable CS0618 + namespace CommunityToolkit.HighPerformance.UnitTests.Extensions; [TestClass] @@ -33,7 +35,7 @@ public unsafe void Test_ArrayExtensions_Pointer() Assert.AreEqual(sum, 1000 * 10); } -#if !NETFRAMEWORK +#if NET7_0_OR_GREATER [TestMethod] public void Test_ArrayExtensions_Ref() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableReadOnlyRef{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableReadOnlyRef{T}.cs index bcf9ac5d..7ddffd84 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableReadOnlyRef{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableReadOnlyRef{T}.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETCOREAPP3_1_OR_GREATER +#if NET7_0_OR_GREATER using System; using System.Runtime.CompilerServices; diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableRef{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableRef{T}.cs index b10ae880..7799a67f 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableRef{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_NullableRef{T}.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETCOREAPP3_1_OR_GREATER +#if NET7_0_OR_GREATER using System; using System.Runtime.CompilerServices; @@ -76,4 +76,4 @@ public void Test_NullableRefOfT_CreateNullableRefOfT_ExplicitCastOfT_Exception() } } -#endif \ No newline at end of file +#endif diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_ReadOnlyRef{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_ReadOnlyRef{T}.cs index 863711e4..f5c8fece 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_ReadOnlyRef{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_ReadOnlyRef{T}.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET7_0_OR_GREATER + using System.Runtime.CompilerServices; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -11,23 +13,6 @@ namespace CommunityToolkit.HighPerformance.UnitTests; public class Test_ReadOnlyRefOfT { [TestMethod] -#if NETFRAMEWORK - public void Test_RefOfT_CreateRefOfT() - { - ReadOnlyFieldOwner model = new(); - ReadOnlyRef reference = new(model, model.Value); - - Assert.IsTrue(Unsafe.AreSame(ref Unsafe.AsRef(model.Value), ref Unsafe.AsRef(reference.Value))); - } - - /// - /// A dummy model that owns an field. - /// - private sealed class ReadOnlyFieldOwner - { - public readonly int Value = 1; - } -#else public void Test_RefOfT_CreateRefOfT() { int value = 1; @@ -35,5 +20,6 @@ public void Test_RefOfT_CreateRefOfT() Assert.IsTrue(Unsafe.AreSame(ref value, ref Unsafe.AsRef(reference.Value))); } -#endif } + +#endif \ No newline at end of file diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Ref{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Ref{T}.cs index d59534e2..ce17f01b 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Ref{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Ref{T}.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET7_0_OR_GREATER + using System.Runtime.CompilerServices; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -11,27 +13,6 @@ namespace CommunityToolkit.HighPerformance.UnitTests; public class Test_RefOfT { [TestMethod] -#if NETFRAMEWORK - public void Test_RefOfT_CreateRefOfT() - { - FieldOwner model = new() { Value = 1 }; - Ref reference = new(model, ref model.Value); - - Assert.IsTrue(Unsafe.AreSame(ref model.Value, ref reference.Value)); - - reference.Value++; - - Assert.AreEqual(model.Value, 2); - } - - /// - /// A dummy model that owns an field. - /// - private sealed class FieldOwner - { - public int Value; - } -#else public void Test_RefOfT_CreateRefOfT() { int value = 1; @@ -43,5 +24,6 @@ public void Test_RefOfT_CreateRefOfT() Assert.AreEqual(value, 2); } -#endif } + +#endif \ No newline at end of file From 1961f572d70a21cd70d4c25257f427deb9d83d93 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Oct 2022 12:49:37 +0200 Subject: [PATCH 2/6] Set EnableTrimAnalyzer again in MVVM Toolkit --- CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index f9a64e8f..3eef8704 100644 --- a/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -36,9 +36,7 @@ - - - false + true true From 15cbf787188a311c031de2137e7f61b2848d8636 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Oct 2022 13:01:50 +0200 Subject: [PATCH 3/6] Use nameof() operator in attribute arguments --- .../Extensions/StringExtensions.cs | 2 +- .../Generated/Guard.Collection.g.cs | 192 +++++----- .../Generated/Guard.Collection.tt | 24 +- .../Generated/Guard.Comparable.Numeric.g.cs | 336 +++++++++--------- .../Generated/Guard.Comparable.Numeric.tt | 24 +- CommunityToolkit.Diagnostics/Guard.Boolean.cs | 12 +- .../Guard.Comparable.Generic.cs | 30 +- .../Guard.Comparable.Numeric.cs | 20 +- CommunityToolkit.Diagnostics/Guard.IO.cs | 8 +- CommunityToolkit.Diagnostics/Guard.String.cs | 37 +- CommunityToolkit.Diagnostics/Guard.Tasks.cs | 20 +- CommunityToolkit.Diagnostics/Guard.cs | 28 +- .../ComponentModel/ObservableObject.cs | 4 +- .../ComponentModel/ObservableRecipient.cs | 4 +- .../ComponentModel/ObservableValidator.cs | 4 +- .../Polyfills/ArgumentNullException.cs | 4 +- 16 files changed, 377 insertions(+), 372 deletions(-) diff --git a/CommunityToolkit.Common/Extensions/StringExtensions.cs b/CommunityToolkit.Common/Extensions/StringExtensions.cs index c94d84a6..417e1594 100644 --- a/CommunityToolkit.Common/Extensions/StringExtensions.cs +++ b/CommunityToolkit.Common/Extensions/StringExtensions.cs @@ -96,7 +96,7 @@ public static bool IsNumeric([NotNullWhen(true)] this string? str) /// /// HTML string. /// Decoded HTML string. - [return: NotNullIfNotNull("htmlText")] + [return: NotNullIfNotNull(nameof(htmlText))] public static string? DecodeHtml(this string? htmlText) { if (htmlText is null) diff --git a/CommunityToolkit.Diagnostics/Generated/Guard.Collection.g.cs b/CommunityToolkit.Diagnostics/Generated/Guard.Collection.g.cs index 4208dabe..fcf70516 100644 --- a/CommunityToolkit.Diagnostics/Generated/Guard.Collection.g.cs +++ b/CommunityToolkit.Diagnostics/Generated/Guard.Collection.g.cs @@ -22,7 +22,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(Span span, [CallerArgumentExpression("span")] string name = "") + public static void IsEmpty(Span span, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length == 0) { @@ -40,7 +40,7 @@ public static void IsEmpty(Span span, [CallerArgumentExpression("span")] s /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(Span span, [CallerArgumentExpression("span")] string name = "") + public static void IsNotEmpty(Span span, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length != 0) { @@ -59,7 +59,7 @@ public static void IsNotEmpty(Span span, [CallerArgumentExpression("span") /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeEqualTo(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length == size) { @@ -78,7 +78,7 @@ public static void HasSizeEqualTo(Span span, int size, [CallerArgumentExpr /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeNotEqualTo(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length != size) { @@ -97,7 +97,7 @@ public static void HasSizeNotEqualTo(Span span, int size, [CallerArgumentE /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeGreaterThan(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length > size) { @@ -116,7 +116,7 @@ public static void HasSizeGreaterThan(Span span, int size, [CallerArgument /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length >= size) { @@ -135,7 +135,7 @@ public static void HasSizeGreaterThanOrEqualTo(Span span, int size, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeLessThan(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length < size) { @@ -154,7 +154,7 @@ public static void HasSizeLessThan(Span span, int size, [CallerArgumentExp /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(Span span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeLessThanOrEqualTo(Span span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length <= size) { @@ -173,7 +173,7 @@ public static void HasSizeLessThanOrEqualTo(Span span, int size, [CallerAr /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(Span source, Span destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(Span source, Span destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length == destination.Length) { @@ -192,7 +192,7 @@ public static void HasSizeEqualTo(Span source, Span destination, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(Span source, Span destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(Span source, Span destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length <= destination.Length) { @@ -211,7 +211,7 @@ public static void HasSizeLessThanOrEqualTo(Span source, Span destinati /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, Span span, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, Span span, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)span.Length) { @@ -230,7 +230,7 @@ public static void IsInRangeFor(int index, Span span, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, Span span, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, Span span, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)span.Length) { @@ -248,7 +248,7 @@ public static void IsNotInRangeFor(int index, Span span, [CallerArgumentEx /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(ReadOnlySpan span, [CallerArgumentExpression("span")] string name = "") + public static void IsEmpty(ReadOnlySpan span, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length == 0) { @@ -266,7 +266,7 @@ public static void IsEmpty(ReadOnlySpan span, [CallerArgumentExpression("s /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(ReadOnlySpan span, [CallerArgumentExpression("span")] string name = "") + public static void IsNotEmpty(ReadOnlySpan span, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length != 0) { @@ -285,7 +285,7 @@ public static void IsNotEmpty(ReadOnlySpan span, [CallerArgumentExpression /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length == size) { @@ -304,7 +304,7 @@ public static void HasSizeEqualTo(ReadOnlySpan span, int size, [CallerArgu /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeNotEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length != size) { @@ -323,7 +323,7 @@ public static void HasSizeNotEqualTo(ReadOnlySpan span, int size, [CallerA /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeGreaterThan(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length > size) { @@ -342,7 +342,7 @@ public static void HasSizeGreaterThan(ReadOnlySpan span, int size, [Caller /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length >= size) { @@ -361,7 +361,7 @@ public static void HasSizeGreaterThanOrEqualTo(ReadOnlySpan span, int size /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeLessThan(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length < size) { @@ -380,7 +380,7 @@ public static void HasSizeLessThan(ReadOnlySpan span, int size, [CallerArg /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression("span")] string name = "") + public static void HasSizeLessThanOrEqualTo(ReadOnlySpan span, int size, [CallerArgumentExpression(nameof(span))] string name = "") { if (span.Length <= size) { @@ -399,7 +399,7 @@ public static void HasSizeLessThanOrEqualTo(ReadOnlySpan span, int size, [ /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ReadOnlySpan source, Span destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(ReadOnlySpan source, Span destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length == destination.Length) { @@ -418,7 +418,7 @@ public static void HasSizeEqualTo(ReadOnlySpan source, Span destination /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ReadOnlySpan source, Span destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(ReadOnlySpan source, Span destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length <= destination.Length) { @@ -437,7 +437,7 @@ public static void HasSizeLessThanOrEqualTo(ReadOnlySpan source, Span d /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, ReadOnlySpan span, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, ReadOnlySpan span, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)span.Length) { @@ -456,7 +456,7 @@ public static void IsInRangeFor(int index, ReadOnlySpan span, [CallerArgum /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, ReadOnlySpan span, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, ReadOnlySpan span, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)span.Length) { @@ -474,7 +474,7 @@ public static void IsNotInRangeFor(int index, ReadOnlySpan span, [CallerAr /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(Memory memory, [CallerArgumentExpression("memory")] string name = "") + public static void IsEmpty(Memory memory, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length == 0) { @@ -492,7 +492,7 @@ public static void IsEmpty(Memory memory, [CallerArgumentExpression("memor /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(Memory memory, [CallerArgumentExpression("memory")] string name = "") + public static void IsNotEmpty(Memory memory, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length != 0) { @@ -511,7 +511,7 @@ public static void IsNotEmpty(Memory memory, [CallerArgumentExpression("me /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeEqualTo(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length == size) { @@ -530,7 +530,7 @@ public static void HasSizeEqualTo(Memory memory, int size, [CallerArgument /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeNotEqualTo(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length != size) { @@ -549,7 +549,7 @@ public static void HasSizeNotEqualTo(Memory memory, int size, [CallerArgum /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeGreaterThan(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length > size) { @@ -568,7 +568,7 @@ public static void HasSizeGreaterThan(Memory memory, int size, [CallerArgu /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length >= size) { @@ -587,7 +587,7 @@ public static void HasSizeGreaterThanOrEqualTo(Memory memory, int size, [C /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeLessThan(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length < size) { @@ -606,7 +606,7 @@ public static void HasSizeLessThan(Memory memory, int size, [CallerArgumen /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(Memory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeLessThanOrEqualTo(Memory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length <= size) { @@ -625,7 +625,7 @@ public static void HasSizeLessThanOrEqualTo(Memory memory, int size, [Call /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(Memory source, Memory destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(Memory source, Memory destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length == destination.Length) { @@ -644,7 +644,7 @@ public static void HasSizeEqualTo(Memory source, Memory destination, [C /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(Memory source, Memory destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(Memory source, Memory destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length <= destination.Length) { @@ -663,7 +663,7 @@ public static void HasSizeLessThanOrEqualTo(Memory source, Memory desti /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, Memory memory, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, Memory memory, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)memory.Length) { @@ -682,7 +682,7 @@ public static void IsInRangeFor(int index, Memory memory, [CallerArgumentE /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, Memory memory, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, Memory memory, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)memory.Length) { @@ -700,7 +700,7 @@ public static void IsNotInRangeFor(int index, Memory memory, [CallerArgume /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(ReadOnlyMemory memory, [CallerArgumentExpression("memory")] string name = "") + public static void IsEmpty(ReadOnlyMemory memory, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length == 0) { @@ -718,7 +718,7 @@ public static void IsEmpty(ReadOnlyMemory memory, [CallerArgumentExpressio /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(ReadOnlyMemory memory, [CallerArgumentExpression("memory")] string name = "") + public static void IsNotEmpty(ReadOnlyMemory memory, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length != 0) { @@ -737,7 +737,7 @@ public static void IsNotEmpty(ReadOnlyMemory memory, [CallerArgumentExpres /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length == size) { @@ -756,7 +756,7 @@ public static void HasSizeEqualTo(ReadOnlyMemory memory, int size, [Caller /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeNotEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length != size) { @@ -775,7 +775,7 @@ public static void HasSizeNotEqualTo(ReadOnlyMemory memory, int size, [Cal /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeGreaterThan(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length > size) { @@ -794,7 +794,7 @@ public static void HasSizeGreaterThan(ReadOnlyMemory memory, int size, [Ca /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length >= size) { @@ -813,7 +813,7 @@ public static void HasSizeGreaterThanOrEqualTo(ReadOnlyMemory memory, int /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeLessThan(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length < size) { @@ -832,7 +832,7 @@ public static void HasSizeLessThan(ReadOnlyMemory memory, int size, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression("memory")] string name = "") + public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory memory, int size, [CallerArgumentExpression(nameof(memory))] string name = "") { if (memory.Length <= size) { @@ -851,7 +851,7 @@ public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory memory, int siz /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ReadOnlyMemory source, Memory destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(ReadOnlyMemory source, Memory destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length == destination.Length) { @@ -870,7 +870,7 @@ public static void HasSizeEqualTo(ReadOnlyMemory source, Memory destina /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory source, Memory destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory source, Memory destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length <= destination.Length) { @@ -889,7 +889,7 @@ public static void HasSizeLessThanOrEqualTo(ReadOnlyMemory source, Memory< /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, ReadOnlyMemory memory, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, ReadOnlyMemory memory, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)memory.Length) { @@ -908,7 +908,7 @@ public static void IsInRangeFor(int index, ReadOnlyMemory memory, [CallerA /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, ReadOnlyMemory memory, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, ReadOnlyMemory memory, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)memory.Length) { @@ -926,7 +926,7 @@ public static void IsNotInRangeFor(int index, ReadOnlyMemory memory, [Call /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(T[] array, [CallerArgumentExpression("array")] string name = "") + public static void IsEmpty(T[] array, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length == 0) { @@ -944,7 +944,7 @@ public static void IsEmpty(T[] array, [CallerArgumentExpression("array")] str /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(T[] array, [CallerArgumentExpression("array")] string name = "") + public static void IsNotEmpty(T[] array, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length != 0) { @@ -963,7 +963,7 @@ public static void IsNotEmpty(T[] array, [CallerArgumentExpression("array")] /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeEqualTo(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length == size) { @@ -982,7 +982,7 @@ public static void HasSizeEqualTo(T[] array, int size, [CallerArgumentExpress /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeNotEqualTo(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length != size) { @@ -1001,7 +1001,7 @@ public static void HasSizeNotEqualTo(T[] array, int size, [CallerArgumentExpr /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeGreaterThan(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length > size) { @@ -1020,7 +1020,7 @@ public static void HasSizeGreaterThan(T[] array, int size, [CallerArgumentExp /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length >= size) { @@ -1039,7 +1039,7 @@ public static void HasSizeGreaterThanOrEqualTo(T[] array, int size, [CallerAr /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeLessThan(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length < size) { @@ -1058,7 +1058,7 @@ public static void HasSizeLessThan(T[] array, int size, [CallerArgumentExpres /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(T[] array, int size, [CallerArgumentExpression("array")] string name = "") + public static void HasSizeLessThanOrEqualTo(T[] array, int size, [CallerArgumentExpression(nameof(array))] string name = "") { if (array.Length <= size) { @@ -1077,7 +1077,7 @@ public static void HasSizeLessThanOrEqualTo(T[] array, int size, [CallerArgum /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(T[] source, T[] destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(T[] source, T[] destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length == destination.Length) { @@ -1096,7 +1096,7 @@ public static void HasSizeEqualTo(T[] source, T[] destination, [CallerArgumen /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(T[] source, T[] destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(T[] source, T[] destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Length <= destination.Length) { @@ -1115,7 +1115,7 @@ public static void HasSizeLessThanOrEqualTo(T[] source, T[] destination, [Cal /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, T[] array, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, T[] array, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)array.Length) { @@ -1134,7 +1134,7 @@ public static void IsInRangeFor(int index, T[] array, [CallerArgumentExpressi /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, T[] array, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, T[] array, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)array.Length) { @@ -1152,7 +1152,7 @@ public static void IsNotInRangeFor(int index, T[] array, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(List list, [CallerArgumentExpression("list")] string name = "") + public static void IsEmpty(List list, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count == 0) { @@ -1170,7 +1170,7 @@ public static void IsEmpty(List list, [CallerArgumentExpression("list")] s /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(List list, [CallerArgumentExpression("list")] string name = "") + public static void IsNotEmpty(List list, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count != 0) { @@ -1189,7 +1189,7 @@ public static void IsNotEmpty(List list, [CallerArgumentExpression("list") /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeEqualTo(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count == size) { @@ -1208,7 +1208,7 @@ public static void HasSizeEqualTo(List list, int size, [CallerArgumentExpr /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeNotEqualTo(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count != size) { @@ -1227,7 +1227,7 @@ public static void HasSizeNotEqualTo(List list, int size, [CallerArgumentE /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeGreaterThan(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count > size) { @@ -1246,7 +1246,7 @@ public static void HasSizeGreaterThan(List list, int size, [CallerArgument /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count >= size) { @@ -1265,7 +1265,7 @@ public static void HasSizeGreaterThanOrEqualTo(List list, int size, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeLessThan(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count < size) { @@ -1284,7 +1284,7 @@ public static void HasSizeLessThan(List list, int size, [CallerArgumentExp /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(List list, int size, [CallerArgumentExpression("list")] string name = "") + public static void HasSizeLessThanOrEqualTo(List list, int size, [CallerArgumentExpression(nameof(list))] string name = "") { if (list.Count <= size) { @@ -1303,7 +1303,7 @@ public static void HasSizeLessThanOrEqualTo(List list, int size, [CallerAr /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(List source, List destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(List source, List destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count == destination.Count) { @@ -1322,7 +1322,7 @@ public static void HasSizeEqualTo(List source, List destination, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(List source, List destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(List source, List destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count <= destination.Count) { @@ -1341,7 +1341,7 @@ public static void HasSizeLessThanOrEqualTo(List source, List destinati /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, List list, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, List list, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)list.Count) { @@ -1360,7 +1360,7 @@ public static void IsInRangeFor(int index, List list, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, List list, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, List list, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)list.Count) { @@ -1378,7 +1378,7 @@ public static void IsNotInRangeFor(int index, List list, [CallerArgumentEx /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(ICollection collection, [CallerArgumentExpression("collection")] string name = "") + public static void IsEmpty(ICollection collection, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count == 0) { @@ -1396,7 +1396,7 @@ public static void IsEmpty(ICollection collection, [CallerArgumentExpressi /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(ICollection collection, [CallerArgumentExpression("collection")] string name = "") + public static void IsNotEmpty(ICollection collection, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count != 0) { @@ -1415,7 +1415,7 @@ public static void IsNotEmpty(ICollection collection, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeEqualTo(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count == size) { @@ -1434,7 +1434,7 @@ public static void HasSizeEqualTo(ICollection collection, int size, [Calle /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeNotEqualTo(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count != size) { @@ -1453,7 +1453,7 @@ public static void HasSizeNotEqualTo(ICollection collection, int size, [Ca /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeGreaterThan(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count > size) { @@ -1472,7 +1472,7 @@ public static void HasSizeGreaterThan(ICollection collection, int size, [C /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count >= size) { @@ -1491,7 +1491,7 @@ public static void HasSizeGreaterThanOrEqualTo(ICollection collection, int /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeLessThan(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count < size) { @@ -1510,7 +1510,7 @@ public static void HasSizeLessThan(ICollection collection, int size, [Call /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ICollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeLessThanOrEqualTo(ICollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count <= size) { @@ -1529,7 +1529,7 @@ public static void HasSizeLessThanOrEqualTo(ICollection collection, int si /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(ICollection source, ICollection destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(ICollection source, ICollection destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count == destination.Count) { @@ -1548,7 +1548,7 @@ public static void HasSizeEqualTo(ICollection source, ICollection desti /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(ICollection source, ICollection destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(ICollection source, ICollection destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count <= destination.Count) { @@ -1567,7 +1567,7 @@ public static void HasSizeLessThanOrEqualTo(ICollection source, ICollectio /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, ICollection collection, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, ICollection collection, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)collection.Count) { @@ -1586,7 +1586,7 @@ public static void IsInRangeFor(int index, ICollection collection, [Caller /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, ICollection collection, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, ICollection collection, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)collection.Count) { @@ -1604,7 +1604,7 @@ public static void IsNotInRangeFor(int index, ICollection collection, [Cal /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(IReadOnlyCollection collection, [CallerArgumentExpression("collection")] string name = "") + public static void IsEmpty(IReadOnlyCollection collection, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count == 0) { @@ -1622,7 +1622,7 @@ public static void IsEmpty(IReadOnlyCollection collection, [CallerArgument /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(IReadOnlyCollection collection, [CallerArgumentExpression("collection")] string name = "") + public static void IsNotEmpty(IReadOnlyCollection collection, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count != 0) { @@ -1641,7 +1641,7 @@ public static void IsNotEmpty(IReadOnlyCollection collection, [CallerArgum /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count == size) { @@ -1660,7 +1660,7 @@ public static void HasSizeEqualTo(IReadOnlyCollection collection, int size /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeNotEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count != size) { @@ -1679,7 +1679,7 @@ public static void HasSizeNotEqualTo(IReadOnlyCollection collection, int s /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeGreaterThan(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count > size) { @@ -1698,7 +1698,7 @@ public static void HasSizeGreaterThan(IReadOnlyCollection collection, int /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count >= size) { @@ -1717,7 +1717,7 @@ public static void HasSizeGreaterThanOrEqualTo(IReadOnlyCollection collect /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeLessThan(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count < size) { @@ -1736,7 +1736,7 @@ public static void HasSizeLessThan(IReadOnlyCollection collection, int siz /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression("collection")] string name = "") + public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection collection, int size, [CallerArgumentExpression(nameof(collection))] string name = "") { if (collection.Count <= size) { @@ -1755,7 +1755,7 @@ public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection collection /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(IReadOnlyCollection source, ICollection destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(IReadOnlyCollection source, ICollection destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count == destination.Count) { @@ -1774,7 +1774,7 @@ public static void HasSizeEqualTo(IReadOnlyCollection source, ICollection< /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection source, ICollection destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection source, ICollection destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.Count <= destination.Count) { @@ -1793,7 +1793,7 @@ public static void HasSizeLessThanOrEqualTo(IReadOnlyCollection source, IC /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, IReadOnlyCollection collection, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, IReadOnlyCollection collection, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)collection.Count) { @@ -1812,7 +1812,7 @@ public static void IsInRangeFor(int index, IReadOnlyCollection collection, /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, IReadOnlyCollection collection, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, IReadOnlyCollection collection, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)collection.Count) { diff --git a/CommunityToolkit.Diagnostics/Generated/Guard.Collection.tt b/CommunityToolkit.Diagnostics/Generated/Guard.Collection.tt index 7e2b7776..fd93aa2f 100644 --- a/CommunityToolkit.Diagnostics/Generated/Guard.Collection.tt +++ b/CommunityToolkit.Diagnostics/Generated/Guard.Collection.tt @@ -23,7 +23,7 @@ GenerateTextForItems(EnumerableTypes, item => /// The name of the input parameter being tested. /// Thrown if the size of is != 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(<#=item.Type#> <#=item.Name#>, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void IsEmpty(<#=item.Type#> <#=item.Name#>, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> == 0) { @@ -41,7 +41,7 @@ GenerateTextForItems(EnumerableTypes, item => /// The name of the input parameter being tested. /// Thrown if the size of is == 0. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(<#=item.Type#> <#=item.Name#>, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void IsNotEmpty(<#=item.Type#> <#=item.Name#>, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> != 0) { @@ -79,7 +79,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> == size) { @@ -98,7 +98,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeNotEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> != size) { @@ -117,7 +117,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeGreaterThan(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> > size) { @@ -136,7 +136,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> >= size) { @@ -155,7 +155,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeLessThan(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> < size) { @@ -174,7 +174,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression("<#=item.Name#>")] string name = "") + public static void HasSizeLessThanOrEqualTo(<#=item.Type#> <#=item.Name#>, int size, [CallerArgumentExpression(nameof(<#=item.Name#>))] string name = "") { if (<#=item.Name#>.<#=item.Size#> <= size) { @@ -193,7 +193,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is != the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.<#=item.Size#> == destination.<#=item.Size#>) { @@ -225,7 +225,7 @@ else /// The name of the input parameter being tested. /// Thrown if the size of is > the one of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, [CallerArgumentExpression("source")] string name = "") + public static void HasSizeLessThanOrEqualTo(<#=item.Type#> source, <#=item.DestinationType#> destination, [CallerArgumentExpression(nameof(source))] string name = "") { if (source.<#=item.Size#> <= destination.<#=item.Size#>) { @@ -257,7 +257,7 @@ else /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, <#=item.Type#> <#=item.Name#>, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, <#=item.Type#> <#=item.Name#>, [CallerArgumentExpression(nameof(index))] string name = "") { <# // Here we're leveraging the fact that signed integers are represented @@ -283,7 +283,7 @@ else /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, <#=item.Type#> <#=item.Name#>, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, <#=item.Type#> <#=item.Name#>, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)<#=item.Name#>.<#=item.Size#>) { diff --git a/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.g.cs b/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.g.cs index ecc1cbef..fc381828 100644 --- a/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.g.cs +++ b/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.g.cs @@ -21,7 +21,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(byte value, byte target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(byte value, byte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -40,7 +40,7 @@ public static void IsEqualTo(byte value, byte target, [CallerArgumentExpression( /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(byte value, byte target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(byte value, byte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -59,7 +59,7 @@ public static void IsNotEqualTo(byte value, byte target, [CallerArgumentExpressi /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(byte value, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(byte value, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -78,7 +78,7 @@ public static void IsLessThan(byte value, byte maximum, [CallerArgumentExpressio /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(byte value, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(byte value, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -97,7 +97,7 @@ public static void IsLessThanOrEqualTo(byte value, byte maximum, [CallerArgument /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(byte value, byte minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(byte value, byte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -116,7 +116,7 @@ public static void IsGreaterThan(byte value, byte minimum, [CallerArgumentExpres /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(byte value, byte minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(byte value, byte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -139,7 +139,7 @@ public static void IsGreaterThanOrEqualTo(byte value, byte minimum, [CallerArgum /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -162,7 +162,7 @@ public static void IsInRange(byte value, byte minimum, byte maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -185,7 +185,7 @@ public static void IsNotInRange(byte value, byte minimum, byte maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -208,7 +208,7 @@ public static void IsBetween(byte value, byte minimum, byte maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -231,7 +231,7 @@ public static void IsNotBetween(byte value, byte minimum, byte maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -254,7 +254,7 @@ public static void IsBetweenOrEqualTo(byte value, byte minimum, byte maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(byte value, byte minimum, byte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -272,7 +272,7 @@ public static void IsNotBetweenOrEqualTo(byte value, byte minimum, byte maximum, /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(sbyte value, sbyte target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(sbyte value, sbyte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -291,7 +291,7 @@ public static void IsEqualTo(sbyte value, sbyte target, [CallerArgumentExpressio /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(sbyte value, sbyte target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(sbyte value, sbyte target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -310,7 +310,7 @@ public static void IsNotEqualTo(sbyte value, sbyte target, [CallerArgumentExpres /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(sbyte value, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(sbyte value, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -329,7 +329,7 @@ public static void IsLessThan(sbyte value, sbyte maximum, [CallerArgumentExpress /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(sbyte value, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(sbyte value, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -348,7 +348,7 @@ public static void IsLessThanOrEqualTo(sbyte value, sbyte maximum, [CallerArgume /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(sbyte value, sbyte minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(sbyte value, sbyte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -367,7 +367,7 @@ public static void IsGreaterThan(sbyte value, sbyte minimum, [CallerArgumentExpr /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(sbyte value, sbyte minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(sbyte value, sbyte minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -390,7 +390,7 @@ public static void IsGreaterThanOrEqualTo(sbyte value, sbyte minimum, [CallerArg /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -413,7 +413,7 @@ public static void IsInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -436,7 +436,7 @@ public static void IsNotInRange(sbyte value, sbyte minimum, sbyte maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -459,7 +459,7 @@ public static void IsBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -482,7 +482,7 @@ public static void IsNotBetween(sbyte value, sbyte minimum, sbyte maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -505,7 +505,7 @@ public static void IsBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -523,7 +523,7 @@ public static void IsNotBetweenOrEqualTo(sbyte value, sbyte minimum, sbyte maxim /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(short value, short target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(short value, short target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -542,7 +542,7 @@ public static void IsEqualTo(short value, short target, [CallerArgumentExpressio /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(short value, short target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(short value, short target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -561,7 +561,7 @@ public static void IsNotEqualTo(short value, short target, [CallerArgumentExpres /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(short value, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(short value, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -580,7 +580,7 @@ public static void IsLessThan(short value, short maximum, [CallerArgumentExpress /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(short value, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(short value, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -599,7 +599,7 @@ public static void IsLessThanOrEqualTo(short value, short maximum, [CallerArgume /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(short value, short minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(short value, short minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -618,7 +618,7 @@ public static void IsGreaterThan(short value, short minimum, [CallerArgumentExpr /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(short value, short minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(short value, short minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -641,7 +641,7 @@ public static void IsGreaterThanOrEqualTo(short value, short minimum, [CallerArg /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -664,7 +664,7 @@ public static void IsInRange(short value, short minimum, short maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -687,7 +687,7 @@ public static void IsNotInRange(short value, short minimum, short maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -710,7 +710,7 @@ public static void IsBetween(short value, short minimum, short maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -733,7 +733,7 @@ public static void IsNotBetween(short value, short minimum, short maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -756,7 +756,7 @@ public static void IsBetweenOrEqualTo(short value, short minimum, short maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(short value, short minimum, short maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -774,7 +774,7 @@ public static void IsNotBetweenOrEqualTo(short value, short minimum, short maxim /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(ushort value, ushort target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(ushort value, ushort target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -793,7 +793,7 @@ public static void IsEqualTo(ushort value, ushort target, [CallerArgumentExpress /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(ushort value, ushort target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(ushort value, ushort target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -812,7 +812,7 @@ public static void IsNotEqualTo(ushort value, ushort target, [CallerArgumentExpr /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(ushort value, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(ushort value, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -831,7 +831,7 @@ public static void IsLessThan(ushort value, ushort maximum, [CallerArgumentExpre /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(ushort value, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(ushort value, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -850,7 +850,7 @@ public static void IsLessThanOrEqualTo(ushort value, ushort maximum, [CallerArgu /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(ushort value, ushort minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(ushort value, ushort minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -869,7 +869,7 @@ public static void IsGreaterThan(ushort value, ushort minimum, [CallerArgumentEx /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(ushort value, ushort minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(ushort value, ushort minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -892,7 +892,7 @@ public static void IsGreaterThanOrEqualTo(ushort value, ushort minimum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -915,7 +915,7 @@ public static void IsInRange(ushort value, ushort minimum, ushort maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -938,7 +938,7 @@ public static void IsNotInRange(ushort value, ushort minimum, ushort maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -961,7 +961,7 @@ public static void IsBetween(ushort value, ushort minimum, ushort maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -984,7 +984,7 @@ public static void IsNotBetween(ushort value, ushort minimum, ushort maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -1007,7 +1007,7 @@ public static void IsBetweenOrEqualTo(ushort value, ushort minimum, ushort maxim /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(ushort value, ushort minimum, ushort maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -1025,7 +1025,7 @@ public static void IsNotBetweenOrEqualTo(ushort value, ushort minimum, ushort ma /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(char value, char target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(char value, char target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -1044,7 +1044,7 @@ public static void IsEqualTo(char value, char target, [CallerArgumentExpression( /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(char value, char target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(char value, char target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -1063,7 +1063,7 @@ public static void IsNotEqualTo(char value, char target, [CallerArgumentExpressi /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(char value, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(char value, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -1082,7 +1082,7 @@ public static void IsLessThan(char value, char maximum, [CallerArgumentExpressio /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(char value, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(char value, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -1101,7 +1101,7 @@ public static void IsLessThanOrEqualTo(char value, char maximum, [CallerArgument /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(char value, char minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(char value, char minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -1120,7 +1120,7 @@ public static void IsGreaterThan(char value, char minimum, [CallerArgumentExpres /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(char value, char minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(char value, char minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -1143,7 +1143,7 @@ public static void IsGreaterThanOrEqualTo(char value, char minimum, [CallerArgum /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -1166,7 +1166,7 @@ public static void IsInRange(char value, char minimum, char maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -1189,7 +1189,7 @@ public static void IsNotInRange(char value, char minimum, char maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -1212,7 +1212,7 @@ public static void IsBetween(char value, char minimum, char maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -1235,7 +1235,7 @@ public static void IsNotBetween(char value, char minimum, char maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -1258,7 +1258,7 @@ public static void IsBetweenOrEqualTo(char value, char minimum, char maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(char value, char minimum, char maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -1276,7 +1276,7 @@ public static void IsNotBetweenOrEqualTo(char value, char minimum, char maximum, /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(int value, int target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(int value, int target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -1295,7 +1295,7 @@ public static void IsEqualTo(int value, int target, [CallerArgumentExpression("v /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(int value, int target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(int value, int target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -1314,7 +1314,7 @@ public static void IsNotEqualTo(int value, int target, [CallerArgumentExpression /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(int value, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(int value, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -1333,7 +1333,7 @@ public static void IsLessThan(int value, int maximum, [CallerArgumentExpression( /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(int value, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(int value, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -1352,7 +1352,7 @@ public static void IsLessThanOrEqualTo(int value, int maximum, [CallerArgumentEx /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(int value, int minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(int value, int minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -1371,7 +1371,7 @@ public static void IsGreaterThan(int value, int minimum, [CallerArgumentExpressi /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(int value, int minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(int value, int minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -1394,7 +1394,7 @@ public static void IsGreaterThanOrEqualTo(int value, int minimum, [CallerArgumen /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -1417,7 +1417,7 @@ public static void IsInRange(int value, int minimum, int maximum, [CallerArgumen /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -1440,7 +1440,7 @@ public static void IsNotInRange(int value, int minimum, int maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -1463,7 +1463,7 @@ public static void IsBetween(int value, int minimum, int maximum, [CallerArgumen /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -1486,7 +1486,7 @@ public static void IsNotBetween(int value, int minimum, int maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -1509,7 +1509,7 @@ public static void IsBetweenOrEqualTo(int value, int minimum, int maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -1527,7 +1527,7 @@ public static void IsNotBetweenOrEqualTo(int value, int minimum, int maximum, [C /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(uint value, uint target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(uint value, uint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -1546,7 +1546,7 @@ public static void IsEqualTo(uint value, uint target, [CallerArgumentExpression( /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(uint value, uint target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(uint value, uint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -1565,7 +1565,7 @@ public static void IsNotEqualTo(uint value, uint target, [CallerArgumentExpressi /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(uint value, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(uint value, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -1584,7 +1584,7 @@ public static void IsLessThan(uint value, uint maximum, [CallerArgumentExpressio /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(uint value, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(uint value, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -1603,7 +1603,7 @@ public static void IsLessThanOrEqualTo(uint value, uint maximum, [CallerArgument /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(uint value, uint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(uint value, uint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -1622,7 +1622,7 @@ public static void IsGreaterThan(uint value, uint minimum, [CallerArgumentExpres /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(uint value, uint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(uint value, uint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -1645,7 +1645,7 @@ public static void IsGreaterThanOrEqualTo(uint value, uint minimum, [CallerArgum /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -1668,7 +1668,7 @@ public static void IsInRange(uint value, uint minimum, uint maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -1691,7 +1691,7 @@ public static void IsNotInRange(uint value, uint minimum, uint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -1714,7 +1714,7 @@ public static void IsBetween(uint value, uint minimum, uint maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -1737,7 +1737,7 @@ public static void IsNotBetween(uint value, uint minimum, uint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -1760,7 +1760,7 @@ public static void IsBetweenOrEqualTo(uint value, uint minimum, uint maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(uint value, uint minimum, uint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -1778,7 +1778,7 @@ public static void IsNotBetweenOrEqualTo(uint value, uint minimum, uint maximum, /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(float value, float target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(float value, float target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -1797,7 +1797,7 @@ public static void IsEqualTo(float value, float target, [CallerArgumentExpressio /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(float value, float target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(float value, float target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -1816,7 +1816,7 @@ public static void IsNotEqualTo(float value, float target, [CallerArgumentExpres /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(float value, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(float value, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -1835,7 +1835,7 @@ public static void IsLessThan(float value, float maximum, [CallerArgumentExpress /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(float value, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(float value, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -1854,7 +1854,7 @@ public static void IsLessThanOrEqualTo(float value, float maximum, [CallerArgume /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(float value, float minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(float value, float minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -1873,7 +1873,7 @@ public static void IsGreaterThan(float value, float minimum, [CallerArgumentExpr /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(float value, float minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(float value, float minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -1896,7 +1896,7 @@ public static void IsGreaterThanOrEqualTo(float value, float minimum, [CallerArg /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -1919,7 +1919,7 @@ public static void IsInRange(float value, float minimum, float maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -1942,7 +1942,7 @@ public static void IsNotInRange(float value, float minimum, float maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -1965,7 +1965,7 @@ public static void IsBetween(float value, float minimum, float maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -1988,7 +1988,7 @@ public static void IsNotBetween(float value, float minimum, float maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -2011,7 +2011,7 @@ public static void IsBetweenOrEqualTo(float value, float minimum, float maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(float value, float minimum, float maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -2029,7 +2029,7 @@ public static void IsNotBetweenOrEqualTo(float value, float minimum, float maxim /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(long value, long target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(long value, long target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -2048,7 +2048,7 @@ public static void IsEqualTo(long value, long target, [CallerArgumentExpression( /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(long value, long target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(long value, long target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -2067,7 +2067,7 @@ public static void IsNotEqualTo(long value, long target, [CallerArgumentExpressi /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(long value, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(long value, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -2086,7 +2086,7 @@ public static void IsLessThan(long value, long maximum, [CallerArgumentExpressio /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(long value, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(long value, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -2105,7 +2105,7 @@ public static void IsLessThanOrEqualTo(long value, long maximum, [CallerArgument /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(long value, long minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(long value, long minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -2124,7 +2124,7 @@ public static void IsGreaterThan(long value, long minimum, [CallerArgumentExpres /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(long value, long minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(long value, long minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -2147,7 +2147,7 @@ public static void IsGreaterThanOrEqualTo(long value, long minimum, [CallerArgum /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -2170,7 +2170,7 @@ public static void IsInRange(long value, long minimum, long maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -2193,7 +2193,7 @@ public static void IsNotInRange(long value, long minimum, long maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -2216,7 +2216,7 @@ public static void IsBetween(long value, long minimum, long maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -2239,7 +2239,7 @@ public static void IsNotBetween(long value, long minimum, long maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -2262,7 +2262,7 @@ public static void IsBetweenOrEqualTo(long value, long minimum, long maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -2280,7 +2280,7 @@ public static void IsNotBetweenOrEqualTo(long value, long minimum, long maximum, /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(ulong value, ulong target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(ulong value, ulong target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -2299,7 +2299,7 @@ public static void IsEqualTo(ulong value, ulong target, [CallerArgumentExpressio /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(ulong value, ulong target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(ulong value, ulong target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -2318,7 +2318,7 @@ public static void IsNotEqualTo(ulong value, ulong target, [CallerArgumentExpres /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(ulong value, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(ulong value, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -2337,7 +2337,7 @@ public static void IsLessThan(ulong value, ulong maximum, [CallerArgumentExpress /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(ulong value, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(ulong value, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -2356,7 +2356,7 @@ public static void IsLessThanOrEqualTo(ulong value, ulong maximum, [CallerArgume /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(ulong value, ulong minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(ulong value, ulong minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -2375,7 +2375,7 @@ public static void IsGreaterThan(ulong value, ulong minimum, [CallerArgumentExpr /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(ulong value, ulong minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(ulong value, ulong minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -2398,7 +2398,7 @@ public static void IsGreaterThanOrEqualTo(ulong value, ulong minimum, [CallerArg /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -2421,7 +2421,7 @@ public static void IsInRange(ulong value, ulong minimum, ulong maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -2444,7 +2444,7 @@ public static void IsNotInRange(ulong value, ulong minimum, ulong maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -2467,7 +2467,7 @@ public static void IsBetween(ulong value, ulong minimum, ulong maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -2490,7 +2490,7 @@ public static void IsNotBetween(ulong value, ulong minimum, ulong maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -2513,7 +2513,7 @@ public static void IsBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(ulong value, ulong minimum, ulong maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -2531,7 +2531,7 @@ public static void IsNotBetweenOrEqualTo(ulong value, ulong minimum, ulong maxim /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(double value, double target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(double value, double target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -2550,7 +2550,7 @@ public static void IsEqualTo(double value, double target, [CallerArgumentExpress /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(double value, double target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(double value, double target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -2569,7 +2569,7 @@ public static void IsNotEqualTo(double value, double target, [CallerArgumentExpr /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(double value, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(double value, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -2588,7 +2588,7 @@ public static void IsLessThan(double value, double maximum, [CallerArgumentExpre /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(double value, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(double value, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -2607,7 +2607,7 @@ public static void IsLessThanOrEqualTo(double value, double maximum, [CallerArgu /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(double value, double minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(double value, double minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -2626,7 +2626,7 @@ public static void IsGreaterThan(double value, double minimum, [CallerArgumentEx /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(double value, double minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(double value, double minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -2649,7 +2649,7 @@ public static void IsGreaterThanOrEqualTo(double value, double minimum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -2672,7 +2672,7 @@ public static void IsInRange(double value, double minimum, double maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -2695,7 +2695,7 @@ public static void IsNotInRange(double value, double minimum, double maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -2718,7 +2718,7 @@ public static void IsBetween(double value, double minimum, double maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -2741,7 +2741,7 @@ public static void IsNotBetween(double value, double minimum, double maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -2764,7 +2764,7 @@ public static void IsBetweenOrEqualTo(double value, double minimum, double maxim /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(double value, double minimum, double maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -2782,7 +2782,7 @@ public static void IsNotBetweenOrEqualTo(double value, double minimum, double ma /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(decimal value, decimal target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(decimal value, decimal target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -2801,7 +2801,7 @@ public static void IsEqualTo(decimal value, decimal target, [CallerArgumentExpre /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(decimal value, decimal target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(decimal value, decimal target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -2820,7 +2820,7 @@ public static void IsNotEqualTo(decimal value, decimal target, [CallerArgumentEx /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(decimal value, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(decimal value, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -2839,7 +2839,7 @@ public static void IsLessThan(decimal value, decimal maximum, [CallerArgumentExp /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(decimal value, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(decimal value, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -2858,7 +2858,7 @@ public static void IsLessThanOrEqualTo(decimal value, decimal maximum, [CallerAr /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(decimal value, decimal minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(decimal value, decimal minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -2877,7 +2877,7 @@ public static void IsGreaterThan(decimal value, decimal minimum, [CallerArgument /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(decimal value, decimal minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(decimal value, decimal minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -2900,7 +2900,7 @@ public static void IsGreaterThanOrEqualTo(decimal value, decimal minimum, [Calle /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -2923,7 +2923,7 @@ public static void IsInRange(decimal value, decimal minimum, decimal maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -2946,7 +2946,7 @@ public static void IsNotInRange(decimal value, decimal minimum, decimal maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -2969,7 +2969,7 @@ public static void IsBetween(decimal value, decimal minimum, decimal maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -2992,7 +2992,7 @@ public static void IsNotBetween(decimal value, decimal minimum, decimal maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -3015,7 +3015,7 @@ public static void IsBetweenOrEqualTo(decimal value, decimal minimum, decimal ma /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(decimal value, decimal minimum, decimal maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -3033,7 +3033,7 @@ public static void IsNotBetweenOrEqualTo(decimal value, decimal minimum, decimal /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(nint value, nint target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(nint value, nint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -3052,7 +3052,7 @@ public static void IsEqualTo(nint value, nint target, [CallerArgumentExpression( /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(nint value, nint target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(nint value, nint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -3071,7 +3071,7 @@ public static void IsNotEqualTo(nint value, nint target, [CallerArgumentExpressi /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(nint value, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(nint value, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -3090,7 +3090,7 @@ public static void IsLessThan(nint value, nint maximum, [CallerArgumentExpressio /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(nint value, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(nint value, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -3109,7 +3109,7 @@ public static void IsLessThanOrEqualTo(nint value, nint maximum, [CallerArgument /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(nint value, nint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(nint value, nint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -3128,7 +3128,7 @@ public static void IsGreaterThan(nint value, nint minimum, [CallerArgumentExpres /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(nint value, nint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(nint value, nint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -3151,7 +3151,7 @@ public static void IsGreaterThanOrEqualTo(nint value, nint minimum, [CallerArgum /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -3174,7 +3174,7 @@ public static void IsInRange(nint value, nint minimum, nint maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -3197,7 +3197,7 @@ public static void IsNotInRange(nint value, nint minimum, nint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -3220,7 +3220,7 @@ public static void IsBetween(nint value, nint minimum, nint maximum, [CallerArgu /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -3243,7 +3243,7 @@ public static void IsNotBetween(nint value, nint minimum, nint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -3266,7 +3266,7 @@ public static void IsBetweenOrEqualTo(nint value, nint minimum, nint maximum, [C /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(nint value, nint minimum, nint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { @@ -3284,7 +3284,7 @@ public static void IsNotBetweenOrEqualTo(nint value, nint minimum, nint maximum, /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(nuint value, nuint target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(nuint value, nuint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -3303,7 +3303,7 @@ public static void IsEqualTo(nuint value, nuint target, [CallerArgumentExpressio /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(nuint value, nuint target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(nuint value, nuint target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -3322,7 +3322,7 @@ public static void IsNotEqualTo(nuint value, nuint target, [CallerArgumentExpres /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(nuint value, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(nuint value, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -3341,7 +3341,7 @@ public static void IsLessThan(nuint value, nuint maximum, [CallerArgumentExpress /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(nuint value, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(nuint value, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -3360,7 +3360,7 @@ public static void IsLessThanOrEqualTo(nuint value, nuint maximum, [CallerArgume /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(nuint value, nuint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(nuint value, nuint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -3379,7 +3379,7 @@ public static void IsGreaterThan(nuint value, nuint minimum, [CallerArgumentExpr /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(nuint value, nuint minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(nuint value, nuint minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -3402,7 +3402,7 @@ public static void IsGreaterThanOrEqualTo(nuint value, nuint minimum, [CallerArg /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -3425,7 +3425,7 @@ public static void IsInRange(nuint value, nuint minimum, nuint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -3448,7 +3448,7 @@ public static void IsNotInRange(nuint value, nuint minimum, nuint maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -3471,7 +3471,7 @@ public static void IsBetween(nuint value, nuint minimum, nuint maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -3494,7 +3494,7 @@ public static void IsNotBetween(nuint value, nuint minimum, nuint maximum, [Call /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -3517,7 +3517,7 @@ public static void IsBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(nuint value, nuint minimum, nuint maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { diff --git a/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.tt b/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.tt index c22f8837..c8c0b53d 100644 --- a/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.tt +++ b/CommunityToolkit.Diagnostics/Generated/Guard.Comparable.Numeric.tt @@ -23,7 +23,7 @@ var (type, prefix) = typeInfo; /// The name of the input parameter being tested. /// Thrown if is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value == target) { @@ -42,7 +42,7 @@ var (type, prefix) = typeInfo; /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(<#=type#> value, <#=type#> target, [CallerArgumentExpression(nameof(value))] string name = "") { if (value != target) { @@ -61,7 +61,7 @@ var (type, prefix) = typeInfo; /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < maximum) { @@ -80,7 +80,7 @@ var (type, prefix) = typeInfo; /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(<#=type#> value, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= maximum) { @@ -99,7 +99,7 @@ var (type, prefix) = typeInfo; /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum) { @@ -118,7 +118,7 @@ var (type, prefix) = typeInfo; /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(<#=type#> value, <#=type#> minimum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum) { @@ -141,7 +141,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value < maximum) { @@ -164,7 +164,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value >= maximum) { @@ -187,7 +187,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value > minimum && value < maximum) { @@ -210,7 +210,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value <= minimum || value >= maximum) { @@ -233,7 +233,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value >= minimum && value <= maximum) { @@ -256,7 +256,7 @@ var (type, prefix) = typeInfo; /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(<#=type#> value, <#=type#> minimum, <#=type#> maximum, [CallerArgumentExpression(nameof(value))] string name = "") { if (value < minimum || value > maximum) { diff --git a/CommunityToolkit.Diagnostics/Guard.Boolean.cs b/CommunityToolkit.Diagnostics/Guard.Boolean.cs index 6d65c662..3e80d32b 100644 --- a/CommunityToolkit.Diagnostics/Guard.Boolean.cs +++ b/CommunityToolkit.Diagnostics/Guard.Boolean.cs @@ -3,10 +3,14 @@ // See the LICENSE file in the project root for more information. using System; +#if NET6_0_OR_GREATER using System.ComponentModel; +#endif using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +#if NET6_0_OR_GREATER using System.Text; +#endif namespace CommunityToolkit.Diagnostics; @@ -20,7 +24,7 @@ public static partial class Guard /// The name of the input parameter being tested. /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsTrue([DoesNotReturnIf(false)] bool value, [CallerArgumentExpression("value")] string name = "") + public static void IsTrue([DoesNotReturnIf(false)] bool value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value) { @@ -55,7 +59,7 @@ public static void IsTrue([DoesNotReturnIf(false)] bool value, string name, stri /// The name of the input parameter being tested. /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsFalse([DoesNotReturnIf(true)] bool value, [CallerArgumentExpression("value")] string name = "") + public static void IsFalse([DoesNotReturnIf(true)] bool value, [CallerArgumentExpression(nameof(value))] string name = "") { if (!value) { @@ -92,7 +96,7 @@ public static void IsFalse([DoesNotReturnIf(true)] bool value, string name, stri /// A message to display if is . /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsTrue([DoesNotReturnIf(false)] bool value, string name, [InterpolatedStringHandlerArgument("value")] ref IsTrueInterpolatedStringHandler message) + public static void IsTrue([DoesNotReturnIf(false)] bool value, string name, [InterpolatedStringHandlerArgument(nameof(value))] ref IsTrueInterpolatedStringHandler message) { if (value) { @@ -110,7 +114,7 @@ public static void IsTrue([DoesNotReturnIf(false)] bool value, string name, [Int /// A message to display if is . /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsFalse([DoesNotReturnIf(true)] bool value, string name, [InterpolatedStringHandlerArgument("value")] ref IsFalseInterpolatedStringHandler message) + public static void IsFalse([DoesNotReturnIf(true)] bool value, string name, [InterpolatedStringHandlerArgument(nameof(value))] ref IsFalseInterpolatedStringHandler message) { if (!value) { diff --git a/CommunityToolkit.Diagnostics/Guard.Comparable.Generic.cs b/CommunityToolkit.Diagnostics/Guard.Comparable.Generic.cs index 2c63162c..52b2f33a 100644 --- a/CommunityToolkit.Diagnostics/Guard.Comparable.Generic.cs +++ b/CommunityToolkit.Diagnostics/Guard.Comparable.Generic.cs @@ -18,7 +18,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if is not . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsDefault(T value, [CallerArgumentExpression("value")] string name = "") + public static void IsDefault(T value, [CallerArgumentExpression(nameof(value))] string name = "") where T : struct, IEquatable { if (value.Equals(default)) @@ -37,7 +37,7 @@ public static void IsDefault(T value, [CallerArgumentExpression("value")] str /// The name of the input parameter being tested. /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotDefault(T value, [CallerArgumentExpression("value")] string name = "") + public static void IsNotDefault(T value, [CallerArgumentExpression(nameof(value))] string name = "") where T : struct, IEquatable { if (!value.Equals(default)) @@ -58,7 +58,7 @@ public static void IsNotDefault(T value, [CallerArgumentExpression("value")] /// Thrown if is != . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEqualTo(T value, T target, [CallerArgumentExpression("value")] string name = "") + public static void IsEqualTo(T value, T target, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IEquatable { if (value.Equals(target)) @@ -79,7 +79,7 @@ public static void IsEqualTo(T value, T target, [CallerArgumentExpression("va /// Thrown if is == . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEqualTo(T value, T target, [CallerArgumentExpression("value")] string name = "") + public static void IsNotEqualTo(T value, T target, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IEquatable { if (!value.Equals(target)) @@ -99,7 +99,7 @@ public static void IsNotEqualTo(T value, T target, [CallerArgumentExpression( /// The name of the input parameter being tested. /// Thrown if is not a bitwise match for . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void IsBitwiseEqualTo(T value, T target, [CallerArgumentExpression("value")] string name = "") + public static unsafe void IsBitwiseEqualTo(T value, T target, [CallerArgumentExpression(nameof(value))] string name = "") where T : unmanaged { // Include some fast paths if the input type is of size 1, 2, 4, 8, or 16. @@ -214,7 +214,7 @@ private static unsafe bool Bit64Compare(ref ulong left, ref ulong right) /// Thrown if is >= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThan(T value, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThan(T value, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(maximum) < 0) @@ -235,7 +235,7 @@ public static void IsLessThan(T value, T maximum, [CallerArgumentExpression(" /// Thrown if is > . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsLessThanOrEqualTo(T value, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsLessThanOrEqualTo(T value, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(maximum) <= 0) @@ -256,7 +256,7 @@ public static void IsLessThanOrEqualTo(T value, T maximum, [CallerArgumentExp /// Thrown if is <= . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThan(T value, T minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThan(T value, T minimum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) > 0) @@ -277,7 +277,7 @@ public static void IsGreaterThan(T value, T minimum, [CallerArgumentExpressio /// Thrown if is < . /// The method is generic to avoid boxing the parameters, if they are value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsGreaterThanOrEqualTo(T value, T minimum, [CallerArgumentExpression("value")] string name = "") + public static void IsGreaterThanOrEqualTo(T value, T minimum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) >= 0) @@ -302,7 +302,7 @@ public static void IsGreaterThanOrEqualTo(T value, T minimum, [CallerArgument /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRange(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsInRange(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) >= 0 && value.CompareTo(maximum) < 0) @@ -327,7 +327,7 @@ public static void IsInRange(T value, T minimum, T maximum, [CallerArgumentEx /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRange(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotInRange(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) < 0 || value.CompareTo(maximum) >= 0) @@ -352,7 +352,7 @@ public static void IsNotInRange(T value, T minimum, T maximum, [CallerArgumen /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetween(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetween(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) > 0 && value.CompareTo(maximum) < 0) @@ -377,7 +377,7 @@ public static void IsBetween(T value, T minimum, T maximum, [CallerArgumentEx /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetween(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetween(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) <= 0 || value.CompareTo(maximum) >= 0) @@ -402,7 +402,7 @@ public static void IsNotBetween(T value, T minimum, T maximum, [CallerArgumen /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsBetweenOrEqualTo(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsBetweenOrEqualTo(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) >= 0 && value.CompareTo(maximum) <= 0) @@ -427,7 +427,7 @@ public static void IsBetweenOrEqualTo(T value, T minimum, T maximum, [CallerA /// The method is generic to avoid boxing the parameters, if they are value types. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotBetweenOrEqualTo(T value, T minimum, T maximum, [CallerArgumentExpression("value")] string name = "") + public static void IsNotBetweenOrEqualTo(T value, T minimum, T maximum, [CallerArgumentExpression(nameof(value))] string name = "") where T : notnull, IComparable { if (value.CompareTo(minimum) < 0 || value.CompareTo(maximum) > 0) diff --git a/CommunityToolkit.Diagnostics/Guard.Comparable.Numeric.cs b/CommunityToolkit.Diagnostics/Guard.Comparable.Numeric.cs index 874f093d..a69b96f4 100644 --- a/CommunityToolkit.Diagnostics/Guard.Comparable.Numeric.cs +++ b/CommunityToolkit.Diagnostics/Guard.Comparable.Numeric.cs @@ -19,7 +19,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if ( - ) > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCloseTo(int value, int target, uint delta, [CallerArgumentExpression("value")] string name = "") + public static void IsCloseTo(int value, int target, uint delta, [CallerArgumentExpression(nameof(value))] string name = "") { uint difference; @@ -49,7 +49,7 @@ public static void IsCloseTo(int value, int target, uint delta, [CallerArgumentE /// The name of the input parameter being tested. /// Thrown if ( - ) <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCloseTo(int value, int target, uint delta, [CallerArgumentExpression("value")] string name = "") + public static void IsNotCloseTo(int value, int target, uint delta, [CallerArgumentExpression(nameof(value))] string name = "") { uint difference; @@ -79,7 +79,7 @@ public static void IsNotCloseTo(int value, int target, uint delta, [CallerArgume /// The name of the input parameter being tested. /// Thrown if ( - ) > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCloseTo(long value, long target, ulong delta, [CallerArgumentExpression("value")] string name = "") + public static void IsCloseTo(long value, long target, ulong delta, [CallerArgumentExpression(nameof(value))] string name = "") { ulong difference; @@ -109,7 +109,7 @@ public static void IsCloseTo(long value, long target, ulong delta, [CallerArgume /// The name of the input parameter being tested. /// Thrown if ( - ) <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCloseTo(long value, long target, ulong delta, [CallerArgumentExpression("value")] string name = "") + public static void IsNotCloseTo(long value, long target, ulong delta, [CallerArgumentExpression(nameof(value))] string name = "") { ulong difference; @@ -139,7 +139,7 @@ public static void IsNotCloseTo(long value, long target, ulong delta, [CallerArg /// The name of the input parameter being tested. /// Thrown if ( - ) > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCloseTo(float value, float target, float delta, [CallerArgumentExpression("value")] string name = "") + public static void IsCloseTo(float value, float target, float delta, [CallerArgumentExpression(nameof(value))] string name = "") { if (Math.Abs(value - target) <= delta) { @@ -158,7 +158,7 @@ public static void IsCloseTo(float value, float target, float delta, [CallerArgu /// The name of the input parameter being tested. /// Thrown if ( - ) <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCloseTo(float value, float target, float delta, [CallerArgumentExpression("value")] string name = "") + public static void IsNotCloseTo(float value, float target, float delta, [CallerArgumentExpression(nameof(value))] string name = "") { if (Math.Abs(value - target) > delta) { @@ -177,7 +177,7 @@ public static void IsNotCloseTo(float value, float target, float delta, [CallerA /// The name of the input parameter being tested. /// Thrown if ( - ) > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCloseTo(double value, double target, double delta, [CallerArgumentExpression("value")] string name = "") + public static void IsCloseTo(double value, double target, double delta, [CallerArgumentExpression(nameof(value))] string name = "") { if (Math.Abs(value - target) <= delta) { @@ -196,7 +196,7 @@ public static void IsCloseTo(double value, double target, double delta, [CallerA /// The name of the input parameter being tested. /// Thrown if ( - ) <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCloseTo(double value, double target, double delta, [CallerArgumentExpression("value")] string name = "") + public static void IsNotCloseTo(double value, double target, double delta, [CallerArgumentExpression(nameof(value))] string name = "") { if (Math.Abs(value - target) > delta) { @@ -215,7 +215,7 @@ public static void IsNotCloseTo(double value, double target, double delta, [Call /// The name of the input parameter being tested. /// Thrown if ( - ) > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCloseTo(nint value, nint target, nuint delta, [CallerArgumentExpression("value")] string name = "") + public static void IsCloseTo(nint value, nint target, nuint delta, [CallerArgumentExpression(nameof(value))] string name = "") { nuint difference; @@ -245,7 +245,7 @@ public static void IsCloseTo(nint value, nint target, nuint delta, [CallerArgume /// The name of the input parameter being tested. /// Thrown if ( - ) <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCloseTo(nint value, nint target, nuint delta, [CallerArgumentExpression("value")] string name = "") + public static void IsNotCloseTo(nint value, nint target, nuint delta, [CallerArgumentExpression(nameof(value))] string name = "") { nuint difference; diff --git a/CommunityToolkit.Diagnostics/Guard.IO.cs b/CommunityToolkit.Diagnostics/Guard.IO.cs index 7d58cdc7..a4446782 100644 --- a/CommunityToolkit.Diagnostics/Guard.IO.cs +++ b/CommunityToolkit.Diagnostics/Guard.IO.cs @@ -18,7 +18,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if doesn't support reading. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void CanRead(Stream stream, [CallerArgumentExpression("stream")] string name = "") + public static void CanRead(Stream stream, [CallerArgumentExpression(nameof(stream))] string name = "") { if (stream.CanRead) { @@ -35,7 +35,7 @@ public static void CanRead(Stream stream, [CallerArgumentExpression("stream")] s /// The name of the input parameter being tested. /// Thrown if doesn't support writing. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void CanWrite(Stream stream, [CallerArgumentExpression("stream")] string name = "") + public static void CanWrite(Stream stream, [CallerArgumentExpression(nameof(stream))] string name = "") { if (stream.CanWrite) { @@ -52,7 +52,7 @@ public static void CanWrite(Stream stream, [CallerArgumentExpression("stream")] /// The name of the input parameter being tested. /// Thrown if doesn't support seeking. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void CanSeek(Stream stream, [CallerArgumentExpression("stream")] string name = "") + public static void CanSeek(Stream stream, [CallerArgumentExpression(nameof(stream))] string name = "") { if (stream.CanSeek) { @@ -69,7 +69,7 @@ public static void CanSeek(Stream stream, [CallerArgumentExpression("stream")] s /// The name of the input parameter being tested. /// Thrown if is not at the starting position. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsAtStartPosition(Stream stream, [CallerArgumentExpression("stream")] string name = "") + public static void IsAtStartPosition(Stream stream, [CallerArgumentExpression(nameof(stream))] string name = "") { if (stream.Position == 0) { diff --git a/CommunityToolkit.Diagnostics/Guard.String.cs b/CommunityToolkit.Diagnostics/Guard.String.cs index ef2d6f96..4261c393 100644 --- a/CommunityToolkit.Diagnostics/Guard.String.cs +++ b/CommunityToolkit.Diagnostics/Guard.String.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Runtime.CompilerServices; #pragma warning disable CS8777 @@ -20,7 +21,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if is neither nor empty. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNullOrEmpty(string? text, [CallerArgumentExpression("text")] string name = "") + public static void IsNullOrEmpty(string? text, [CallerArgumentExpression(nameof(text))] string name = "") { if (string.IsNullOrEmpty(text)) { @@ -38,7 +39,7 @@ public static void IsNullOrEmpty(string? text, [CallerArgumentExpression("text") /// Thrown if is . /// Thrown if is empty. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotNullOrEmpty([NotNull] string? text, [CallerArgumentExpression("text")] string name = "") + public static void IsNotNullOrEmpty([NotNull] string? text, [CallerArgumentExpression(nameof(text))] string name = "") { if (!string.IsNullOrEmpty(text)) { @@ -55,7 +56,7 @@ public static void IsNotNullOrEmpty([NotNull] string? text, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if is neither nor whitespace. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNullOrWhiteSpace(string? text, [CallerArgumentExpression("text")] string name = "") + public static void IsNullOrWhiteSpace(string? text, [CallerArgumentExpression(nameof(text))] string name = "") { if (string.IsNullOrWhiteSpace(text)) { @@ -73,7 +74,7 @@ public static void IsNullOrWhiteSpace(string? text, [CallerArgumentExpression("t /// Thrown if is . /// Thrown if is whitespace. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotNullOrWhiteSpace([NotNull] string? text, [CallerArgumentExpression("text")] string name = "") + public static void IsNotNullOrWhiteSpace([NotNull] string? text, [CallerArgumentExpression(nameof(text))] string name = "") { if (!string.IsNullOrWhiteSpace(text)) { @@ -90,7 +91,7 @@ public static void IsNotNullOrWhiteSpace([NotNull] string? text, [CallerArgument /// The name of the input parameter being tested. /// Thrown if is empty. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsEmpty(string text, [CallerArgumentExpression("text")] string name = "") + public static void IsEmpty(string text, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length == 0) { @@ -107,7 +108,7 @@ public static void IsEmpty(string text, [CallerArgumentExpression("text")] strin /// The name of the input parameter being tested. /// Thrown if is empty. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotEmpty(string text, [CallerArgumentExpression("text")] string name = "") + public static void IsNotEmpty(string text, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length != 0) { @@ -124,7 +125,7 @@ public static void IsNotEmpty(string text, [CallerArgumentExpression("text")] st /// The name of the input parameter being tested. /// Thrown if is neither nor whitespace. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsWhiteSpace(string text, [CallerArgumentExpression("text")] string name = "") + public static void IsWhiteSpace(string text, [CallerArgumentExpression(nameof(text))] string name = "") { if (string.IsNullOrWhiteSpace(text)) { @@ -141,7 +142,7 @@ public static void IsWhiteSpace(string text, [CallerArgumentExpression("text")] /// The name of the input parameter being tested. /// Thrown if is or whitespace. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotWhiteSpace(string text, [CallerArgumentExpression("text")] string name = "") + public static void IsNotWhiteSpace(string text, [CallerArgumentExpression(nameof(text))] string name = "") { if (!string.IsNullOrWhiteSpace(text)) { @@ -159,7 +160,7 @@ public static void IsNotWhiteSpace(string text, [CallerArgumentExpression("text" /// The name of the input parameter being tested. /// Thrown if the size of is != . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeEqualTo(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length == size) { @@ -177,7 +178,7 @@ public static void HasSizeEqualTo(string text, int size, [CallerArgumentExpressi /// The name of the input parameter being tested. /// Thrown if the size of is == . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeNotEqualTo(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeNotEqualTo(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length != size) { @@ -195,7 +196,7 @@ public static void HasSizeNotEqualTo(string text, int size, [CallerArgumentExpre /// The name of the input parameter being tested. /// Thrown if the size of is <= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThan(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeGreaterThan(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length > size) { @@ -213,7 +214,7 @@ public static void HasSizeGreaterThan(string text, int size, [CallerArgumentExpr /// The name of the input parameter being tested. /// Thrown if the size of is < . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeGreaterThanOrEqualTo(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeGreaterThanOrEqualTo(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length >= size) { @@ -231,7 +232,7 @@ public static void HasSizeGreaterThanOrEqualTo(string text, int size, [CallerArg /// The name of the input parameter being tested. /// Thrown if the size of is >= . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThan(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeLessThan(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length < size) { @@ -249,7 +250,7 @@ public static void HasSizeLessThan(string text, int size, [CallerArgumentExpress /// The name of the input parameter being tested. /// Thrown if the size of is > . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(string text, int size, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeLessThanOrEqualTo(string text, int size, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length <= size) { @@ -268,7 +269,7 @@ public static void HasSizeLessThanOrEqualTo(string text, int size, [CallerArgume /// Thrown if the size of is != the one of . /// The type is immutable, but the name of this API is kept for consistency with the other overloads. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeEqualTo(string text, string destination, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeEqualTo(string text, string destination, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length == destination.Length) { @@ -287,7 +288,7 @@ public static void HasSizeEqualTo(string text, string destination, [CallerArgume /// Thrown if the size of is > the one of . /// The type is immutable, but the name of this API is kept for consistency with the other overloads. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasSizeLessThanOrEqualTo(string text, string destination, [CallerArgumentExpression("text")] string name = "") + public static void HasSizeLessThanOrEqualTo(string text, string destination, [CallerArgumentExpression(nameof(text))] string name = "") { if (text.Length <= destination.Length) { @@ -305,7 +306,7 @@ public static void HasSizeLessThanOrEqualTo(string text, string destination, [Ca /// The name of the input parameter being tested. /// Thrown if is not valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsInRangeFor(int index, string text, [CallerArgumentExpression("index")] string name = "") + public static void IsInRangeFor(int index, string text, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index < (uint)text.Length) { @@ -323,7 +324,7 @@ public static void IsInRangeFor(int index, string text, [CallerArgumentExpressio /// The name of the input parameter being tested. /// Thrown if is valid to access . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotInRangeFor(int index, string text, [CallerArgumentExpression("index")] string name = "") + public static void IsNotInRangeFor(int index, string text, [CallerArgumentExpression(nameof(index))] string name = "") { if ((uint)index >= (uint)text.Length) { diff --git a/CommunityToolkit.Diagnostics/Guard.Tasks.cs b/CommunityToolkit.Diagnostics/Guard.Tasks.cs index ea5ffdd6..b3e1970c 100644 --- a/CommunityToolkit.Diagnostics/Guard.Tasks.cs +++ b/CommunityToolkit.Diagnostics/Guard.Tasks.cs @@ -18,7 +18,7 @@ partial class Guard /// The name of the input parameter being tested. /// Thrown if is not in a completed state. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCompleted(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsCompleted(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.IsCompleted) { @@ -35,7 +35,7 @@ public static void IsCompleted(Task task, [CallerArgumentExpression("task")] str /// The name of the input parameter being tested. /// Thrown if is in a completed state. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCompleted(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsNotCompleted(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (!task.IsCompleted) { @@ -52,7 +52,7 @@ public static void IsNotCompleted(Task task, [CallerArgumentExpression("task")] /// The name of the input parameter being tested. /// Thrown if has not been completed successfully. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCompletedSuccessfully(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsCompletedSuccessfully(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.Status == TaskStatus.RanToCompletion) { @@ -69,7 +69,7 @@ public static void IsCompletedSuccessfully(Task task, [CallerArgumentExpression( /// The name of the input parameter being tested. /// Thrown if has been completed successfully. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCompletedSuccessfully(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsNotCompletedSuccessfully(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.Status != TaskStatus.RanToCompletion) { @@ -86,7 +86,7 @@ public static void IsNotCompletedSuccessfully(Task task, [CallerArgumentExpressi /// The name of the input parameter being tested. /// Thrown if is not faulted. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsFaulted(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsFaulted(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.IsFaulted) { @@ -103,7 +103,7 @@ public static void IsFaulted(Task task, [CallerArgumentExpression("task")] strin /// The name of the input parameter being tested. /// Thrown if is faulted. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotFaulted(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsNotFaulted(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (!task.IsFaulted) { @@ -120,7 +120,7 @@ public static void IsNotFaulted(Task task, [CallerArgumentExpression("task")] st /// The name of the input parameter being tested. /// Thrown if is not canceled. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsCanceled(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsCanceled(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.IsCanceled) { @@ -137,7 +137,7 @@ public static void IsCanceled(Task task, [CallerArgumentExpression("task")] stri /// The name of the input parameter being tested. /// Thrown if is canceled. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotCanceled(Task task, [CallerArgumentExpression("task")] string name = "") + public static void IsNotCanceled(Task task, [CallerArgumentExpression(nameof(task))] string name = "") { if (!task.IsCanceled) { @@ -155,7 +155,7 @@ public static void IsNotCanceled(Task task, [CallerArgumentExpression("task")] s /// The name of the input parameter being tested. /// Thrown if doesn't match . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasStatusEqualTo(Task task, TaskStatus status, [CallerArgumentExpression("task")] string name = "") + public static void HasStatusEqualTo(Task task, TaskStatus status, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.Status == status) { @@ -173,7 +173,7 @@ public static void HasStatusEqualTo(Task task, TaskStatus status, [CallerArgumen /// The name of the input parameter being tested. /// Thrown if matches . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasStatusNotEqualTo(Task task, TaskStatus status, [CallerArgumentExpression("task")] string name = "") + public static void HasStatusNotEqualTo(Task task, TaskStatus status, [CallerArgumentExpression(nameof(task))] string name = "") { if (task.Status != status) { diff --git a/CommunityToolkit.Diagnostics/Guard.cs b/CommunityToolkit.Diagnostics/Guard.cs index fc8f48fa..f0141080 100644 --- a/CommunityToolkit.Diagnostics/Guard.cs +++ b/CommunityToolkit.Diagnostics/Guard.cs @@ -23,7 +23,7 @@ public static partial class Guard /// The name of the input parameter being tested. /// Thrown if is not . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNull(T? value, [CallerArgumentExpression("value")] string name = "") + public static void IsNull(T? value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value is null) { @@ -41,7 +41,7 @@ public static void IsNull(T? value, [CallerArgumentExpression("value")] strin /// The name of the input parameter being tested. /// Thrown if is not . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNull(T? value, [CallerArgumentExpression("value")] string name = "") + public static void IsNull(T? value, [CallerArgumentExpression(nameof(value))] string name = "") where T : struct { if (value is null) @@ -60,7 +60,7 @@ public static void IsNull(T? value, [CallerArgumentExpression("value")] strin /// The name of the input parameter being tested. /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression("value")] string name = "") + public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value is not null) { @@ -78,7 +78,7 @@ public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression("v /// The name of the input parameter being tested. /// Thrown if is . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression("value")] string name = "") + public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression(nameof(value))] string name = "") where T : struct { if (value is not null) @@ -97,7 +97,7 @@ public static void IsNotNull([NotNull] T? value, [CallerArgumentExpression("v /// The name of the input parameter being tested. /// Thrown if is not of type . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsOfType(object value, [CallerArgumentExpression("value")] string name = "") + public static void IsOfType(object value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value.GetType() == typeof(T)) { @@ -115,7 +115,7 @@ public static void IsOfType(object value, [CallerArgumentExpression("value")] /// The name of the input parameter being tested. /// Thrown if is of type . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotOfType(object value, [CallerArgumentExpression("value")] string name = "") + public static void IsNotOfType(object value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value.GetType() != typeof(T)) { @@ -133,7 +133,7 @@ public static void IsNotOfType(object value, [CallerArgumentExpression("value /// The name of the input parameter being tested. /// Thrown if the type of is not the same as . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsOfType(object value, Type type, [CallerArgumentExpression("value")] string name = "") + public static void IsOfType(object value, Type type, [CallerArgumentExpression(nameof(value))] string name = "") { if (value.GetType() == type) { @@ -151,7 +151,7 @@ public static void IsOfType(object value, Type type, [CallerArgumentExpression(" /// The name of the input parameter being tested. /// Thrown if the type of is the same as . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotOfType(object value, Type type, [CallerArgumentExpression("value")] string name = "") + public static void IsNotOfType(object value, Type type, [CallerArgumentExpression(nameof(value))] string name = "") { if (value.GetType() != type) { @@ -169,7 +169,7 @@ public static void IsNotOfType(object value, Type type, [CallerArgumentExpressio /// The name of the input parameter being tested. /// Thrown if can't be assigned to type . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsAssignableToType(object value, [CallerArgumentExpression("value")] string name = "") + public static void IsAssignableToType(object value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value is T) { @@ -187,7 +187,7 @@ public static void IsAssignableToType(object value, [CallerArgumentExpression /// The name of the input parameter being tested. /// Thrown if can be assigned to type . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotAssignableToType(object value, [CallerArgumentExpression("value")] string name = "") + public static void IsNotAssignableToType(object value, [CallerArgumentExpression(nameof(value))] string name = "") { if (value is not T) { @@ -205,7 +205,7 @@ public static void IsNotAssignableToType(object value, [CallerArgumentExpress /// The name of the input parameter being tested. /// Thrown if can't be assigned to . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsAssignableToType(object value, Type type, [CallerArgumentExpression("value")] string name = "") + public static void IsAssignableToType(object value, Type type, [CallerArgumentExpression(nameof(value))] string name = "") { if (type.IsInstanceOfType(value)) { @@ -223,7 +223,7 @@ public static void IsAssignableToType(object value, Type type, [CallerArgumentEx /// The name of the input parameter being tested. /// Thrown if can be assigned to . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsNotAssignableToType(object value, Type type, [CallerArgumentExpression("value")] string name = "") + public static void IsNotAssignableToType(object value, Type type, [CallerArgumentExpression(nameof(value))] string name = "") { if (!type.IsInstanceOfType(value)) { @@ -243,7 +243,7 @@ public static void IsNotAssignableToType(object value, Type type, [CallerArgumen /// Thrown if is not the same instance as . /// The method is generic to prevent using it with value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsReferenceEqualTo(T value, T target, [CallerArgumentExpression("value")] string name = "") + public static void IsReferenceEqualTo(T value, T target, [CallerArgumentExpression(nameof(value))] string name = "") where T : class { if (ReferenceEquals(value, target)) @@ -264,7 +264,7 @@ public static void IsReferenceEqualTo(T value, T target, [CallerArgumentExpre /// Thrown if is the same instance as . /// The method is generic to prevent using it with value types. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void IsReferenceNotEqualTo(T value, T target, [CallerArgumentExpression("value")] string name = "") + public static void IsReferenceNotEqualTo(T value, T target, [CallerArgumentExpression(nameof(value))] string name = "") where T : class { if (!ReferenceEquals(value, target)) diff --git a/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs b/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs index ac82eb33..f3252a29 100644 --- a/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs +++ b/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs @@ -97,7 +97,7 @@ protected void OnPropertyChanging([CallerMemberName] string? propertyName = null /// The and events are not raised /// if the current and new value for the target property are the same. /// - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, [CallerMemberName] string? propertyName = null) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, [CallerMemberName] string? propertyName = null) { // We duplicate the code here instead of calling the overload because we can't // guarantee that the invoked SetProperty will be inlined, and we need the JIT @@ -134,7 +134,7 @@ protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newV /// (optional) The name of the property that changed. /// if the property was changed, otherwise. /// Thrown if is . - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, IEqualityComparer comparer, [CallerMemberName] string? propertyName = null) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, IEqualityComparer comparer, [CallerMemberName] string? propertyName = null) { ArgumentNullException.ThrowIfNull(comparer); diff --git a/CommunityToolkit.Mvvm/ComponentModel/ObservableRecipient.cs b/CommunityToolkit.Mvvm/ComponentModel/ObservableRecipient.cs index e6598825..63b28441 100644 --- a/CommunityToolkit.Mvvm/ComponentModel/ObservableRecipient.cs +++ b/CommunityToolkit.Mvvm/ComponentModel/ObservableRecipient.cs @@ -152,7 +152,7 @@ protected virtual void Broadcast(T oldValue, T newValue, string? propertyName /// the and events /// are not raised if the current and new value for the target property are the same. /// - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, bool broadcast, [CallerMemberName] string? propertyName = null) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, bool broadcast, [CallerMemberName] string? propertyName = null) { T oldValue = field; @@ -182,7 +182,7 @@ protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newV /// (optional) The name of the property that changed. /// if the property was changed, otherwise. /// Thrown if is . - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, IEqualityComparer comparer, bool broadcast, [CallerMemberName] string? propertyName = null) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, IEqualityComparer comparer, bool broadcast, [CallerMemberName] string? propertyName = null) { ArgumentNullException.ThrowIfNull(comparer); diff --git a/CommunityToolkit.Mvvm/ComponentModel/ObservableValidator.cs b/CommunityToolkit.Mvvm/ComponentModel/ObservableValidator.cs index a39af634..02921bf0 100644 --- a/CommunityToolkit.Mvvm/ComponentModel/ObservableValidator.cs +++ b/CommunityToolkit.Mvvm/ComponentModel/ObservableValidator.cs @@ -145,7 +145,7 @@ protected ObservableValidator(ValidationContext validationContext) /// /// Thrown if is . [RequiresUnreferencedCode("The type of the current instance cannot be statically discovered.")] - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, bool validate, [CallerMemberName] string propertyName = null!) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, bool validate, [CallerMemberName] string propertyName = null!) { ArgumentNullException.ThrowIfNull(propertyName); @@ -174,7 +174,7 @@ protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newV /// if the property was changed, otherwise. /// Thrown if or are . [RequiresUnreferencedCode("The type of the current instance cannot be statically discovered.")] - protected bool SetProperty([NotNullIfNotNull("newValue")] ref T field, T newValue, IEqualityComparer comparer, bool validate, [CallerMemberName] string propertyName = null!) + protected bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, IEqualityComparer comparer, bool validate, [CallerMemberName] string propertyName = null!) { ArgumentNullException.ThrowIfNull(comparer); ArgumentNullException.ThrowIfNull(propertyName); diff --git a/CommunityToolkit.Mvvm/Properties/Polyfills/ArgumentNullException.cs b/CommunityToolkit.Mvvm/Properties/Polyfills/ArgumentNullException.cs index 9a0408ac..00647683 100644 --- a/CommunityToolkit.Mvvm/Properties/Polyfills/ArgumentNullException.cs +++ b/CommunityToolkit.Mvvm/Properties/Polyfills/ArgumentNullException.cs @@ -18,7 +18,7 @@ internal sealed class ArgumentNullException /// The reference type argument to validate as non-. /// The name of the parameter with which corresponds. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpression("argument")] string? paramName = null) + public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) { if (argument is null) { @@ -42,7 +42,7 @@ public static class For /// The reference type argument to validate as non-. /// The name of the parameter with which corresponds. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ThrowIfNull([NotNull] T? argument, [CallerArgumentExpression("argument")] string? paramName = null) + public static void ThrowIfNull([NotNull] T? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) { if (argument is null) { From f9bb4a451c4565ed3ef8e7691ece2eb42767c8a0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Oct 2022 13:11:58 +0200 Subject: [PATCH 4/6] Use raw multiline string literals in diagnostics tests --- .../Test_SourceGeneratorsDiagnostics.cs | 383 ++++++++++-------- 1 file changed, 225 insertions(+), 158 deletions(-) diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs index 9239be52..68fbf292 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs @@ -24,7 +24,7 @@ public class Test_SourceGeneratorsDiagnostics [TestMethod] public void DuplicateINotifyPropertyChangedInterfaceForINotifyPropertyChangedAttributeError_Explicit() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -35,7 +35,8 @@ public partial class SampleViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0001"); } @@ -43,7 +44,7 @@ public partial class SampleViewModel : INotifyPropertyChanged [TestMethod] public void DuplicateINotifyPropertyChangedInterfaceForINotifyPropertyChangedAttributeError_Inherited() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -62,7 +63,8 @@ namespace MyApp public partial class SampleViewModel : ObservableObject { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0001"); } @@ -70,7 +72,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void DuplicateINotifyPropertyChangedInterfaceForObservableObjectAttributeError_Explicit() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -81,7 +83,8 @@ public partial class SampleViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0002"); } @@ -89,7 +92,7 @@ public partial class SampleViewModel : INotifyPropertyChanged [TestMethod] public void DuplicateINotifyPropertyChangedInterfaceForObservableObjectAttributeError_Inherited() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -107,7 +110,8 @@ namespace MyApp public partial class SampleViewModel : ObservableObject { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0002"); } @@ -115,7 +119,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void DuplicateINotifyPropertyChangingInterfaceForObservableObjectAttributeError_Explicit() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -126,7 +130,8 @@ public partial class SampleViewModel : INotifyPropertyChanging { public event PropertyChangingEventHandler? PropertyChanging; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0003"); } @@ -134,7 +139,7 @@ public partial class SampleViewModel : INotifyPropertyChanging [TestMethod] public void DuplicateINotifyPropertyChangingInterfaceForObservableObjectAttributeError_Inherited() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -149,7 +154,8 @@ public abstract class MyBaseViewModel : INotifyPropertyChanging public partial class SampleViewModel : MyBaseViewModel { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0003"); } @@ -157,7 +163,7 @@ public partial class SampleViewModel : MyBaseViewModel [TestMethod] public void DuplicateObservableRecipientError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace CommunityToolkit.Mvvm.ComponentModel @@ -173,7 +179,8 @@ namespace MyApp public partial class SampleViewModel : ObservableRecipient { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0004"); } @@ -181,7 +188,7 @@ public partial class SampleViewModel : ObservableRecipient [TestMethod] public void MissingBaseObservableObjectFunctionalityError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -190,7 +197,8 @@ namespace MyApp public partial class SampleViewModel { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0005"); } @@ -198,7 +206,7 @@ public partial class SampleViewModel [TestMethod] public void MissingObservableValidatorInheritanceForValidationAttributeError() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -211,7 +219,8 @@ public partial class SampleViewModel [Required] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0006"); } @@ -219,7 +228,7 @@ public partial class SampleViewModel [TestMethod] public void InvalidRelayCommandMethodSignatureError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -227,9 +236,10 @@ namespace MyApp public partial class SampleViewModel { [RelayCommand] - private string GreetUser() => ""Hello world!""; + private string GreetUser() => "Hello world!"; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0007"); } @@ -237,7 +247,7 @@ public partial class SampleViewModel [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromINotifyPropertyChangedGenerator() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -246,7 +256,8 @@ namespace MyApp public partial class {|MVVMTK0008:SampleViewModel|} { } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -254,7 +265,7 @@ public partial class {|MVVMTK0008:SampleViewModel|} [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromObservableObjectGenerator() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -263,7 +274,8 @@ namespace MyApp public partial class {|MVVMTK0008:SampleViewModel|} { } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -271,7 +283,7 @@ public partial class {|MVVMTK0008:SampleViewModel|} [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromObservablePropertyGenerator() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -282,7 +294,8 @@ public partial class {|MVVMTK0008:SampleViewModel|} [ObservableProperty] private string {|MVVMTK0008:name|}; } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -290,7 +303,7 @@ public partial class {|MVVMTK0008:SampleViewModel|} [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromObservablePropertyGenerator_MultipleAttributes() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -307,7 +320,8 @@ public partial class {|MVVMTK0008:SampleViewModel|} string Bar { get; set; } } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -315,7 +329,7 @@ public partial class {|MVVMTK0008:SampleViewModel|} [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromObservableValidatorValidateAllPropertiesGenerator() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -326,7 +340,8 @@ public partial class SampleViewModel : ObservableValidator [Required] public string Name { get; set; } } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -334,7 +349,7 @@ public partial class SampleViewModel : ObservableValidator [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromRelayCommandGenerator() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -346,7 +361,8 @@ public partial class SampleViewModel { } } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -354,7 +370,7 @@ public partial class SampleViewModel [TestMethod] public async Task UnsupportedCSharpLanguageVersion_FromIMessengerRegisterAllGenerator() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Messaging; namespace MyApp @@ -369,7 +385,8 @@ public void Receive(MyMessage message) { } } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp7_3); } @@ -377,7 +394,7 @@ public void Receive(MyMessage message) [TestMethod] public void InvalidCanExecuteMemberName() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -386,12 +403,13 @@ public partial class SampleViewModel { private bool Foo => true; - [RelayCommand(CanExecute = ""Bar"")] + [RelayCommand(CanExecute = "Bar")] private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0009"); } @@ -399,7 +417,7 @@ private void GreetUser() [TestMethod] public void MultipleCanExecuteMemberNameMatches() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -415,7 +433,8 @@ private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0010"); } @@ -423,7 +442,7 @@ private void GreetUser() [TestMethod] public void InvalidCanExecuteMember_NonReadableProperty() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -437,7 +456,8 @@ private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -445,21 +465,22 @@ private void GreetUser() [TestMethod] public void InvalidCanExecuteMember_PropertyWithInvalidType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp { public partial class SampleViewModel { - private string Foo => ""Hi!""; + private string Foo => "Hi!"; [RelayCommand(CanExecute = nameof(Foo))] private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -467,21 +488,22 @@ private void GreetUser() [TestMethod] public void InvalidCanExecuteMember_MethodWithInvalidType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp { public partial class SampleViewModel { - private string Foo() => ""Hi!""; + private string Foo() => "Hi!"; [RelayCommand(CanExecute = nameof(Foo))] private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -489,7 +511,7 @@ private void GreetUser() [TestMethod] public void InvalidCanExecuteMember_MethodWithIncompatibleInputType_MissingInput() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -503,7 +525,8 @@ private void GreetUser() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -511,7 +534,7 @@ private void GreetUser() [TestMethod] public void InvalidCanExecuteMember_MethodWithIncompatibleInputType_NonMatchingInputType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -525,7 +548,8 @@ private void GreetUser(string name) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -533,7 +557,7 @@ private void GreetUser(string name) [TestMethod] public void InvalidCanExecuteMember_MethodWithIncompatibleInputType_TooManyInputs() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -547,7 +571,8 @@ private void GreetUser(string name) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0011"); } @@ -555,7 +580,7 @@ private void GreetUser(string name) [TestMethod] public void InvalidRelayCommandAllowConcurrentExecutionsOption() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -567,7 +592,8 @@ private void GreetUser(User user) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0012"); } @@ -575,7 +601,7 @@ private void GreetUser(User user) [TestMethod] public void InvalidRelayCommandIncludeCancelCommandSettings_SynchronousMethod() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -587,7 +613,8 @@ private void GreetUser(User user) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0013"); } @@ -595,7 +622,7 @@ private void GreetUser(User user) [TestMethod] public void InvalidRelayCommandIncludeCancelCommandSettings_AsynchronousMethodWithNoCancellationToken() { - string source = @" + string source = """ using System.Threading.Tasks; using CommunityToolkit.Mvvm.Input; @@ -608,7 +635,8 @@ private async Task DoWorkAsync() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0013"); } @@ -616,7 +644,7 @@ private async Task DoWorkAsync() [TestMethod] public void InvalidRelayCommandIncludeCancelCommandSettings_AsynchronousMethodWithParameterAndNoCancellationToken() { - string source = @" + string source = """ using System.Threading.Tasks; using CommunityToolkit.Mvvm.Input; @@ -629,7 +657,8 @@ private async Task GreetUserAsync(User user) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0013"); } @@ -637,7 +666,7 @@ private async Task GreetUserAsync(User user) [TestMethod] public void NameCollisionForGeneratedObservableProperty() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -647,7 +676,8 @@ public partial class SampleViewModel : ObservableObject [ObservableProperty] private string Name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0014"); } @@ -655,7 +685,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyPropertyChangedForInvalidTargetError_Null() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -666,7 +696,8 @@ public partial class SampleViewModel : ObservableObject [NotifyPropertyChangedFor(null)] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0015"); } @@ -674,7 +705,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyPropertyChangedForInvalidTargetError_SamePropertyAsGeneratedOneFromSelf() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -685,7 +716,8 @@ public partial class SampleViewModel : ObservableObject [NotifyPropertyChangedFor(nameof(Name))] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0015"); } @@ -693,7 +725,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyPropertyChangedForInvalidTargetError_Missing() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -701,10 +733,11 @@ namespace MyApp public partial class SampleViewModel : ObservableObject { [ObservableProperty] - [NotifyPropertyChangedFor(""FooBar"")] + [NotifyPropertyChangedFor("FooBar")] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0015"); } @@ -712,7 +745,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyPropertyChangedForInvalidTargetError_InvalidType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -727,7 +760,8 @@ public void Foo() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0015"); } @@ -735,7 +769,7 @@ public void Foo() [TestMethod] public void NotifyCanExecuteChangedForInvalidTargetError_Null() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -746,7 +780,8 @@ public partial class SampleViewModel : ObservableObject [NotifyCanExecuteChangedFor(null)] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0016"); } @@ -754,7 +789,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyCanExecuteChangedForInvalidTargetError_Missing() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -762,10 +797,11 @@ namespace MyApp public partial class SampleViewModel : ObservableObject { [ObservableProperty] - [NotifyCanExecuteChangedFor(""FooBar"")] + [NotifyCanExecuteChangedFor("FooBar")] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0016"); } @@ -773,7 +809,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyCanExecuteChangedForInvalidTargetError_InvalidMemberType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -788,7 +824,8 @@ public void Foo() { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0016"); } @@ -796,7 +833,7 @@ public void Foo() [TestMethod] public void NotifyCanExecuteChangedForInvalidTargetError_InvalidPropertyType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -809,7 +846,8 @@ public partial class SampleViewModel : ObservableObject public string Foo { get; } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0016"); } @@ -817,7 +855,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void NotifyCanExecuteChangedForInvalidTargetError_InvalidCommandType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -831,7 +869,8 @@ public partial class SampleViewModel : ObservableObject public ICommand FooCommand { get; } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0016"); } @@ -839,7 +878,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void InvalidAttributeCombinationForINotifyPropertyChangedAttributeError_InheritingINotifyPropertyChangedAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -853,7 +892,8 @@ public partial class A public partial class B : A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0017"); } @@ -861,7 +901,7 @@ public partial class B : A [TestMethod] public void InvalidAttributeCombinationForINotifyPropertyChangedAttributeError_InheritingObservableObjectAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -875,7 +915,8 @@ public partial class A public partial class B : A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0017"); } @@ -883,7 +924,7 @@ public partial class B : A [TestMethod] public void InvalidAttributeCombinationForINotifyPropertyChangedAttributeError_WithAlsoObservableObjectAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -893,7 +934,8 @@ namespace MyApp public partial class A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0017"); } @@ -901,7 +943,7 @@ public partial class A [TestMethod] public void InvalidAttributeCombinationForObservableObjectAttributeError_InheritingINotifyPropertyChangedAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -915,7 +957,8 @@ public partial class A public partial class B : A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0018"); } @@ -923,7 +966,7 @@ public partial class B : A [TestMethod] public void InvalidAttributeCombinationForObservableObjectAttributeError_InheritingObservableObjectAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -937,7 +980,8 @@ public partial class A public partial class B : A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0018"); } @@ -945,7 +989,7 @@ public partial class B : A [TestMethod] public void InvalidAttributeCombinationForObservableObjectAttributeError_WithAlsoINotifyPropertyChangedAttribute() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -955,7 +999,8 @@ namespace MyApp public partial class A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0018"); } @@ -963,7 +1008,7 @@ public partial class A [TestMethod] public void InvalidContainingTypeForObservablePropertyFieldError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -975,7 +1020,8 @@ public partial class MyViewModel : INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0019"); } @@ -983,17 +1029,18 @@ public partial class MyViewModel : INotifyPropertyChanged [TestMethod] public async Task FieldWithOrphanedDependentObservablePropertyAttributesError_NotifyPropertyChangedFor() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp { public partial class MyViewModel { - [NotifyPropertyChangedFor("""")] + [NotifyPropertyChangedFor("")] public int {|MVVMTK0020:number|}; } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp8); } @@ -1001,17 +1048,18 @@ public partial class MyViewModel [TestMethod] public async Task FieldWithOrphanedDependentObservablePropertyAttributesError_NotifyCanExecuteChangedFor() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp { public partial class MyViewModel { - [NotifyCanExecuteChangedFor("""")] + [NotifyCanExecuteChangedFor("")] public int {|MVVMTK0020:number|}; } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp8); } @@ -1019,7 +1067,7 @@ public partial class MyViewModel [TestMethod] public async Task FieldWithOrphanedDependentObservablePropertyAttributesError_NotifyPropertyChangedRecipients() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1029,7 +1077,8 @@ public partial class MyViewModel [NotifyPropertyChangedRecipients] public int {|MVVMTK0020:number|}; } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp8); } @@ -1037,22 +1086,23 @@ public partial class MyViewModel [TestMethod] public async Task FieldWithOrphanedDependentObservablePropertyAttributesError_MultipleUsesStillGenerateOnlyASingleDiagnostic() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp { public partial class MyViewModel { - [NotifyPropertyChangedFor("""")] - [NotifyPropertyChangedFor("""")] - [NotifyPropertyChangedFor("""")] - [NotifyCanExecuteChangedFor("""")] - [NotifyCanExecuteChangedFor("""")] + [NotifyPropertyChangedFor("")] + [NotifyPropertyChangedFor("")] + [NotifyPropertyChangedFor("")] + [NotifyCanExecuteChangedFor("")] + [NotifyCanExecuteChangedFor("")] [NotifyPropertyChangedRecipients] public int {|MVVMTK0020:number|}; } - }"; + } + """; await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration(source, LanguageVersion.CSharp8); } @@ -1060,7 +1110,7 @@ public partial class MyViewModel [TestMethod] public void InvalidAttributeCombinationForObservableRecipientAttributeError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1074,7 +1124,8 @@ public partial class A : ObservableObject public partial class B : A { } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0021"); } @@ -1082,7 +1133,7 @@ public partial class B : A [TestMethod] public void InvalidContainingTypeForNotifyPropertyChangedRecipientsFieldError_ObservableObject() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1093,7 +1144,8 @@ public partial class MyViewModel : ObservableObject [NotifyPropertyChangedRecipients] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0022"); } @@ -1101,7 +1153,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void MultipleRelayCommandMethodOverloads_WithOverloads() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -1118,7 +1170,8 @@ private void GreetUser(object value) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0023"); } @@ -1126,27 +1179,28 @@ private void GreetUser(object value) [TestMethod] public void MultipleRelayCommandMethodOverloads_WithOverloadInBaseType() { - string source = @" - using CommunityToolkit.Mvvm.Input; + string source = """ + using CommunityToolkit.Mvvm.Input; - namespace MyApp - { - public partial class BaseViewModel + namespace MyApp { - [RelayCommand] - private void GreetUser() + public partial class BaseViewModel { + [RelayCommand] + private void GreetUser() + { + } } - } - public partial class SampleViewModel : BaseViewModel - { - [RelayCommand] - private void GreetUser(object value) + public partial class SampleViewModel : BaseViewModel { + [RelayCommand] + private void GreetUser(object value) + { + } } } - }"; + """; VerifyGeneratedDiagnostics(source, "MVVMTK0023"); } @@ -1154,7 +1208,7 @@ private void GreetUser(object value) [TestMethod] public void InvalidObservablePropertyError_Object() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1164,7 +1218,8 @@ public partial class MyViewModel : ObservableObject [ObservableProperty] public object property; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0024"); } @@ -1172,7 +1227,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void InvalidObservablePropertyError_PropertyChangingEventArgs() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -1183,7 +1238,8 @@ public partial class MyViewModel : ObservableObject [ObservableProperty] public PropertyChangingEventArgs property; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0024"); } @@ -1191,7 +1247,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void InvalidObservablePropertyError_PropertyChangedEventArgs() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -1202,7 +1258,8 @@ public partial class MyViewModel : ObservableObject [ObservableProperty] public PropertyChangedEventArgs property; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0024"); } @@ -1210,7 +1267,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void InvalidObservablePropertyError_CustomTypeDerivedFromPropertyChangedEventArgs() { - string source = @" + string source = """ using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; @@ -1229,7 +1286,8 @@ public partial class MyViewModel : ObservableObject [ObservableProperty] public MyPropertyChangedEventArgs property; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0024"); } @@ -1237,7 +1295,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void MissingObservableValidatorInheritanceForNotifyDataErrorInfoError() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -1251,7 +1309,8 @@ public partial class SampleViewModel [NotifyDataErrorInfo] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0006", "MVVMTK0025"); } @@ -1259,7 +1318,7 @@ public partial class SampleViewModel [TestMethod] public void MissingValidationAttributesForNotifyDataErrorInfoError() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -1271,7 +1330,8 @@ public partial class SampleViewModel : ObservableValidator [NotifyDataErrorInfo] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0026"); } @@ -1279,7 +1339,7 @@ public partial class SampleViewModel : ObservableValidator [TestMethod] public void InvalidTypeForNotifyPropertyChangedRecipientsError() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1290,7 +1350,8 @@ public partial class MyViewModel : ObservableObject [ObservableProperty] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0027"); } @@ -1298,7 +1359,7 @@ public partial class MyViewModel : ObservableObject [TestMethod] public void InvalidTypeForNotifyDataErrorInfoError() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -1311,7 +1372,8 @@ public partial class SampleViewModel : ObservableObject [Required] private string name; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0006", "MVVMTK0028"); } @@ -1319,7 +1381,7 @@ public partial class SampleViewModel : ObservableObject [TestMethod] public void UnnecessaryNotifyPropertyChangedRecipientsWarning_SameType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1331,7 +1393,8 @@ public partial class MyViewModel : ObservableRecipient [NotifyPropertyChangedRecipients] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0029"); } @@ -1339,7 +1402,7 @@ public partial class MyViewModel : ObservableRecipient [TestMethod] public void UnnecessaryNotifyPropertyChangedRecipientsWarning_BaseType() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.ComponentModel; namespace MyApp @@ -1355,7 +1418,8 @@ public partial class MyViewModel : MyBaseViewModel [NotifyPropertyChangedRecipients] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0029"); } @@ -1363,7 +1427,7 @@ public partial class MyViewModel : MyBaseViewModel [TestMethod] public void UnnecessaryNotifyDataErrorInfoWarning_SameType() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -1377,7 +1441,8 @@ public partial class MyViewModel : ObservableValidator [NotifyDataErrorInfo] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0030"); } @@ -1385,7 +1450,7 @@ public partial class MyViewModel : ObservableValidator [TestMethod] public void UnnecessaryNotifyDataErrorInfoWarning_BaseType() { - string source = @" + string source = """ using System.ComponentModel.DataAnnotations; using CommunityToolkit.Mvvm.ComponentModel; @@ -1403,7 +1468,8 @@ public partial class MyViewModel : MyBaseViewModel [NotifyDataErrorInfo] public int number; } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0030"); } @@ -1411,7 +1477,7 @@ public partial class MyViewModel : MyBaseViewModel [TestMethod] public void InvalidRelayCommandFlowExceptionsToTaskSchedulerOption() { - string source = @" + string source = """ using CommunityToolkit.Mvvm.Input; namespace MyApp @@ -1423,7 +1489,8 @@ private void GreetUser(User user) { } } - }"; + } + """; VerifyGeneratedDiagnostics(source, "MVVMTK0031"); } From 0ae8bb789ac950eddc6e8d6879d6854222ee6251 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Oct 2022 13:29:21 +0200 Subject: [PATCH 5/6] Centralize trimming settings in common .targets file --- CommunityToolkit.Common/CommunityToolkit.Common.csproj | 5 +---- .../CommunityToolkit.Diagnostics.csproj | 2 -- .../CommunityToolkit.HighPerformance.csproj | 2 -- CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj | 6 ------ build/Community.Toolkit.Common.targets | 6 ++++++ 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CommunityToolkit.Common/CommunityToolkit.Common.csproj b/CommunityToolkit.Common/CommunityToolkit.Common.csproj index cb1d362d..b9b9833c 100644 --- a/CommunityToolkit.Common/CommunityToolkit.Common.csproj +++ b/CommunityToolkit.Common/CommunityToolkit.Common.csproj @@ -14,12 +14,9 @@ Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;Extensions;Helpers - + NETSTANDARD2_1_OR_GREATER - true - true \ No newline at end of file diff --git a/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj b/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj index 46cc03aa..c49a6e53 100644 --- a/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj +++ b/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj @@ -38,8 +38,6 @@ NETSTANDARD2_1_OR_GREATER - true - true diff --git a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 5324fa47..03beef56 100644 --- a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -51,8 +51,6 @@ Additionally, also enable trimming support on .NET 6. --> NETSTANDARD2_1_OR_GREATER - true - true diff --git a/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index 3eef8704..c2ca49b5 100644 --- a/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -34,12 +34,6 @@ - - - true - true - - diff --git a/build/Community.Toolkit.Common.targets b/build/Community.Toolkit.Common.targets index f34ab2ab..ffd77912 100644 --- a/build/Community.Toolkit.Common.targets +++ b/build/Community.Toolkit.Common.targets @@ -17,4 +17,10 @@ + + + true + true + + \ No newline at end of file From 2a9cb1d79a3802f84f1482f577f908486835a1bf Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Oct 2022 13:30:02 +0200 Subject: [PATCH 6/6] Fix nullability warnings in test projects --- .../Test_ObservablePropertyAttribute.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs b/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs index a97b7bc7..ac1cc911 100644 --- a/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs +++ b/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs @@ -958,11 +958,11 @@ public void Test_ObservableProperty_CommandNamesThatCantBeLowered() FieldInfo? fieldInfo = typeof(ModelWithCommandNamesThatCantBeLowered).GetField($"_{nameof(ModelWithCommandNamesThatCantBeLowered.中文)}Command", BindingFlags.Instance | BindingFlags.NonPublic); - Assert.AreSame(model.中文Command, fieldInfo.GetValue(model)); + Assert.AreSame(model.中文Command, fieldInfo?.GetValue(model)); fieldInfo = typeof(ModelWithCommandNamesThatCantBeLowered).GetField($"_{nameof(ModelWithCommandNamesThatCantBeLowered.c中文)}Command", BindingFlags.Instance | BindingFlags.NonPublic); - Assert.AreSame(model.c中文Command, fieldInfo.GetValue(model)); + Assert.AreSame(model.c中文Command, fieldInfo?.GetValue(model)); } public abstract partial class BaseViewModel : ObservableObject