@@ -34,7 +34,7 @@ public static ReadOnlySpan<char> FirstSplit(this string source,
3434 out int nextIndex ,
3535 int startIndex = 0 )
3636 {
37- if ( source == null ) throw new NullReferenceException ( ) ;
37+ if ( source is null ) throw new NullReferenceException ( ) ;
3838 Contract . EndContractBlock ( ) ;
3939
4040 var i = source . Length == 0 ? - 1 : source . IndexOf ( splitCharacter , startIndex ) ;
@@ -64,8 +64,8 @@ public static ReadOnlySpan<char> FirstSplit(this string source,
6464 int startIndex = 0 ,
6565 StringComparison comparisonType = StringComparison . Ordinal )
6666 {
67- if ( source == null ) throw new NullReferenceException ( ) ;
68- if ( splitSequence == null ) throw new ArgumentNullException ( nameof ( splitSequence ) ) ;
67+ if ( source is null ) throw new NullReferenceException ( ) ;
68+ if ( splitSequence is null ) throw new ArgumentNullException ( nameof ( splitSequence ) ) ;
6969 if ( splitSequence . Length == 0 )
7070 throw new ArgumentException ( "Cannot split using empty sequence." , nameof ( splitSequence ) ) ;
7171 Contract . EndContractBlock ( ) ;
@@ -91,7 +91,7 @@ public static ReadOnlySpan<char> FirstSplit(this string source,
9191 public static IEnumerable < string > SplitAsEnumerable ( this string source ,
9292 char splitCharacter )
9393 {
94- if ( source == null ) throw new NullReferenceException ( ) ;
94+ if ( source is null ) throw new NullReferenceException ( ) ;
9595 Contract . EndContractBlock ( ) ;
9696
9797 return source . Length == 0
@@ -122,8 +122,8 @@ public static IEnumerable<string> SplitAsEnumerable(this string source,
122122 string splitSequence ,
123123 StringComparison comparisonType = StringComparison . Ordinal )
124124 {
125- if ( source == null ) throw new NullReferenceException ( ) ;
126- if ( splitSequence == null ) throw new ArgumentNullException ( nameof ( splitSequence ) ) ;
125+ if ( source is null ) throw new NullReferenceException ( ) ;
126+ if ( splitSequence is null ) throw new ArgumentNullException ( nameof ( splitSequence ) ) ;
127127 if ( splitSequence . Length == 0 )
128128 throw new ArgumentException ( "Cannot split using empty sequence." , nameof ( splitSequence ) ) ;
129129 Contract . EndContractBlock ( ) ;
@@ -153,7 +153,7 @@ IEnumerable<string> SplitAsEnumerableCore()
153153 /// <returns>The source of the string before the search string. Returns null if search string is not found.</returns>
154154 public static string BeforeFirst ( this string source , string search , StringComparison comparisonType = StringComparison . Ordinal )
155155 {
156- if ( source == null )
156+ if ( source is null )
157157 throw new NullReferenceException ( ) ;
158158 Contract . EndContractBlock ( ) ;
159159
@@ -173,7 +173,7 @@ public static string BeforeFirst(this string source, string search, StringCompar
173173 /// <returns>The source of the string after the search string. Returns null if search string is not found.</returns>
174174 public static string AfterFirst ( this string source , string search , StringComparison comparisonType = StringComparison . Ordinal )
175175 {
176- if ( source == null )
176+ if ( source is null )
177177 throw new NullReferenceException ( ) ;
178178 Contract . EndContractBlock ( ) ;
179179
@@ -193,7 +193,7 @@ public static string AfterFirst(this string source, string search, StringCompari
193193 /// <returns>The source of the string before the search string. Returns null if search string is not found.</returns>
194194 public static string BeforeLast ( this string source , string search , StringComparison comparisonType = StringComparison . Ordinal )
195195 {
196- if ( source == null )
196+ if ( source is null )
197197 throw new NullReferenceException ( ) ;
198198 Contract . EndContractBlock ( ) ;
199199
@@ -213,7 +213,7 @@ public static string BeforeLast(this string source, string search, StringCompari
213213 /// <returns>The source of the string after the search string. Returns null if search string is not found.</returns>
214214 public static string AfterLast ( this string source , string search , StringComparison comparisonType = StringComparison . Ordinal )
215215 {
216- if ( source == null )
216+ if ( source is null )
217217 throw new NullReferenceException ( ) ;
218218 Contract . EndContractBlock ( ) ;
219219
@@ -361,7 +361,7 @@ public static ReadOnlySpan<char> AfterLast(this in ReadOnlySpan<char> source,
361361 /// </summary>
362362 public static string ToTitleCase ( this string source )
363363 {
364- if ( source == null )
364+ if ( source is null )
365365 throw new NullReferenceException ( ) ;
366366 Contract . EndContractBlock ( ) ;
367367
@@ -374,7 +374,7 @@ public static string ToTitleCase(this string source)
374374
375375 public static bool IsAnyNullOrWhiteSpace ( params string [ ] values )
376376 {
377- if ( values == null || values . Length == 0 )
377+ if ( values is null || values . Length == 0 )
378378 return false ;
379379
380380 return values . Any ( string . IsNullOrWhiteSpace ) ;
@@ -412,7 +412,7 @@ public static string ToNullIfWhiteSpace(this string value, bool trim = false)
412412 /// <param name="format">The format string.</param>
413413 public static string ToFormat ( this string value , string format = null )
414414 => string . IsNullOrWhiteSpace ( value ) ? string . Empty
415- : ( format == null ? value : string . Format ( format , value ) ) ;
415+ : ( format is null ? value : string . Format ( format , value ) ) ;
416416
417417
418418 /// <summary>
@@ -422,8 +422,8 @@ public static string ToFormat(this string value, string format = null)
422422 /// <param name="format">The format string.</param>
423423 public static string ToFormat ( this int ? value , string format = null )
424424 {
425- if ( format == null ) format = "{0}" ;
426- return value == null ? string . Empty : string . Format ( format , value . Value ) ;
425+ if ( format is null ) format = "{0}" ;
426+ return value is null ? string . Empty : string . Format ( format , value . Value ) ;
427427 }
428428
429429 /// <summary>
@@ -433,8 +433,8 @@ public static string ToFormat(this int? value, string format = null)
433433 /// <param name="format">The format string.</param>
434434 public static string ToFormat ( this short ? value , string format = null )
435435 {
436- if ( format == null ) format = "{0}" ;
437- return value == null ? string . Empty : string . Format ( format , value . Value ) ;
436+ if ( format is null ) format = "{0}" ;
437+ return value is null ? string . Empty : string . Format ( format , value . Value ) ;
438438 }
439439
440440
@@ -451,14 +451,14 @@ public static bool IsAlphaNumeric(this string source, bool trim = false)
451451 #region Regex helper methods.
452452 public static string GetValue ( this GroupCollection groups , string groupName , bool throwIfInvalid = false )
453453 {
454- if ( groups == null )
454+ if ( groups is null )
455455 throw new NullReferenceException ( ) ;
456- if ( groupName == null )
456+ if ( groupName is null )
457457 throw new ArgumentNullException ( nameof ( groupName ) ) ;
458458 Contract . EndContractBlock ( ) ;
459459
460460 var group = groups [ groupName ] ;
461- if ( group == null )
461+ if ( group is null )
462462 {
463463 if ( throwIfInvalid )
464464 throw new ArgumentException ( ) ;
@@ -476,7 +476,7 @@ public static string GetValue(this GroupCollection groups, string groupName, boo
476476 /// </summary>
477477 public static string ToString ( this double ? value , string format )
478478 {
479- if ( format == null )
479+ if ( format is null )
480480 throw new ArgumentNullException ( nameof ( format ) ) ;
481481 Contract . EndContractBlock ( ) ;
482482
@@ -489,7 +489,7 @@ public static string ToString(this double? value, string format)
489489 /// </summary>
490490 public static string ToString ( this float ? value , string format )
491491 {
492- if ( format == null )
492+ if ( format is null )
493493 throw new ArgumentNullException ( nameof ( format ) ) ;
494494 Contract . EndContractBlock ( ) ;
495495
@@ -501,7 +501,7 @@ public static string ToString(this float? value, string format)
501501 /// </summary>
502502 public static string ToString ( this int ? value , string format )
503503 {
504- if ( format == null )
504+ if ( format is null )
505505 throw new ArgumentNullException ( nameof ( format ) ) ;
506506 Contract . EndContractBlock ( ) ;
507507
@@ -591,9 +591,9 @@ public static string ToMetricString(this int number)
591591 public static readonly Regex WHITESPACE = new Regex ( @"\s+" ) ;
592592 public static string ReplaceWhiteSpace ( this string source , string replace = " " )
593593 {
594- if ( source == null )
594+ if ( source is null )
595595 throw new NullReferenceException ( ) ;
596- if ( replace == null )
596+ if ( replace is null )
597597 throw new ArgumentNullException ( nameof ( replace ) ) ;
598598 Contract . EndContractBlock ( ) ;
599599
@@ -602,11 +602,11 @@ public static string ReplaceWhiteSpace(this string source, string replace = " ")
602602
603603 public static string TrimStart ( this string source , string pattern )
604604 {
605- if ( source == null )
605+ if ( source is null )
606606 throw new NullReferenceException ( ) ;
607607 Contract . EndContractBlock ( ) ;
608608
609- if ( pattern == null )
609+ if ( pattern is null )
610610 return source . TrimStart ( ) ;
611611
612612 if ( pattern == string . Empty )
@@ -619,11 +619,11 @@ public static string TrimStart(this string source, string pattern)
619619
620620 public static string TrimEnd ( this string source , string pattern )
621621 {
622- if ( source == null )
622+ if ( source is null )
623623 throw new NullReferenceException ( ) ;
624624 Contract . EndContractBlock ( ) ;
625625
626- if ( pattern == null )
626+ if ( pattern is null )
627627 return source . TrimEnd ( ) ;
628628
629629 if ( pattern == string . Empty )
@@ -642,7 +642,7 @@ public static string TrimEnd(this string source, string pattern)
642642 /// </summary>
643643 public static void WriteLineNoTabs ( this TextWriter writer , string s = null )
644644 {
645- if ( writer == null )
645+ if ( writer is null )
646646 throw new NullReferenceException ( ) ;
647647 Contract . EndContractBlock ( ) ;
648648
@@ -660,7 +660,7 @@ public static void WriteLineNoTabs(this TextWriter writer, string s = null)
660660 /// <returns>The resultant string.</returns>
661661 public static string Supplant < T > ( this string format , T [ ] values )
662662 {
663- if ( values == null )
663+ if ( values is null )
664664 return format ;
665665
666666 switch ( values . Length )
0 commit comments