@@ -43,13 +43,13 @@ public static void IsNotNullOrEmpty([NotNull] string? text, string name)
43
43
{
44
44
if ( ! string . IsNullOrEmpty ( text ) )
45
45
{
46
+ #pragma warning disable CS8777 // Does not return when text is null
46
47
return ;
48
+ #pragma warning restore CS8777
47
49
}
48
50
49
51
ThrowHelper . ThrowArgumentExceptionForIsNotNullOrEmpty ( text , name ) ;
50
- #pragma warning disable CS8777 // Does not return when text is null (.NET Standard 2.0 string.IsNullOrEmpty lacks flow attribute)
51
52
}
52
- #pragma warning restore CS8777
53
53
54
54
/// <summary>
55
55
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
@@ -58,14 +58,32 @@ public static void IsNotNullOrEmpty([NotNull] string? text, string name)
58
58
/// <param name="name">The name of the input parameter being tested.</param>
59
59
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
60
60
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
61
+ public static void IsNullOrWhiteSpace ( string ? text , string name )
62
+ {
63
+ if ( string . IsNullOrWhiteSpace ( text ) )
64
+ {
65
+ return ;
66
+ }
67
+
68
+ ThrowHelper . ThrowArgumentExceptionForIsNullOrWhiteSpace ( text , name ) ;
69
+ }
70
+
71
+ /// <summary>
72
+ /// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
73
+ /// </summary>
74
+ /// <param name="text">The input <see cref="string"/> instance to test.</param>
75
+ /// <param name="name">The name of the input parameter being tested.</param>
76
+ /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
77
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
78
+ [ Obsolete ( "Use " + nameof ( IsNullOrWhiteSpace ) ) ]
61
79
public static void IsNullOrWhitespace ( string ? text , string name )
62
80
{
63
81
if ( string . IsNullOrWhiteSpace ( text ) )
64
82
{
65
83
return ;
66
84
}
67
85
68
- ThrowHelper . ThrowArgumentExceptionForIsNullOrWhitespace ( text , name ) ;
86
+ ThrowHelper . ThrowArgumentExceptionForIsNullOrWhiteSpace ( text , name ) ;
69
87
}
70
88
71
89
/// <summary>
@@ -75,17 +93,37 @@ public static void IsNullOrWhitespace(string? text, string name)
75
93
/// <param name="name">The name of the input parameter being tested.</param>
76
94
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
77
95
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
78
- public static void IsNotNullOrWhitespace ( [ NotNull ] string ? text , string name )
96
+ public static void IsNotNullOrWhiteSpace ( [ NotNull ] string ? text , string name )
79
97
{
80
98
if ( ! string . IsNullOrWhiteSpace ( text ) )
81
99
{
100
+ #pragma warning disable CS8777 // Does not return when text is null
82
101
return ;
102
+ #pragma warning restore CS8777
83
103
}
84
104
85
- ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhitespace ( text , name ) ;
86
- #pragma warning disable CS8777 // Does not return when text is null
105
+ ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhiteSpace ( text , name ) ;
87
106
}
107
+
108
+ /// <summary>
109
+ /// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
110
+ /// </summary>
111
+ /// <param name="text">The input <see cref="string"/> instance to test.</param>
112
+ /// <param name="name">The name of the input parameter being tested.</param>
113
+ /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
114
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
115
+ [ Obsolete ( "Use " + nameof ( IsNotNullOrWhiteSpace ) ) ]
116
+ public static void IsNotNullOrWhitespace ( [ NotNull ] string ? text , string name )
117
+ {
118
+ if ( ! string . IsNullOrWhiteSpace ( text ) )
119
+ {
120
+ #pragma warning disable CS8777 // Does not return when text is null
121
+ return ;
88
122
#pragma warning restore CS8777
123
+ }
124
+
125
+ ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhiteSpace ( text , name ) ;
126
+ }
89
127
90
128
/// <summary>
91
129
/// Asserts that the input <see cref="string"/> instance must be empty.
@@ -128,14 +166,49 @@ public static void IsNotEmpty(string text, string name)
128
166
/// <param name="name">The name of the input parameter being tested.</param>
129
167
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
130
168
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
169
+ public static void IsWhiteSpace ( string text , string name )
170
+ {
171
+ if ( string . IsNullOrWhiteSpace ( text ) )
172
+ {
173
+ return ;
174
+ }
175
+
176
+ ThrowHelper . ThrowArgumentExceptionForIsWhiteSpace ( text , name ) ;
177
+ }
178
+
179
+ /// <summary>
180
+ /// Asserts that the input <see cref="string"/> instance must be whitespace.
181
+ /// </summary>
182
+ /// <param name="text">The input <see cref="string"/> instance to test.</param>
183
+ /// <param name="name">The name of the input parameter being tested.</param>
184
+ /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
185
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
186
+ [ Obsolete ( "Use " + nameof ( IsWhiteSpace ) ) ]
131
187
public static void IsWhitespace ( string text , string name )
132
188
{
133
189
if ( string . IsNullOrWhiteSpace ( text ) )
134
190
{
135
191
return ;
136
192
}
137
193
138
- ThrowHelper . ThrowArgumentExceptionForIsWhitespace ( text , name ) ;
194
+ ThrowHelper . ThrowArgumentExceptionForIsWhiteSpace ( text , name ) ;
195
+ }
196
+
197
+ /// <summary>
198
+ /// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
199
+ /// </summary>
200
+ /// <param name="text">The input <see cref="string"/> instance to test.</param>
201
+ /// <param name="name">The name of the input parameter being tested.</param>
202
+ /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
203
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
204
+ public static void IsNotWhiteSpace ( string text , string name )
205
+ {
206
+ if ( ! string . IsNullOrWhiteSpace ( text ) )
207
+ {
208
+ return ;
209
+ }
210
+
211
+ ThrowHelper . ThrowArgumentExceptionForIsNotWhiteSpace ( text , name ) ;
139
212
}
140
213
141
214
/// <summary>
@@ -145,14 +218,15 @@ public static void IsWhitespace(string text, string name)
145
218
/// <param name="name">The name of the input parameter being tested.</param>
146
219
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
147
220
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
221
+ [ Obsolete ( "Use " + nameof ( IsNotWhiteSpace ) ) ]
148
222
public static void IsNotWhitespace ( string text , string name )
149
223
{
150
224
if ( ! string . IsNullOrWhiteSpace ( text ) )
151
225
{
152
226
return ;
153
227
}
154
228
155
- ThrowHelper . ThrowArgumentExceptionForIsNotWhitespace ( text , name ) ;
229
+ ThrowHelper . ThrowArgumentExceptionForIsNotWhiteSpace ( text , name ) ;
156
230
}
157
231
158
232
/// <summary>
0 commit comments