@@ -43,13 +43,13 @@ public static void IsNotNullOrEmpty([NotNull] string? text, string name)
4343 {
4444 if ( ! string . IsNullOrEmpty ( text ) )
4545 {
46+ #pragma warning disable CS8777 // Does not return when text is null
4647 return ;
48+ #pragma warning restore CS8777
4749 }
4850
4951 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)
5152 }
52- #pragma warning restore CS8777
5353
5454 /// <summary>
5555 /// 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)
5858 /// <param name="name">The name of the input parameter being tested.</param>
5959 /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
6060 [ 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 ) ) ]
6179 public static void IsNullOrWhitespace ( string ? text , string name )
6280 {
6381 if ( string . IsNullOrWhiteSpace ( text ) )
6482 {
6583 return ;
6684 }
6785
68- ThrowHelper . ThrowArgumentExceptionForIsNullOrWhitespace ( text , name ) ;
86+ ThrowHelper . ThrowArgumentExceptionForIsNullOrWhiteSpace ( text , name ) ;
6987 }
7088
7189 /// <summary>
@@ -75,17 +93,37 @@ public static void IsNullOrWhitespace(string? text, string name)
7593 /// <param name="name">The name of the input parameter being tested.</param>
7694 /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
7795 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
78- public static void IsNotNullOrWhitespace ( [ NotNull ] string ? text , string name )
96+ public static void IsNotNullOrWhiteSpace ( [ NotNull ] string ? text , string name )
7997 {
8098 if ( ! string . IsNullOrWhiteSpace ( text ) )
8199 {
100+ #pragma warning disable CS8777 // Does not return when text is null
82101 return ;
102+ #pragma warning restore CS8777
83103 }
84104
85- ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhitespace ( text , name ) ;
86- #pragma warning disable CS8777 // Does not return when text is null
105+ ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhiteSpace ( text , name ) ;
87106 }
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 ;
88122#pragma warning restore CS8777
123+ }
124+
125+ ThrowHelper . ThrowArgumentExceptionForIsNotNullOrWhiteSpace ( text , name ) ;
126+ }
89127
90128 /// <summary>
91129 /// Asserts that the input <see cref="string"/> instance must be empty.
@@ -128,14 +166,49 @@ public static void IsNotEmpty(string text, string name)
128166 /// <param name="name">The name of the input parameter being tested.</param>
129167 /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
130168 [ 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 ) ) ]
131187 public static void IsWhitespace ( string text , string name )
132188 {
133189 if ( string . IsNullOrWhiteSpace ( text ) )
134190 {
135191 return ;
136192 }
137193
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 ) ;
139212 }
140213
141214 /// <summary>
@@ -145,14 +218,15 @@ public static void IsWhitespace(string text, string name)
145218 /// <param name="name">The name of the input parameter being tested.</param>
146219 /// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
147220 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
221+ [ Obsolete ( "Use " + nameof ( IsNotWhiteSpace ) ) ]
148222 public static void IsNotWhitespace ( string text , string name )
149223 {
150224 if ( ! string . IsNullOrWhiteSpace ( text ) )
151225 {
152226 return ;
153227 }
154228
155- ThrowHelper . ThrowArgumentExceptionForIsNotWhitespace ( text , name ) ;
229+ ThrowHelper . ThrowArgumentExceptionForIsNotWhiteSpace ( text , name ) ;
156230 }
157231
158232 /// <summary>
0 commit comments