@@ -55,7 +55,7 @@ internal static class Guard
55
55
/// <param name="paramName">The parameter name to use in the thrown exception.</param>
56
56
[ DebuggerHidden ]
57
57
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
58
- public static void ThrowIfNull ( [ NotNull ] object ? value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
58
+ public static void ThrowIfNull ( [ NotNull ] object ? value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
59
59
{
60
60
if ( value is null )
61
61
{
@@ -70,7 +70,7 @@ public static void ThrowIfNull([NotNull] object? value, [CallerArgumentExpressio
70
70
/// <param name="paramName">The parameter name to use in the thrown exception.</param>
71
71
[ DebuggerHidden ]
72
72
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
73
- public static void ThrowIfNullOrEmpty ( [ NotNull ] string ? value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
73
+ public static void ThrowIfNullOrEmpty ( [ NotNull ] string ? value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
74
74
#pragma warning disable CS8777 // Parameter must have a non-null value when exiting.
75
75
{
76
76
if ( string . IsNullOrEmpty ( value ) )
@@ -87,7 +87,7 @@ public static void ThrowIfNullOrEmpty([NotNull] string? value, [CallerArgumentEx
87
87
/// <param name="paramName">The parameter name to use in the thrown exception.</param>
88
88
[ DebuggerHidden ]
89
89
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
90
- public static void ThrowIfNullOrWhitespace ( [ NotNull ] string ? value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
90
+ public static void ThrowIfNullOrWhitespace ( [ NotNull ] string ? value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
91
91
#pragma warning disable CS8777 // Parameter must have a non-null value when exiting.
92
92
{
93
93
if ( string . IsNullOrWhiteSpace ( value ) )
@@ -105,7 +105,7 @@ public static void ThrowIfNullOrWhitespace([NotNull] string? value, [CallerArgum
105
105
/// <param name="paramName">The parameter name to use in the thrown exception.</param>
106
106
[ DebuggerHidden ]
107
107
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
108
- public static void ThrowIfZero ( int value , string message = "Must not be zero" , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
108
+ public static void ThrowIfZero ( int value , string message = "Must not be zero" , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
109
109
{
110
110
if ( value == 0 )
111
111
{
@@ -120,7 +120,7 @@ public static void ThrowIfZero(int value, string message = "Must not be zero", [
120
120
/// <param name="paramName">The parameter name to use in the thrown exception.</param>
121
121
[ DebuggerHidden ]
122
122
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
123
- public static void ThrowIfInvalidTimeout ( int value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
123
+ public static void ThrowIfInvalidTimeout ( int value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
124
124
{
125
125
ThrowIfOutOfRange ( value , paramName , min : Timeout . Infinite , message : $ "Must be non-negative or '{ nameof ( Timeout ) } .{ nameof ( Timeout . Infinite ) } '") ;
126
126
}
@@ -137,7 +137,7 @@ public static void ThrowIfInvalidTimeout(int value, [CallerArgumentExpression("v
137
137
/// <param name="message">An optional custom message to use in the thrown exception.</param>
138
138
[ DebuggerHidden ]
139
139
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
140
- public static void ThrowIfOutOfRange ( int value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null , int min = int . MinValue , int max = int . MaxValue , string ? minName = null , string ? maxName = null , string ? message = null )
140
+ public static void ThrowIfOutOfRange ( int value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null , int min = int . MinValue , int max = int . MaxValue , string ? minName = null , string ? maxName = null , string ? message = null )
141
141
{
142
142
Range ( value , paramName , min , max , minName , maxName , message ) ;
143
143
}
@@ -154,7 +154,7 @@ public static void ThrowIfOutOfRange(int value, [CallerArgumentExpression("value
154
154
/// <param name="message">An optional custom message to use in the thrown exception.</param>
155
155
[ DebuggerHidden ]
156
156
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
157
- public static void ThrowIfOutOfRange ( double value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null , double min = double . MinValue , double max = double . MaxValue , string ? minName = null , string ? maxName = null , string ? message = null )
157
+ public static void ThrowIfOutOfRange ( double value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null , double min = double . MinValue , double max = double . MaxValue , string ? minName = null , string ? maxName = null , string ? message = null )
158
158
{
159
159
Range ( value , paramName , min , max , minName , maxName , message ) ;
160
160
}
@@ -168,7 +168,7 @@ public static void ThrowIfOutOfRange(double value, [CallerArgumentExpression("va
168
168
/// <returns>The value casted to the specified type.</returns>
169
169
[ DebuggerHidden ]
170
170
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
171
- public static T ThrowIfNotOfType < T > ( [ NotNull ] object ? value , [ CallerArgumentExpression ( " value" ) ] string ? paramName = null )
171
+ public static T ThrowIfNotOfType < T > ( [ NotNull ] object ? value , [ CallerArgumentExpression ( nameof ( value ) ) ] string ? paramName = null )
172
172
{
173
173
if ( value is not T result )
174
174
{
0 commit comments