@@ -32,8 +32,7 @@ private static CompositeRange<T> ParseCompositeRange<T>(
3232 var boundaryAndRange = value . Split ( new [ ] { CompositeRangeInternal . PrefixString } , 2 , StringSplitOptions . None ) ;
3333 var boundary = ParseRange ( boundaryAndRange [ 0 ] , parseValueCallback ) ;
3434
35- var result = boundaryAndRange [ 1 ]
36- . Substring ( 0 , boundaryAndRange [ 1 ] . Length - CompositeRangeInternal . SuffixString . Length )
35+ var result = boundaryAndRange [ 1 ] [ ..^ CompositeRangeInternal . SuffixString . Length ]
3736 . Split ( new [ ] { CompositeRangeInternal . SeparatorString } , StringSplitOptions . None )
3837 . Select ( s => ParseRange ( s , parseValueCallback ) )
3938 . ToCompositeRange ( ) ;
@@ -53,8 +52,7 @@ private static CompositeRange<T, TKey> ParseCompositeRange<T, TKey>(
5352 var boundaryAndRange = value . Split ( new [ ] { CompositeRangeInternal . PrefixString } , 2 , StringSplitOptions . None ) ;
5453 var boundary = ParseRange ( boundaryAndRange [ 0 ] , parseValueCallback ) ;
5554
56- var result = boundaryAndRange [ 1 ]
57- . Substring ( 0 , boundaryAndRange [ 1 ] . Length - CompositeRangeInternal . SuffixString . Length )
55+ var result = boundaryAndRange [ 1 ] [ ..^ CompositeRangeInternal . SuffixString . Length ]
5856 . Split ( new [ ] { CompositeRangeInternal . SeparatorString } , StringSplitOptions . None )
5957 . Select ( s => ParseRange ( s , parseValueCallback , parseKeyCallback ) )
6058 . ToCompositeRange ( ) ;
@@ -454,11 +452,11 @@ public static void TestCompositeRangeWithValues()
454452 var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
455453 AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "[A0..A3]: { '1':[A0..A2]; '2':[A1..A3] }" ) ;
456454
457- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
455+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
458456 AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "[A0..B3]: { '1':[A0..B2]; '2':[A1..B3] }" ) ;
459457
460458 var compositeRange4 =
461- compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i . Substring ( 1 ) , CultureInfo . InvariantCulture ) ) ;
459+ compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i [ 1 .. ] , CultureInfo . InvariantCulture ) ) ;
462460 AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "[0..3]: { [0..2]; [1..3] }" ) ;
463461
464462 AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -492,11 +490,11 @@ public static void TestCompositeRangeExclusiveWithValues()
492490 var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
493491 AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "(A0..A3): { '1':(A0..A2); '2':(A1..A3) }" ) ;
494492
495- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
493+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
496494 AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "(A0..B3): { '1':(A0..B2); '2':(A1..B3) }" ) ;
497495
498496 var compositeRange4 =
499- compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i . Substring ( 1 ) , CultureInfo . InvariantCulture ) ) ;
497+ compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i [ 1 .. ] , CultureInfo . InvariantCulture ) ) ;
500498 AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "(0..3): { (0..2); (1..3) }" ) ;
501499
502500 AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -530,11 +528,11 @@ public static void TestCompositeRangeExclusiveFromWithValues()
530528 var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
531529 AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "(A0..A3]: { '1':(A0..A2]; '2':(A1..A3] }" ) ;
532530
533- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
531+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
534532 AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "(A0..B3]: { '1':(A0..B2]; '2':(A1..B3] }" ) ;
535533
536534 var compositeRange4 =
537- compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i . Substring ( 1 ) , CultureInfo . InvariantCulture ) ) ;
535+ compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i [ 1 .. ] , CultureInfo . InvariantCulture ) ) ;
538536 AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "(0..3]: { (0..2]; (1..3] }" ) ;
539537
540538 AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -568,11 +566,11 @@ public static void TestCompositeRangeExclusiveToWithValues()
568566 var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
569567 AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "[A0..A3): { '1':[A0..A2); '2':[A1..A3) }" ) ;
570568
571- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
569+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
572570 AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "[A0..B3): { '1':[A0..B2); '2':[A1..B3) }" ) ;
573571
574572 var compositeRange4 =
575- compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i . Substring ( 1 ) , CultureInfo . InvariantCulture ) ) ;
573+ compositeRange3 . WithoutKeys ( ) . WithValues ( i => int . Parse ( i [ 1 .. ] , CultureInfo . InvariantCulture ) ) ;
576574 AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "[0..3): { [0..2); [1..3) }" ) ;
577575
578576 AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
0 commit comments