@@ -68,8 +68,8 @@ public class Scanner : IScanner
68
68
private bool streamEndProduced ;
69
69
private bool plainScalarFollowedByComment ;
70
70
private long flowSequenceStartLine ;
71
- private bool flowCollectionFetched = false ;
72
- private bool startFlowCollectionFetched = false ;
71
+ private bool flowCollectionFetched ;
72
+ private bool startFlowCollectionFetched ;
73
73
private long indent = - 1 ;
74
74
private bool flowScalarFetched ;
75
75
private bool simpleKeyAllowed ;
@@ -78,7 +78,7 @@ public class Scanner : IScanner
78
78
private bool tokenAvailable ;
79
79
private Token ? previous ;
80
80
private Anchor ? previousAnchor ;
81
- private Scalar ? lastScalar = null ;
81
+ private Scalar ? lastScalar ;
82
82
83
83
private bool IsDocumentStart ( ) =>
84
84
! analyzer . EndOfInput &&
@@ -1282,7 +1282,9 @@ private void FetchAnchor(bool isAlias)
1282
1282
tokens . Enqueue ( ScanAnchor ( isAlias ) ) ;
1283
1283
}
1284
1284
1285
+ #pragma warning disable CA1859
1285
1286
private Token ScanAnchor ( bool isAlias )
1287
+ #pragma warning restore CA1859
1286
1288
{
1287
1289
// Eat the indicator character.
1288
1290
@@ -1369,8 +1371,7 @@ private void FetchTag()
1369
1371
/// <summary>
1370
1372
/// Scan a TAG token.
1371
1373
/// </summary>
1372
-
1373
- Token ScanTag ( )
1374
+ private Tag ScanTag ( )
1374
1375
{
1375
1376
var start = cursor . Mark ( ) ;
1376
1377
@@ -1478,8 +1479,7 @@ private void FetchBlockScalar(bool isLiteral)
1478
1479
/// <summary>
1479
1480
/// Scan a block scalar.
1480
1481
/// </summary>
1481
-
1482
- Token ScanBlockScalar ( bool isLiteral )
1482
+ private Scalar ScanBlockScalar ( bool isLiteral )
1483
1483
{
1484
1484
using var valueBuilder = StringBuilderPool . Rent ( ) ;
1485
1485
var value = valueBuilder . Builder ;
@@ -1629,13 +1629,13 @@ Token ScanBlockScalar(bool isLiteral)
1629
1629
}
1630
1630
else
1631
1631
{
1632
- value . Append ( leadingBreak . ToString ( ) ) ;
1632
+ value . Append ( leadingBreak ) ;
1633
1633
leadingBreak . Length = 0 ;
1634
1634
}
1635
1635
1636
1636
// Append the remaining line breaks.
1637
1637
1638
- value . Append ( trailingBreaks . ToString ( ) ) ;
1638
+ value . Append ( trailingBreaks ) ;
1639
1639
trailingBreaks . Length = 0 ;
1640
1640
1641
1641
// Is it a leading whitespace?
@@ -2064,20 +2064,20 @@ private Scalar ScanFlowScalar(bool isSingleQuoted)
2064
2064
}
2065
2065
else
2066
2066
{
2067
- value . Append ( trailingBreaks . ToString ( ) ) ;
2067
+ value . Append ( trailingBreaks ) ;
2068
2068
}
2069
2069
}
2070
2070
else
2071
2071
{
2072
- value . Append ( leadingBreak . ToString ( ) ) ;
2073
- value . Append ( trailingBreaks . ToString ( ) ) ;
2072
+ value . Append ( leadingBreak ) ;
2073
+ value . Append ( trailingBreaks ) ;
2074
2074
}
2075
2075
leadingBreak . Length = 0 ;
2076
2076
trailingBreaks . Length = 0 ;
2077
2077
}
2078
2078
else
2079
2079
{
2080
- value . Append ( whitespaces . ToString ( ) ) ;
2080
+ value . Append ( whitespaces ) ;
2081
2081
whitespaces . Length = 0 ;
2082
2082
}
2083
2083
}
@@ -2220,7 +2220,7 @@ private Scalar ScanPlainScalar(ref bool isMultiline)
2220
2220
}
2221
2221
if ( flowLevel > 0 && cursor . LineOffset < currentIndent )
2222
2222
{
2223
- throw new Exception ( ) ;
2223
+ throw new InvalidOperationException ( ) ;
2224
2224
}
2225
2225
// Copy the character.
2226
2226
@@ -2382,7 +2382,7 @@ private void SkipWhitespaces()
2382
2382
/// %YAML 1.1 # a comment \n
2383
2383
/// ^^^^^^
2384
2384
/// </summary>
2385
- private Token ScanVersionDirectiveValue ( in Mark start )
2385
+ private VersionDirective ScanVersionDirectiveValue ( in Mark start )
2386
2386
{
2387
2387
SkipWhitespaces ( ) ;
2388
2388
@@ -2413,7 +2413,7 @@ private Token ScanVersionDirectiveValue(in Mark start)
2413
2413
/// %TAG !yaml! tag:yaml.org,2002: \n
2414
2414
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2415
2415
/// </summary>
2416
- private Token ScanTagDirectiveValue ( in Mark start )
2416
+ private TagDirective ScanTagDirectiveValue ( in Mark start )
2417
2417
{
2418
2418
SkipWhitespaces ( ) ;
2419
2419
@@ -2499,15 +2499,15 @@ private string ScanTagUri(string? head, Mark start)
2499
2499
}
2500
2500
2501
2501
var result = tag . ToString ( ) ;
2502
- if ( result . EndsWith ( "," ) )
2502
+ if ( result . EndsWith ( ',' ) )
2503
2503
{
2504
2504
throw new SyntaxErrorException ( cursor . Mark ( ) , cursor . Mark ( ) , "Unexpected comma at end of tag" ) ;
2505
2505
}
2506
2506
2507
2507
return result ;
2508
2508
}
2509
2509
2510
- private static readonly byte [ ] EmptyBytes = new byte [ 0 ] ;
2510
+ private static readonly byte [ ] EmptyBytes = Array . Empty < byte > ( ) ;
2511
2511
2512
2512
/// <summary>
2513
2513
/// Decode an URI-escape sequence corresponding to a single UTF-8 character.
0 commit comments