2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ #nullable enable
5
6
using System . Diagnostics ;
6
7
using System . Globalization ;
7
8
using System . Runtime . CompilerServices ;
@@ -237,7 +238,7 @@ public static int ToLower(this ReadOnlySpan<char> source, Span<char> destination
237
238
if ( GlobalizationMode . Invariant )
238
239
TextInfo . ToLowerAsciiInvariant ( source , destination ) ;
239
240
else
240
- culture . TextInfo . ChangeCaseToLower ( source , destination ) ;
241
+ culture ! . TextInfo . ChangeCaseToLower ( source , destination ) ; // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/538
241
242
return source . Length ;
242
243
}
243
244
@@ -288,7 +289,7 @@ public static int ToUpper(this ReadOnlySpan<char> source, Span<char> destination
288
289
if ( GlobalizationMode . Invariant )
289
290
TextInfo . ToUpperAsciiInvariant ( source , destination ) ;
290
291
else
291
- culture . TextInfo . ChangeCaseToUpper ( source , destination ) ;
292
+ culture ! . TextInfo . ChangeCaseToUpper ( source , destination ) ; // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/538
292
293
return source . Length ;
293
294
}
294
295
@@ -384,15 +385,15 @@ public static bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> v
384
385
/// Creates a new span over the portion of the target array.
385
386
/// </summary>
386
387
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
387
- public static Span < T > AsSpan < T > ( this T [ ] array , int start )
388
+ public static Span < T > AsSpan < T > ( this T [ ] ? array , int start )
388
389
{
389
390
if ( array == null )
390
391
{
391
392
if ( start != 0 )
392
393
ThrowHelper . ThrowArgumentOutOfRangeException ( ) ;
393
394
return default ;
394
395
}
395
- if ( default ( T ) == null && array . GetType ( ) != typeof ( T [ ] ) )
396
+ if ( default ( T ) ! == null && array . GetType ( ) != typeof ( T [ ] ) ) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
396
397
ThrowHelper . ThrowArrayTypeMismatchException ( ) ;
397
398
if ( ( uint ) start > ( uint ) array . Length )
398
399
ThrowHelper . ThrowArgumentOutOfRangeException ( ) ;
@@ -404,7 +405,7 @@ public static Span<T> AsSpan<T>(this T[] array, int start)
404
405
/// Creates a new span over the portion of the target array.
405
406
/// </summary>
406
407
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
407
- public static Span < T > AsSpan < T > ( this T [ ] array , Index startIndex )
408
+ public static Span < T > AsSpan < T > ( this T [ ] ? array , Index startIndex )
408
409
{
409
410
if ( array == null )
410
411
{
@@ -414,7 +415,7 @@ public static Span<T> AsSpan<T>(this T[] array, Index startIndex)
414
415
return default ;
415
416
}
416
417
417
- if ( default ( T ) == null && array . GetType ( ) != typeof ( T [ ] ) )
418
+ if ( default ( T ) ! == null && array . GetType ( ) != typeof ( T [ ] ) ) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
418
419
ThrowHelper . ThrowArrayTypeMismatchException ( ) ;
419
420
420
421
int actualIndex = startIndex . GetOffset ( array . Length ) ;
@@ -428,7 +429,7 @@ public static Span<T> AsSpan<T>(this T[] array, Index startIndex)
428
429
/// Creates a new span over the portion of the target array.
429
430
/// </summary>
430
431
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
431
- public static Span < T > AsSpan < T > ( this T [ ] array , Range range )
432
+ public static Span < T > AsSpan < T > ( this T [ ] ? array , Range range )
432
433
{
433
434
if ( array == null )
434
435
{
@@ -441,7 +442,7 @@ public static Span<T> AsSpan<T>(this T[] array, Range range)
441
442
return default ;
442
443
}
443
444
444
- if ( default ( T ) == null && array . GetType ( ) != typeof ( T [ ] ) )
445
+ if ( default ( T ) ! == null && array . GetType ( ) != typeof ( T [ ] ) ) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
445
446
ThrowHelper . ThrowArrayTypeMismatchException ( ) ;
446
447
447
448
( int start , int length ) = range . GetOffsetAndLength ( array . Length ) ;
@@ -454,7 +455,7 @@ public static Span<T> AsSpan<T>(this T[] array, Range range)
454
455
/// <param name="text">The target string.</param>
455
456
/// <remarks>Returns default when <paramref name="text"/> is null.</remarks>
456
457
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
457
- public static ReadOnlySpan < char > AsSpan ( this string text )
458
+ public static ReadOnlySpan < char > AsSpan ( this string ? text )
458
459
{
459
460
if ( text == null )
460
461
return default ;
@@ -472,7 +473,7 @@ public static ReadOnlySpan<char> AsSpan(this string text)
472
473
/// Thrown when the specified <paramref name="start"/> index is not in range (<0 or >text.Length).
473
474
/// </exception>
474
475
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
475
- public static ReadOnlySpan < char > AsSpan ( this string text , int start )
476
+ public static ReadOnlySpan < char > AsSpan ( this string ? text , int start )
476
477
{
477
478
if ( text == null )
478
479
{
@@ -498,7 +499,7 @@ public static ReadOnlySpan<char> AsSpan(this string text, int start)
498
499
/// Thrown when the specified <paramref name="start"/> index or <paramref name="length"/> is not in range.
499
500
/// </exception>
500
501
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
501
- public static ReadOnlySpan < char > AsSpan ( this string text , int start , int length )
502
+ public static ReadOnlySpan < char > AsSpan ( this string ? text , int start , int length )
502
503
{
503
504
if ( text == null )
504
505
{
@@ -522,7 +523,7 @@ public static ReadOnlySpan<char> AsSpan(this string text, int start, int length)
522
523
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
523
524
/// <param name="text">The target string.</param>
524
525
/// <remarks>Returns default when <paramref name="text"/> is null.</remarks>
525
- public static ReadOnlyMemory < char > AsMemory ( this string text )
526
+ public static ReadOnlyMemory < char > AsMemory ( this string ? text )
526
527
{
527
528
if ( text == null )
528
529
return default ;
@@ -537,7 +538,7 @@ public static ReadOnlyMemory<char> AsMemory(this string text)
537
538
/// <exception cref="System.ArgumentOutOfRangeException">
538
539
/// Thrown when the specified <paramref name="start"/> index is not in range (<0 or >text.Length).
539
540
/// </exception>
540
- public static ReadOnlyMemory < char > AsMemory ( this string text , int start )
541
+ public static ReadOnlyMemory < char > AsMemory ( this string ? text , int start )
541
542
{
542
543
if ( text == null )
543
544
{
@@ -555,7 +556,7 @@ public static ReadOnlyMemory<char> AsMemory(this string text, int start)
555
556
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
556
557
/// <param name="text">The target string.</param>
557
558
/// <param name="startIndex">The index at which to begin this slice.</param>
558
- public static ReadOnlyMemory < char > AsMemory ( this string text , Index startIndex )
559
+ public static ReadOnlyMemory < char > AsMemory ( this string ? text , Index startIndex )
559
560
{
560
561
if ( text == null )
561
562
{
@@ -580,7 +581,7 @@ public static ReadOnlyMemory<char> AsMemory(this string text, Index startIndex)
580
581
/// <exception cref="System.ArgumentOutOfRangeException">
581
582
/// Thrown when the specified <paramref name="start"/> index or <paramref name="length"/> is not in range.
582
583
/// </exception>
583
- public static ReadOnlyMemory < char > AsMemory ( this string text , int start , int length )
584
+ public static ReadOnlyMemory < char > AsMemory ( this string ? text , int start , int length )
584
585
{
585
586
if ( text == null )
586
587
{
@@ -604,7 +605,7 @@ public static ReadOnlyMemory<char> AsMemory(this string text, int start, int len
604
605
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
605
606
/// <param name="text">The target string.</param>
606
607
/// <param name="range">The range used to indicate the start and length of the sliced string.</param>
607
- public static ReadOnlyMemory < char > AsMemory ( this string text , Range range )
608
+ public static ReadOnlyMemory < char > AsMemory ( this string ? text , Range range )
608
609
{
609
610
if ( text == null )
610
611
{
0 commit comments