@@ -32,8 +32,7 @@ private static CompositeRange<T> ParseCompositeRange<T>(
32
32
var boundaryAndRange = value . Split ( new [ ] { CompositeRangeInternal . PrefixString } , 2 , StringSplitOptions . None ) ;
33
33
var boundary = ParseRange ( boundaryAndRange [ 0 ] , parseValueCallback ) ;
34
34
35
- var result = boundaryAndRange [ 1 ]
36
- . Substring ( 0 , boundaryAndRange [ 1 ] . Length - CompositeRangeInternal . SuffixString . Length )
35
+ var result = boundaryAndRange [ 1 ] [ ..^ CompositeRangeInternal . SuffixString . Length ]
37
36
. Split ( new [ ] { CompositeRangeInternal . SeparatorString } , StringSplitOptions . None )
38
37
. Select ( s => ParseRange ( s , parseValueCallback ) )
39
38
. ToCompositeRange ( ) ;
@@ -53,8 +52,7 @@ private static CompositeRange<T, TKey> ParseCompositeRange<T, TKey>(
53
52
var boundaryAndRange = value . Split ( new [ ] { CompositeRangeInternal . PrefixString } , 2 , StringSplitOptions . None ) ;
54
53
var boundary = ParseRange ( boundaryAndRange [ 0 ] , parseValueCallback ) ;
55
54
56
- var result = boundaryAndRange [ 1 ]
57
- . Substring ( 0 , boundaryAndRange [ 1 ] . Length - CompositeRangeInternal . SuffixString . Length )
55
+ var result = boundaryAndRange [ 1 ] [ ..^ CompositeRangeInternal . SuffixString . Length ]
58
56
. Split ( new [ ] { CompositeRangeInternal . SeparatorString } , StringSplitOptions . None )
59
57
. Select ( s => ParseRange ( s , parseValueCallback , parseKeyCallback ) )
60
58
. ToCompositeRange ( ) ;
@@ -454,11 +452,11 @@ public static void TestCompositeRangeWithValues()
454
452
var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
455
453
AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "[A0..A3]: { '1':[A0..A2]; '2':[A1..A3] }" ) ;
456
454
457
- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
455
+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
458
456
AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "[A0..B3]: { '1':[A0..B2]; '2':[A1..B3] }" ) ;
459
457
460
458
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 ) ) ;
462
460
AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "[0..3]: { [0..2]; [1..3] }" ) ;
463
461
464
462
AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -492,11 +490,11 @@ public static void TestCompositeRangeExclusiveWithValues()
492
490
var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
493
491
AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "(A0..A3): { '1':(A0..A2); '2':(A1..A3) }" ) ;
494
492
495
- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
493
+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
496
494
AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "(A0..B3): { '1':(A0..B2); '2':(A1..B3) }" ) ;
497
495
498
496
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 ) ) ;
500
498
AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "(0..3): { (0..2); (1..3) }" ) ;
501
499
502
500
AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -530,11 +528,11 @@ public static void TestCompositeRangeExclusiveFromWithValues()
530
528
var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
531
529
AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "(A0..A3]: { '1':(A0..A2]; '2':(A1..A3] }" ) ;
532
530
533
- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
531
+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
534
532
AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "(A0..B3]: { '1':(A0..B2]; '2':(A1..B3] }" ) ;
535
533
536
534
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 ) ) ;
538
536
AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "(0..3]: { (0..2]; (1..3] }" ) ;
539
537
540
538
AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
@@ -568,11 +566,11 @@ public static void TestCompositeRangeExclusiveToWithValues()
568
566
var compositeRange2 = compositeRange . WithValues ( i => "A" + i ) ;
569
567
AreEqual ( compositeRange2 . ToString ( CultureInfo . InvariantCulture ) , "[A0..A3): { '1':[A0..A2); '2':[A1..A3) }" ) ;
570
568
571
- var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i . Substring ( 1 ) ) ;
569
+ var compositeRange3 = compositeRange2 . WithValues ( i => i , i => "B" + i [ 1 .. ] ) ;
572
570
AreEqual ( compositeRange3 . ToString ( CultureInfo . InvariantCulture ) , "[A0..B3): { '1':[A0..B2); '2':[A1..B3) }" ) ;
573
571
574
572
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 ) ) ;
576
574
AreEqual ( compositeRange4 . ToString ( CultureInfo . InvariantCulture ) , "[0..3): { [0..2); [1..3) }" ) ;
577
575
578
576
AreEqual ( compositeRange4 , compositeRange . WithoutKeys ( ) ) ;
0 commit comments