1 write to _ps
System.Private.Xml (1)
System\Xml\Core\XmlTextReaderImpl.cs (1)
8118
_ps
= _parsingStatesStack[_parsingStatesStackTop--];
1706 references to _ps
System.Private.Xml (1706)
System\Xml\Core\XmlTextReaderImpl.cs (1050)
351
_ps
.lineNo = 1;
352
_ps
.lineStartPos = -1;
413
_ps
.lineNo = _lineNumberOffset + 1;
414
_ps
.lineStartPos = -_linePositionOffset - 1;
415
_curNode.SetLineInfo(
_ps
.LineNo - 1,
_ps
.LinePos - 1);
475
_reportedBaseUri =
_ps
.baseUriStr;
476
_reportedEncoding =
_ps
.encoding;
499
_reportedEncoding =
_ps
.encoding;
522
_reportedBaseUri =
_ps
.baseUriStr;
523
_reportedEncoding =
_ps
.encoding;
544
_reportedEncoding =
_ps
.encoding;
575
_ps
.baseUri = GetTempResolver().ResolveUri(null, url);
576
_ps
.baseUriStr =
_ps
.baseUri.ToString();
577
_reportedBaseUri =
_ps
.baseUriStr;
663
_reportedEncoding =
_ps
.encoding;
743
_reportedEncoding =
_ps
.encoding;
796
_reportedEncoding =
_ps
.encoding;
814
_reportedBaseUri =
_ps
.baseUriStr;
815
_reportedEncoding =
_ps
.encoding;
1237
Debug.Assert(!
_ps
.appendMode);
1246
_reportedEncoding =
_ps
.encoding;
1249
_reportedEncoding =
_ps
.encoding;
1286
_reportedEncoding =
_ps
.encoding;
1287
_reportedBaseUri =
_ps
.baseUriStr;
1293
_curNode.SetLineInfo(
_ps
.lineNo,
_ps
.LinePos);
1294
_reportedEncoding =
_ps
.encoding;
1295
_reportedBaseUri =
_ps
.baseUriStr;
1467
_attributeValueBaseEntityId =
_ps
.entityId;
1472
if (
_ps
.entityId == _attributeValueBaseEntityId)
1508
if (
_ps
.charsUsed -
_ps
.charPos == 0)
1529
if (
_ps
.charsUsed -
_ps
.charPos == 0 && !
_ps
.entity!.IsExternal)
1547
_ps
.entityResolvedManually = true;
1867
Debug.Assert(
_ps
.chars != null);
1868
BlockCopyChars(
_ps
.chars, startPos, buffer, (index + readCount), copyCount);
1891
Debug.Assert(
_ps
.chars != null);
1892
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
2020
if (
_ps
.entity == null ||
_ps
.entity.IsExternal)
2022
_ps
.eolNormalized = !value;
2111
_ps
.baseUri = null;
2178
_stringBuilder.Append(
_ps
.chars, _incReadLeftStartPos, _incReadLeftEndPos - _incReadLeftStartPos);
2188
_ps
.appendMode = false;
2191
_stringBuilder.Append(
_ps
.chars,
_ps
.charPos,
_ps
.charsUsed -
_ps
.charPos);
2192
_ps
.charPos =
_ps
.charsUsed;
2363
if (
_ps
.baseUriStr.Length > 0 &&
_ps
.baseUri == null && _xmlResolver != null)
2365
_ps
.baseUri = _xmlResolver.ResolveUri(null,
_ps
.baseUriStr);
2368
return
_ps
.baseUri;
2376
return
_ps
.isEof;
2384
return
_ps
.chars;
2392
return
_ps
.charsUsed;
2400
return
_ps
.charPos;
2404
Debug.Assert(value >= 0 && value <=
_ps
.charsUsed);
2405
_ps
.charPos = value;
2421
return
_ps
.eolNormalized;
2446
return
_ps
.LineNo;
2454
return
_ps
.lineStartPos;
2514
if (e.ResString == SR.Xml_UnexpectedEOF &&
_ps
.entity != null)
2516
SendValidationEvent(XmlSeverityType.Error, SR.Sch_ParEntityRefNesting, null,
_ps
.LineNo,
_ps
.LinePos);
2555
entityId =
_ps
.entityId;
2568
oldEntity =
_ps
.entity;
2570
newEntityId =
_ps
.entityId;
2588
if (
_ps
.baseUri == null && !string.IsNullOrEmpty(
_ps
.baseUriStr))
2590
_ps
.baseUri = _xmlResolver.ResolveUri(null,
_ps
.baseUriStr);
2593
PushExternalEntityOrSubset(publicId, systemId,
_ps
.baseUri, null);
2595
_ps
.entity = null;
2596
_ps
.entityId = 0;
2598
Debug.Assert(
_ps
.appendMode);
2599
int initialPos =
_ps
.charPos;
2606
_ps
.charPos = initialPos;
2622
_ps
.entity = null;
2623
_ps
.entityId = 0;
2624
_ps
.eolNormalized = false;
2655
_ps
.charPos = pos;
2662
_ps
.charPos = pos;
2669
_ps
.charPos = pos;
2682
Throw(new XmlException(res, string.Empty, lineNo, linePos,
_ps
.baseUriStr));
2688
Throw(new XmlException(res, arg,
_ps
.LineNo,
_ps
.LinePos,
_ps
.baseUriStr));
2694
Throw(new XmlException(res, arg, lineNo, linePos,
_ps
.baseUriStr));
2700
Throw(new XmlException(res, args,
_ps
.LineNo,
_ps
.LinePos,
_ps
.baseUriStr));
2712
Throw(new XmlException(res, args, innerException,
_ps
.LineNo,
_ps
.LinePos,
_ps
.baseUriStr));
2732
Throw(new XmlException(e.Message, (Exception?)null, lineNo, linePos,
_ps
.baseUriStr));
2738
Throw(new XmlException(res, string.Empty,
_ps
.baseUriStr));
2744
Throw(new XmlException(res, arg,
_ps
.baseUriStr));
2750
Throw(new XmlException(res, args, innerException, 0, 0,
_ps
.baseUriStr));
2767
SendValidationEvent(severity, new XmlSchemaException(code, arg,
_ps
.baseUriStr, lineNo, linePos));
2800
while (
_ps
.entityId != _attributeValueBaseEntityId)
2842
Debug.Assert(
_ps
.charPos == 0 &&
_ps
.charsUsed == 0 &&
_ps
.textReader == null);
2846
_ps
.stream = stream;
2847
_ps
.baseUri = baseUri;
2848
_ps
.baseUriStr = baseUriStr;
2854
_ps
.bytes = bytes;
2855
_ps
.bytesUsed = byteCount;
2856
bufferSize =
_ps
.bytes.Length;
2869
if (
_ps
.bytes == null ||
_ps
.bytes.Length < bufferSize)
2871
_ps
.bytes = new byte[bufferSize];
2876
if (
_ps
.chars == null ||
_ps
.chars.Length < bufferSize + 1)
2878
_ps
.chars = new char[bufferSize + 1];
2882
_ps
.bytePos = 0;
2883
if (
_ps
.bytesUsed < 4 &&
_ps
.bytes.Length -
_ps
.bytesUsed > 0)
2885
int bytesToRead = Math.Min(4,
_ps
.bytes.Length -
_ps
.bytesUsed);
2886
int read = stream.ReadAtLeast(
_ps
.bytes.AsSpan(
_ps
.bytesUsed), bytesToRead, throwOnEndOfStream: false);
2889
_ps
.isStreamEof = true;
2891
_ps
.bytesUsed += read;
2901
_documentStartBytePos =
_ps
.bytePos;
2903
_ps
.eolNormalized = !_normalize;
2906
_ps
.appendMode = true;
2917
Debug.Assert(
_ps
.charPos == 0 &&
_ps
.charsUsed == 0 &&
_ps
.stream == null);
2920
_ps
.textReader = input;
2921
_ps
.baseUriStr = baseUriStr;
2922
_ps
.baseUri = baseUri;
2924
if (
_ps
.chars == null)
2928
_ps
.chars = new char[XmlReader.AsyncBufferSize + 1];
2932
_ps
.chars = new char[XmlReader.DefaultBufferSize + 1];
2936
_ps
.encoding = Encoding.Unicode;
2937
_ps
.eolNormalized = !_normalize;
2940
_ps
.appendMode = true;
2946
Debug.Assert(
_ps
.stream == null &&
_ps
.textReader == null);
2947
Debug.Assert(
_ps
.charPos == 0 &&
_ps
.charsUsed == 0);
2951
_ps
.baseUriStr = baseUriStr;
2952
_ps
.baseUri = null;
2955
_ps
.chars = new char[len + 1];
2956
str.CopyTo(0,
_ps
.chars, 0, str.Length);
2957
_ps
.charsUsed = len;
2958
_ps
.chars[len] = (char)0;
2960
_ps
.encoding = originalEncoding;
2962
_ps
.eolNormalized = !_normalize;
2963
_ps
.isEof = true;
2982
_ps
.baseUriStr = parserContext.BaseURI;
2983
_ps
.baseUri = null;
2990
_ps
.baseUriStr = string.Empty;
2991
_ps
.baseUri = null;
2994
_reportedBaseUri =
_ps
.baseUriStr;
2999
_ps
.appendMode = false;
3014
_ps
.appendMode = false;
3060
if (
_ps
.baseUri == null)
3062
_ps
.baseUri = tmpResolver.ResolveUri(null, _url);
3063
_ps
.baseUriStr =
_ps
.baseUri.ToString();
3068
_ps
.stream = (Stream?)tmpResolver.GetEntity(
_ps
.baseUri, null, typeof(Stream));
3076
if (
_ps
.stream == null)
3078
ThrowWithoutLineInfo(SR.Xml_CannotResolveUrl,
_ps
.baseUriStr);
3081
Debug.Assert(
_ps
.stream != null);
3082
InitStreamInput(
_ps
.baseUri,
_ps
.baseUriStr,
_ps
.stream, null);
3083
_reportedEncoding =
_ps
.encoding;
3089
Debug.Assert(
_ps
.bytes != null);
3090
Debug.Assert(
_ps
.bytePos == 0);
3092
if (
_ps
.bytesUsed < 2)
3097
int first2Bytes =
_ps
.bytes[0] << 8 |
_ps
.bytes[1];
3098
int next2Bytes = (
_ps
.bytesUsed >= 4) ? (
_ps
.bytes[2] << 8 |
_ps
.bytes[3]) : 0;
3176
Debug.Assert(
_ps
.charPos == 0);
3177
_ps
.encoding = Encoding.UTF8;
3178
_ps
.decoder = new SafeAsciiDecoder();
3182
_ps
.encoding = encoding;
3183
_ps
.decoder =
_ps
.encoding.WebName switch // Encoding.Codepage is not supported in Silverlight
3194
Debug.Assert(
_ps
.encoding != null);
3195
Debug.Assert(
_ps
.bytes != null);
3196
ReadOnlySpan<byte> preamble =
_ps
.encoding.Preamble;
3197
if (
_ps
.bytes.AsSpan(0,
_ps
.bytesUsed).StartsWith(preamble))
3199
_ps
.bytePos = preamble.Length;
3206
Debug.Assert(
_ps
.encoding != null);
3207
if ((newEncoding.WebName !=
_ps
.encoding.WebName ||
_ps
.decoder is SafeAsciiDecoder) && !_afterResetState)
3209
Debug.Assert(
_ps
.stream != null);
3211
_ps
.appendMode = false;
3221
Debug.Assert(
_ps
.encoding != null);
3224
if (
_ps
.stream == null)
3226
return
_ps
.encoding;
3234
if (
_ps
.encoding.WebName != "utf-16BE" &&
3235
_ps
.encoding.WebName != "utf-16" &&
3247
return
_ps
.encoding;
3275
if (_afterResetState &&
_ps
.encoding.WebName != newEncoding.WebName)
3285
Debug.Assert(
_ps
.stream != null &&
_ps
.decoder != null &&
_ps
.bytes != null);
3286
Debug.Assert(
_ps
.appendMode, "UnDecodeChars cannot be called after ps.appendMode has been changed to false");
3288
Debug.Assert(
_ps
.charsUsed >=
_ps
.charPos, "The current position must be in the valid character range.");
3296
Debug.Assert(_charactersInDocument >=
_ps
.charsUsed -
_ps
.charPos,
3298
_charactersInDocument -=
_ps
.charsUsed -
_ps
.charPos;
3305
Debug.Assert(_charactersFromEntities >=
_ps
.charsUsed -
_ps
.charPos,
3307
_charactersFromEntities -=
_ps
.charsUsed -
_ps
.charPos;
3311
_ps
.bytePos = _documentStartBytePos; // byte position after preamble
3312
if (
_ps
.charPos > 0)
3314
Debug.Assert(
_ps
.encoding != null);
3315
Debug.Assert(
_ps
.chars != null);
3316
_ps
.bytePos +=
_ps
.encoding.GetByteCount(
_ps
.chars, 0,
_ps
.charPos);
3319
_ps
.charsUsed =
_ps
.charPos;
3320
_ps
.isEof = false;
3336
if (
_ps
.isEof)
3341
Debug.Assert(
_ps
.chars != null);
3343
if (
_ps
.appendMode)
3346
if (
_ps
.charsUsed ==
_ps
.chars.Length - 1)
3354
char[] newChars = new char[
_ps
.chars.Length * 2];
3355
BlockCopyChars(
_ps
.chars, 0, newChars, 0,
_ps
.chars.Length);
3356
_ps
.chars = newChars;
3359
if (
_ps
.stream != null)
3362
if (
_ps
.bytesUsed -
_ps
.bytePos < MaxByteSequenceLen)
3364
Debug.Assert(
_ps
.bytes != null);
3365
if (
_ps
.bytes.Length -
_ps
.bytesUsed < MaxByteSequenceLen)
3367
byte[] newBytes = new byte[
_ps
.bytes.Length * 2];
3368
BlockCopy(
_ps
.bytes, 0, newBytes, 0,
_ps
.bytesUsed);
3369
_ps
.bytes = newBytes;
3374
charsRead =
_ps
.chars.Length -
_ps
.charsUsed - 1;
3382
int charsLen =
_ps
.chars.Length;
3383
if (charsLen -
_ps
.charsUsed <= charsLen / 2)
3392
int copyCharsCount =
_ps
.charsUsed -
_ps
.charPos;
3395
_ps
.lineStartPos -=
_ps
.charPos;
3398
BlockCopyChars(
_ps
.chars,
_ps
.charPos,
_ps
.chars, 0, copyCharsCount);
3400
_ps
.charPos = 0;
3401
_ps
.charsUsed = copyCharsCount;
3405
char[] newChars = new char[
_ps
.chars.Length * 2];
3406
BlockCopyChars(
_ps
.chars, 0, newChars, 0,
_ps
.chars.Length);
3407
_ps
.chars = newChars;
3411
if (
_ps
.stream != null)
3414
int bytesLeft =
_ps
.bytesUsed -
_ps
.bytePos;
3419
_ps
.bytesUsed = 0;
3423
Debug.Assert(
_ps
.bytes != null);
3424
BlockCopy(
_ps
.bytes,
_ps
.bytePos,
_ps
.bytes, 0, bytesLeft);
3425
_ps
.bytesUsed = bytesLeft;
3428
_ps
.bytePos = 0;
3431
charsRead =
_ps
.chars.Length -
_ps
.charsUsed - 1;
3434
if (
_ps
.stream != null)
3436
if (!
_ps
.isStreamEof)
3438
Debug.Assert(
_ps
.bytes != null);
3441
if (
_ps
.bytePos ==
_ps
.bytesUsed &&
_ps
.bytes.Length -
_ps
.bytesUsed > 0)
3443
int read =
_ps
.stream.Read(
_ps
.bytes,
_ps
.bytesUsed,
_ps
.bytes.Length -
_ps
.bytesUsed);
3446
_ps
.isStreamEof = true;
3448
_ps
.bytesUsed += read;
3452
int originalBytePos =
_ps
.bytePos;
3456
if (charsRead == 0 &&
_ps
.bytePos != originalBytePos)
3462
else if (
_ps
.textReader != null)
3465
charsRead =
_ps
.textReader.Read(
_ps
.chars,
_ps
.charsUsed,
_ps
.chars.Length -
_ps
.charsUsed - 1);
3466
_ps
.charsUsed += charsRead;
3477
Debug.Assert(
_ps
.charsUsed <
_ps
.chars.Length);
3478
_ps
.isEof = true;
3481
_ps
.chars[
_ps
.charsUsed] = (char)0;
3488
Debug.Assert(
_ps
.stream != null &&
_ps
.decoder != null &&
_ps
.bytes != null);
3489
Debug.Assert(
_ps
.chars != null);
3490
Debug.Assert(maxCharsCount <=
_ps
.chars.Length -
_ps
.charsUsed - 1);
3493
int bytesCount =
_ps
.bytesUsed -
_ps
.bytePos;
3504
_ps
.decoder.Convert(
_ps
.bytes,
_ps
.bytePos, bytesCount,
_ps
.chars,
_ps
.charsUsed, maxCharsCount, false, out bytesCount, out charsCount, out completed);
3512
_ps
.bytePos += bytesCount;
3513
_ps
.charsUsed += charsCount;
3529
Debug.Assert(
_ps
.decoder != null);
3530
Debug.Assert(
_ps
.bytes != null);
3531
Debug.Assert(
_ps
.chars != null);
3532
_ps
.decoder.Convert(
_ps
.bytes,
_ps
.bytePos + bytesDecoded, 1,
_ps
.chars,
_ps
.charsUsed + charsDecoded, 2, false, out bDec, out chDec, out completed);
3545
Throw(
_ps
.charsUsed, SR.Xml_InvalidCharInThisEncoding);
3564
_ps
.Close(closeInput);
3579
Debug.Assert(
_ps
.chars != null);
3580
BlockCopyChars(
_ps
.chars, sourcePos,
_ps
.chars, destPos, count);
3586
while (
_ps
.charsUsed -
_ps
.charPos < 6)
3594
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith(XmlDeclarationBeginning) ||
3595
XmlCharType.IsNameSingleChar(
_ps
.chars![
_ps
.charPos + 5]))
3602
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos + 2);
3606
_ps
.charPos += 5;
3622
if (
_ps
.chars[
_ps
.charPos] == '?')
3626
if (
_ps
.chars[
_ps
.charPos + 1] == '>')
3633
_ps
.charPos += 2;
3653
Debug.Assert(
_ps
.encoding != null);
3654
string encodingName =
_ps
.encoding.WebName;
3656
encodingName != "utf-16BE" && !(
_ps
.encoding is Ucs4Encoding))
3658
Throw(SR.Xml_EncodingSwitchAfterResetState, (
_ps
.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
3661
if (
_ps
.decoder is SafeAsciiDecoder)
3670
_ps
.appendMode = false;
3673
else if (
_ps
.charPos + 1 ==
_ps
.charsUsed)
3692
switch (
_ps
.chars.AsSpan(
_ps
.charPos, nameEndPos -
_ps
.charPos))
3731
attr.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
3733
sb.Append(
_ps
.chars,
_ps
.charPos, nameEndPos -
_ps
.charPos);
3734
_ps
.charPos = nameEndPos;
3737
if (
_ps
.chars[
_ps
.charPos] != '=')
3740
if (
_ps
.chars[
_ps
.charPos] != '=')
3746
_ps
.charPos++;
3748
char quoteChar =
_ps
.chars[
_ps
.charPos];
3752
quoteChar =
_ps
.chars[
_ps
.charPos];
3759
_ps
.charPos++;
3764
attr.SetLineInfo2(
_ps
.LineNo,
_ps
.LinePos);
3768
int pos =
_ps
.charPos;
3771
chars =
_ps
.chars;
3777
if (
_ps
.chars[pos] == quoteChar)
3784
if (
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("1.0"))
3789
attr.SetValue(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
3795
string badVersion = new string(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
3800
string encName = new string(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
3810
switch (
_ps
.chars.AsSpan(
_ps
.charPos, pos -
_ps
.charPos))
3820
Throw(SR.Xml_InvalidXmlDecl,
_ps
.LineNo,
_ps
.LinePos - 1);
3826
attr.SetValue(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
3834
sb.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
3836
_ps
.charPos = pos + 1;
3839
else if (pos ==
_ps
.charsUsed)
3856
if (
_ps
.isEof || ReadData() == 0)
3871
Debug.Assert(
_ps
.encoding != null);
3872
string encodingName =
_ps
.encoding.WebName;
3874
encodingName != "utf-16BE" && !(
_ps
.encoding is Ucs4Encoding))
3876
Throw(SR.Xml_EncodingSwitchAfterResetState, (
_ps
.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
3879
if (
_ps
.decoder is SafeAsciiDecoder)
3883
_ps
.appendMode = false;
3894
int pos =
_ps
.charPos;
3895
Debug.Assert(
_ps
.chars != null);
3896
char[] chars =
_ps
.chars;
3902
if (
_ps
.charsUsed - pos < 4) // minimum "<a/>"
3909
_ps
.charPos = pos + 1;
3917
if (
_ps
.charsUsed - pos < 2) // minimum characters expected "--"
3924
_ps
.charPos = pos + 2;
3942
if (
_ps
.charsUsed - pos < 6)
3948
_ps
.charPos = pos + 6;
3963
Throw(
_ps
.charPos, SR.Xml_InvalidRootData);
3972
_ps
.charPos = pos;
4008
_ps
.charPos = pos;
4049
else if (pos ==
_ps
.charsUsed || ((_v1Compat || mangoQuirks) && chars[pos] == 0x0))
4077
Debug.Assert(pos ==
_ps
.charsUsed && !
_ps
.isEof);
4119
int pos =
_ps
.charPos;
4120
Debug.Assert(
_ps
.chars != null);
4121
char[] chars =
_ps
.chars;
4131
_ps
.charPos = pos + 2;
4139
if (
_ps
.charsUsed - pos < 2)
4146
_ps
.charPos = pos + 2;
4162
if (
_ps
.charsUsed - pos < 6)
4168
_ps
.charPos = pos + 6;
4191
_ps
.charPos = pos + 2;
4196
if (pos + 1 ==
_ps
.charsUsed)
4203
_ps
.charPos = pos + 1;
4217
if (pos ==
_ps
.charsUsed)
4236
if (
_ps
.charsUsed -
_ps
.charPos != 0)
4262
Throw(
_ps
.charsUsed, SR.Xml_UnexpectedEOF1);
4286
Throw(
_ps
.charsUsed, SR.Xml_UnexpectedEOFInElementContent, _stringBuilder.ToString());
4293
int pos =
_ps
.charPos;
4294
Debug.Assert(
_ps
.chars != null);
4295
char[] chars =
_ps
.chars;
4298
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
4349
else if (pos + 1 <
_ps
.charsUsed)
4356
chars =
_ps
.chars;
4367
_nameTable.Add(chars,
_ps
.charPos, pos -
_ps
.charPos));
4371
int startPos =
_ps
.charPos;
4384
_nameTable.Add(chars,
_ps
.charPos, prefixLen),
4395
_ps
.charPos = pos;
4405
_ps
.charPos = pos + 1;
4411
if (pos + 1 ==
_ps
.charsUsed)
4413
_ps
.charPos = pos;
4418
pos =
_ps
.charPos;
4419
chars =
_ps
.chars;
4426
_ps
.charPos = pos + 2;
4436
Throw(pos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
4536
while (
_ps
.charsUsed -
_ps
.charPos < prefLen + locLen + 1)
4545
Debug.Assert(
_ps
.chars != null);
4546
char[] chars =
_ps
.chars;
4549
if (!chars.AsSpan(
_ps
.charPos).StartsWith(startTagNode.localName))
4557
int colonPos =
_ps
.charPos + prefLen;
4558
if (!chars.AsSpan(
_ps
.charPos).StartsWith(startTagNode.prefix) ||
4567
LineInfo endTagLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos);
4572
pos =
_ps
.charPos + nameLen;
4573
chars =
_ps
.chars;
4575
if (pos ==
_ps
.charsUsed)
4602
else if (pos ==
_ps
.charsUsed && !
_ps
.isEof)
4616
else if (pos ==
_ps
.charsUsed)
4642
_ps
.charPos = pos + 1;
4656
Debug.Assert(
_ps
.chars != null);
4661
args[3] = new string(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
4674
int pos =
_ps
.charPos;
4675
Debug.Assert(
_ps
.chars != null);
4676
char[] chars =
_ps
.chars;
4701
else if (pos + 1 !=
_ps
.charsUsed)
4708
_ps
.charPos = pos;
4729
_ps
.charPos = pos + 1;
4737
if (pos + 1 ==
_ps
.charsUsed)
4743
_ps
.charPos = pos + 2;
4754
else if (pos ==
_ps
.charsUsed)
4760
Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
4764
if (pos ==
_ps
.charPos)
4768
_ps
.charPos = pos;
4771
int attrNameLinePos =
_ps
.LinePos;
4774
int attrNameLineNo =
_ps
.LineNo;
4827
chars =
_ps
.chars;
4830
else if (pos + 1 >=
_ps
.charsUsed)
4833
chars =
_ps
.chars;
4837
attr.SetLineInfo(
_ps
.LineNo, attrNameLinePos);
4840
Debug.Assert(attrNameLineNo ==
_ps
.LineNo);
4846
_ps
.charPos = pos;
4848
pos =
_ps
.charPos;
4859
_ps
.charPos = pos;
4861
pos =
_ps
.charPos;
4869
_ps
.charPos = pos;
4872
attr.SetLineInfo2(
_ps
.LineNo,
_ps
.LinePos);
4886
string val = new string(chars,
_ps
.charPos, pos -
_ps
.charPos);
4890
attr.SetValue(chars,
_ps
.charPos, pos -
_ps
.charPos);
4892
_ps
.charPos = pos;
4897
pos =
_ps
.charPos;
4898
chars =
_ps
.chars;
4926
_ps
.lineNo -= lineNoDelta;
4929
pos =
_ps
.charPos;
4930
chars =
_ps
.chars;
5096
Debug.Assert(
_ps
.chars != null);
5097
char[] chars =
_ps
.chars;
5098
int attributeBaseEntityId =
_ps
.entityId;
5100
LineInfo valueChunkLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos);
5113
if (pos -
_ps
.charPos > 0)
5115
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
5116
_ps
.charPos = pos;
5119
if (chars[pos] == quoteChar && attributeBaseEntityId ==
_ps
.entityId)
5134
_ps
.charPos++;
5143
_stringBuilder.Append(
_ps
.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA
5144
_ps
.charPos = pos;
5147
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
5153
_ps
.charPos = pos;
5168
_ps
.charPos++;
5182
if (pos -
_ps
.charPos > 0)
5184
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
5186
_ps
.charPos = pos;
5188
int enclosingEntityId =
_ps
.entityId;
5189
LineInfo entityLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos + 1);
5197
if (_parsingMode == ParsingMode.Full &&
_ps
.entityId == attributeBaseEntityId)
5211
_ps
.charPos++;
5228
valueChunkLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
5234
_ps
.charPos++;
5237
pos =
_ps
.charPos;
5258
Debug.Assert(
_ps
.entity != null);
5259
entityChunk.SetNamedNode(XmlNodeType.EntityReference,
_ps
.entity.Name);
5267
pos =
_ps
.charPos;
5270
pos =
_ps
.charPos;
5273
chars =
_ps
.chars;
5277
if (pos ==
_ps
.charsUsed)
5287
if (pos + 1 ==
_ps
.charsUsed)
5298
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
5308
if (
_ps
.charsUsed -
_ps
.charPos > 0)
5310
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
5315
Debug.Assert(
_ps
.isEof);
5323
if (attributeBaseEntityId !=
_ps
.entityId)
5337
if (attributeBaseEntityId ==
_ps
.entityId)
5340
valueChunkLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
5345
pos =
_ps
.charPos;
5346
chars =
_ps
.chars;
5363
_ps
.charPos = pos + 1;
5401
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
5419
Debug.Assert(
_ps
.chars != null);
5420
_curNode.SetValueNode(nodeType,
_ps
.chars, startPos, endPos - startPos);
5433
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5439
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5464
Debug.Assert(
_ps
.chars != null);
5465
_curNode.SetValueNode(XmlNodeType.Text,
_ps
.chars, startPos, endPos - startPos);
5474
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5481
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5539
Debug.Assert(
_ps
.chars != null);
5540
char[] chars =
_ps
.chars;
5541
int pos =
_ps
.charPos;
5569
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
5571
if (pos -
_ps
.charPos > 0)
5587
_ps
.charPos++;
5592
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
5594
if (!
_ps
.eolNormalized)
5632
if (pos >
_ps
.charPos)
5653
if (!XmlCharType.IsWhiteSpace(
_ps
.chars[pos - 1]))
5659
pos =
_ps
.charPos;
5662
chars =
_ps
.chars;
5666
if (
_ps
.charsUsed - pos < 3 && !
_ps
.isEof)
5679
if (pos ==
_ps
.charsUsed)
5689
if (pos + 1 ==
_ps
.charsUsed)
5701
int offset = pos -
_ps
.charPos;
5704
pos =
_ps
.charPos + offset;
5709
ThrowInvalidChar(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos + offset);
5716
if (pos >
_ps
.charPos)
5723
if (
_ps
.charsUsed -
_ps
.charPos > 0)
5725
if (
_ps
.chars[
_ps
.charPos] != (char)0xD &&
_ps
.chars[
_ps
.charPos] != ']')
5729
Debug.Assert(
_ps
.isEof);
5748
pos =
_ps
.charPos;
5749
chars =
_ps
.chars;
5761
startPos =
_ps
.charPos;
5763
_ps
.charPos = pos;
5782
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5784
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
5904
Debug.Assert(
_ps
.chars != null);
5908
if (
_ps
.chars[
_ps
.charPos] == '<' ||
_ps
.charsUsed -
_ps
.charPos == 0 || ZeroEndingStream(
_ps
.charPos))
5915
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
5917
if (
_ps
.chars[
_ps
.charPos] == '<' ||
_ps
.charsUsed -
_ps
.charPos == 0 || ZeroEndingStream(
_ps
.charPos))
5929
if (XmlCharType.IsCharData(
_ps
.chars[
_ps
.charPos]))
5935
ThrowInvalidChar(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos);
5942
Debug.Assert(
_ps
.chars != null);
5943
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
5944
_ps
.charPos++;
5946
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
5952
Debug.Assert(
_ps
.chars != null);
5953
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
5955
if (
_ps
.charPos + 1 ==
_ps
.charsUsed)
5964
if (
_ps
.chars[
_ps
.charPos + 1] == '#')
5992
_ps
.charPos++;
5993
int savedLinePos =
_ps
.LinePos;
6000
Throw(SR.Xml_ErrorParsingEntityName,
_ps
.LineNo, savedLinePos);
6005
if (
_ps
.chars[endPos] != ';')
6010
int entityLinePos =
_ps
.LinePos;
6011
string entityName = _nameTable.Add(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
6012
_ps
.charPos = endPos + 1;
6016
_reportedBaseUri =
_ps
.baseUriStr;
6017
_reportedEncoding =
_ps
.encoding;
6043
Throw(SR.Xml_UndeclaredEntity, name,
_ps
.LineNo, entityStartLinePos);
6057
Throw(SR.Xml_UnparsedEntityRef, name,
_ps
.LineNo, entityStartLinePos);
6062
Throw(SR.Xml_ExternalEntityInStandAloneDocument, entity.Name,
_ps
.LineNo, entityStartLinePos);
6069
Throw(SR.Xml_ExternalEntityInAttValue, name,
_ps
.LineNo, entityStartLinePos);
6083
_curNode.entityId =
_ps
.entityId;
6091
_curNode.entityId =
_ps
.entityId;
6104
_curNode.entityId =
_ps
.entityId;
6126
if (
_ps
.entityResolvedManually)
6132
if (
_ps
.entityId != _nodes[_index].entityId)
6138
_lastEntity =
_ps
.entity; // save last entity for the EndEntity node
6147
if (
_ps
.entityId != _nodes[_index].entityId)
6155
_reportedEncoding =
_ps
.encoding;
6156
_reportedBaseUri =
_ps
.baseUriStr;
6165
_reportedEncoding =
_ps
.encoding;
6166
_reportedBaseUri =
_ps
.baseUriStr;
6171
_curNode.lineInfo.Set(
_ps
.lineNo,
_ps
.LinePos - 1);
6200
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
6207
Debug.Assert(
_ps
.chars != null);
6208
string target = _nameTable.Add(
_ps
.chars,
_ps
.charPos, nameEndPos -
_ps
.charPos);
6214
_ps
.charPos = nameEndPos;
6229
char ch =
_ps
.chars[
_ps
.charPos];
6230
Debug.Assert(
_ps
.charPos <
_ps
.charsUsed);
6233
if (
_ps
.charsUsed -
_ps
.charPos < 2)
6237
if (ch != '?' ||
_ps
.chars[
_ps
.charPos + 1] != '>')
6239
Throw(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos));
6255
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
6260
piInDtdStringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
6283
sb.Append(
_ps
.chars, startPos, endPos - startPos);
6285
sb.Append(
_ps
.chars, startPos, endPos - startPos);
6300
if (
_ps
.charsUsed -
_ps
.charPos < 2)
6304
Throw(
_ps
.charsUsed, SR.Xml_UnexpectedEOF, "PI");
6308
Debug.Assert(
_ps
.chars != null);
6309
int pos =
_ps
.charPos;
6310
char[] chars =
_ps
.chars;
6330
Debug.Assert(!
_ps
.eolNormalized);
6338
outStartPos =
_ps
.charPos;
6339
_ps
.charPos = pos + 2;
6342
else if (pos + 1 ==
_ps
.charsUsed)
6359
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
6362
if (pos -
_ps
.charPos > 0)
6378
_ps
.charPos++;
6383
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
6385
if (!
_ps
.eolNormalized)
6405
if (pos ==
_ps
.charsUsed)
6415
if (pos + 1 ==
_ps
.charsUsed)
6426
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
6442
outStartPos =
_ps
.charPos;
6443
_ps
.charPos = pos;
6476
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
6480
Debug.Assert(
_ps
.chars != null);
6481
_curNode.SetValueNode(type,
_ps
.chars, startPos, endPos - startPos);
6487
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
6490
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
6504
if (
_ps
.charsUsed -
_ps
.charPos < 3)
6513
Debug.Assert(
_ps
.chars != null);
6514
int pos =
_ps
.charPos;
6515
char[] chars =
_ps
.chars;
6537
Debug.Assert(!
_ps
.eolNormalized);
6545
outStartPos =
_ps
.charPos;
6546
_ps
.charPos = pos + 3;
6549
else if (pos + 2 ==
_ps
.charsUsed)
6558
else if (pos + 1 ==
_ps
.charsUsed)
6578
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
6580
if (pos -
_ps
.charPos > 0)
6596
_ps
.charPos++;
6601
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
6603
if (!
_ps
.eolNormalized)
6623
if (pos ==
_ps
.charsUsed)
6631
if (pos + 1 ==
_ps
.charsUsed)
6642
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
6657
outStartPos =
_ps
.charPos;
6659
_ps
.charPos = pos;
6673
while (
_ps
.charsUsed -
_ps
.charPos < 8)
6681
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("DOCTYPE"))
6686
Debug.Assert(
_ps
.chars != null);
6687
if (!XmlCharType.IsWhiteSpace(
_ps
.chars[
_ps
.charPos + 7]))
6689
ThrowExpectingWhitespace(
_ps
.charPos + 7);
6694
Throw(
_ps
.charPos - 2, SR.Xml_MultipleDTDsProvided); // position just before <!DOCTYPE
6699
Throw(
_ps
.charPos - 2, SR.Xml_DtdAfterRootElement);
6702
_ps
.charPos += 8;
6708
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
6745
_ps
.charPos = pos;
6751
Debug.Assert(
_ps
.chars != null);
6752
if (
_ps
.chars[
_ps
.charPos] == 'P')
6755
while (
_ps
.charsUsed -
_ps
.charPos < 6)
6763
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("PUBLIC"))
6767
_ps
.charPos += 6;
6772
ThrowExpectingWhitespace(
_ps
.charPos);
6781
ThrowExpectingWhitespace(
_ps
.charPos);
6789
else if (
_ps
.chars[
_ps
.charPos] == 'S')
6792
while (
_ps
.charsUsed -
_ps
.charPos < 6)
6800
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("SYSTEM"))
6804
_ps
.charPos += 6;
6809
ThrowExpectingWhitespace(
_ps
.charPos);
6817
else if (
_ps
.chars[
_ps
.charPos] != '[' &&
_ps
.chars[
_ps
.charPos] != '>')
6823
if (
_ps
.chars[
_ps
.charPos] == '[')
6825
_ps
.charPos++;
6830
if (
_ps
.chars[
_ps
.charPos] != '>')
6835
else if (
_ps
.chars[
_ps
.charPos] == '>')
6843
_ps
.charPos++;
6848
Debug.Assert(
_ps
.chars != null);
6850
char quoteChar =
_ps
.chars[
_ps
.charPos];
6856
_ps
.charPos++;
6867
Debug.Assert(
_ps
.chars != null);
6868
char[] chars =
_ps
.chars;
6869
int pos =
_ps
.charPos;
6883
_ps
.charPos = pos + 1;
6888
_ps
.charPos = pos;
6901
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
6927
if (pos + 3 >=
_ps
.charsUsed && !
_ps
.isEof)
6942
else if (pos + 1 >=
_ps
.charsUsed && !
_ps
.isEof)
6952
if (pos + 2 >=
_ps
.charsUsed && !
_ps
.isEof)
6970
if (pos + 1 >=
_ps
.charsUsed && !
_ps
.isEof)
7011
if (pos ==
_ps
.charsUsed)
7021
if (pos + 1 ==
_ps
.charsUsed)
7032
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
7041
if (
_ps
.charsUsed -
_ps
.charPos > 0)
7043
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
7048
Debug.Assert(
_ps
.isEof);
7055
chars =
_ps
.chars;
7056
pos =
_ps
.charPos;
7062
int pos =
_ps
.charPos;
7064
Debug.Assert(
_ps
.chars != null);
7065
char[] chars =
_ps
.chars;
7080
int tmp1 = pos -
_ps
.charPos;
7081
if (sb != null && !
_ps
.eolNormalized)
7085
sb.Append(chars,
_ps
.charPos, tmp1);
7088
_ps
.charPos = pos + 1;
7092
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
7094
if (!
_ps
.eolNormalized)
7111
if (pos ==
_ps
.charsUsed)
7117
int tmp2 = pos -
_ps
.charPos;
7120
sb?.Append(
_ps
.chars,
_ps
.charPos, tmp2);
7121
_ps
.charPos = pos;
7130
int tmp3 = pos -
_ps
.charPos;
7133
sb?.Append(
_ps
.chars,
_ps
.charPos, tmp3);
7134
_ps
.charPos = pos;
7140
if (
_ps
.charsUsed -
_ps
.charPos == 0)
7144
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
7149
Debug.Assert(
_ps
.isEof);
7151
pos =
_ps
.charPos;
7152
chars =
_ps
.chars;
7158
Debug.Assert(
_ps
.chars != null);
7159
Debug.Assert(
_ps
.chars[startPos] == '&');
7160
if (
_ps
.chars[startPos + 1] == '#')
7183
switch (newPos = ParseNumericCharRefInline(
_ps
.charPos, expand, internalSubsetBuilder, out charCount, out entityType))
7192
Debug.Assert(
_ps
.chars != null);
7193
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
7198
_ps
.charPos = newPos - charCount;
7213
Debug.Assert(
_ps
.chars != null);
7214
Debug.Assert(
_ps
.chars[startPos] == '&' &&
_ps
.chars[startPos + 1] == '#');
7222
chars =
_ps
.chars;
7244
else if (pos <
_ps
.charsUsed)
7264
_ps
.charPos = pos;
7273
if (pos ==
_ps
.charsUsed)
7291
Throw((
_ps
.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(ch, '\0'));
7296
internalSubsetBuilder?.Append(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos + 1);
7317
Throw((
_ps
.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(high, low));
7324
internalSubsetBuilder?.Append(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos + 1);
7344
switch (newPos = ParseNamedCharRefInline(
_ps
.charPos, expand, internalSubsetBuilder))
7355
Debug.Assert(
_ps
.chars != null);
7356
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
7361
_ps
.charPos = newPos - 1;
7376
Debug.Assert(startPos <
_ps
.charsUsed);
7377
Debug.Assert(
_ps
.chars != null);
7378
Debug.Assert(
_ps
.chars[startPos] == '&');
7379
Debug.Assert(
_ps
.chars[startPos + 1] != '#');
7382
char[] chars =
_ps
.chars;
7393
if (
_ps
.charsUsed - pos >= 3)
7410
if (
_ps
.charsUsed - pos >= 4)
7425
else if (pos <
_ps
.charsUsed)
7432
if (
_ps
.charsUsed - pos >= 5)
7449
if (
_ps
.charsUsed - pos >= 3)
7465
if (
_ps
.charsUsed - pos >= 3)
7490
internalSubsetBuilder?.Append(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
7491
_ps
.chars[pos - 1] = ch;
7509
int pos =
_ps
.charPos + startOffset;
7512
Debug.Assert(
_ps
.chars != null);
7513
char[] chars =
_ps
.chars;
7522
if (pos + 1 >=
_ps
.charsUsed)
7532
Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
7559
colonOffset = pos -
_ps
.charPos;
7565
colonOffset = pos -
_ps
.charPos;
7571
else if (pos ==
_ps
.charsUsed)
7575
Debug.Assert(
_ps
.chars != null);
7576
chars =
_ps
.chars;
7583
colonPos = (colonOffset == -1) ? -1 :
_ps
.charPos + colonOffset;
7589
int offset = pos -
_ps
.charPos;
7591
pos =
_ps
.charPos + offset;
7608
Debug.Assert(
_ps
.chars != null);
7611
if (
_ps
.chars[endPos] != ';')
7616
string entityName = _nameTable.Add(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
7617
_ps
.charPos = endPos + 1;
7661
Debug.Assert(
_ps
.chars != null);
7666
string localName = _nameTable.Add(
_ps
.chars,
_ps
.charPos, endNamePos -
_ps
.charPos);
7672
int startPos =
_ps
.charPos;
7674
if (prefixLen == _lastPrefix.Length &&
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith(_lastPrefix))
7676
return AddAttribute(_nameTable.Add(
_ps
.chars, colonPos + 1, endNamePos - colonPos - 1),
7682
string prefix = _nameTable.Add(
_ps
.chars, startPos, prefixLen);
7684
return AddAttribute(_nameTable.Add(
_ps
.chars, colonPos + 1, endNamePos - colonPos - 1),
7743
_ps
.lineNo++;
7744
_ps
.lineStartPos = pos - 1;
7749
Debug.Assert(
_ps
.isEof);
7752
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
8002
Debug.Assert(
_ps
.appendMode);
8003
int initialPos =
_ps
.charPos;
8011
_ps
.charPos = initialPos;
8018
Encoding? enc =
_ps
.encoding;
8035
Encoding? enc =
_ps
.encoding;
8043
_ps
.lineNo = entity.LineNumber;
8044
_ps
.lineStartPos = -entity.LinePosition - 1;
8046
_ps
.eolNormalized = true;
8053
_ps
.stream?.Dispose();
8057
_curNode.entityId =
_ps
.entityId;
8073
_ps
.entity = entity;
8074
_ps
.entityId = _nextEntityId++;
8088
if (
_ps
.entity != null)
8090
_currentEntities!.Remove(
_ps
.entity);
8108
_parsingStatesStack[_parsingStatesStackTop] =
_ps
;
8110
_ps
.Clear();
8117
_ps
.Close(true);
8129
_incReadLeftStartPos =
_ps
.charPos;
8130
_incReadLeftEndPos =
_ps
.charPos;
8131
_incReadLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
8174
Debug.Assert(
_ps
.chars != null);
8184
count = _incReadDecoder.Decode(
_ps
.chars, _incReadLeftStartPos, charsLeft);
8223
Debug.Assert(
_ps
.chars.AsSpan(
_ps
.charPos - 2).StartsWith("?>"));
8224
_ps
.charPos -= 2;
8231
Debug.Assert(
_ps
.chars.AsSpan(
_ps
.charPos - 3).StartsWith("-->"));
8232
_ps
.charPos -= 3;
8239
Debug.Assert(
_ps
.chars.AsSpan(
_ps
.charPos - 3).StartsWith("]]>"));
8240
_ps
.charPos -= 3;
8268
char[] chars =
_ps
.chars;
8269
startPos =
_ps
.charPos;
8274
_incReadLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
8315
else if (pos + 1 <
_ps
.charsUsed)
8332
if (
_ps
.charsUsed - pos < 2)
8345
if (
_ps
.charsUsed - pos < 4)
8355
if (
_ps
.charsUsed - pos < 9)
8373
Debug.Assert(
_ps
.charPos - pos == 0);
8374
Debug.Assert(
_ps
.charPos - startPos == 0);
8379
if ((endPos -
_ps
.charPos - 2) == checkName.Length && chars.AsSpan(
_ps
.charPos + 2).StartsWith(checkName) &&
8380
(
_ps
.chars[endPos] == '>' || XmlCharType.IsWhiteSpace(
_ps
.chars[endPos])))
8388
_ps
.charPos = endPos;
8389
if (XmlCharType.IsWhiteSpace(
_ps
.chars[endPos]))
8393
if (
_ps
.chars[
_ps
.charPos] != '>')
8397
_ps
.charPos++;
8405
startPos =
_ps
.charPos;
8406
chars =
_ps
.chars;
8413
Debug.Assert(
_ps
.charPos - pos == 0);
8414
Debug.Assert(
_ps
.charPos - startPos == 0);
8418
if (endPos -
_ps
.charPos - 1 == _curNode.localName.Length &&
_ps
.chars.AsSpan(
_ps
.charPos + 1).StartsWith(_curNode.localName) &&
8419
(
_ps
.chars[endPos] == '>' ||
_ps
.chars[endPos] == '/' || XmlCharType.IsWhiteSpace(
_ps
.chars[endPos])))
8427
startPos =
_ps
.charPos;
8428
chars =
_ps
.chars;
8437
if (
_ps
.charsUsed - pos < 2)
8476
if (pos ==
_ps
.charsUsed)
8493
_ps
.charPos = pos;
8503
count = _incReadDecoder.Decode(
_ps
.chars, startPos, charsParsed);
8541
ParseAttributeValueSlow(
_ps
.charPos, ' ', _curNode); // The quote char is intentionally empty (space) because we need to parse ' and " into the attribute value
8564
Debug.Assert(
_ps
.chars != null);
8566
char[] chars =
_ps
.chars;
8567
int pos =
_ps
.charPos;
8570
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
8590
Debug.Assert(
_ps
.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!");
8613
if (pos -
_ps
.charPos > 0)
8615
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
8618
_ps
.charPos = pos;
8626
chars =
_ps
.chars;
8627
if (_normalize && XmlCharType.IsWhiteSpace(chars[
_ps
.charPos]) && pos -
_ps
.charPos == 1)
8629
chars[
_ps
.charPos] = (char)0x20; // CDATA normalization of character references in entities
8636
_ps
.charPos++;
8648
chars =
_ps
.chars;
8652
if (pos ==
_ps
.charsUsed)
8662
if (pos + 1 ==
_ps
.charsUsed)
8675
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
8681
if (pos -
_ps
.charPos > 0)
8683
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
8684
_ps
.charPos = pos;
8708
pos =
_ps
.charPos;
8709
chars =
_ps
.chars;
8713
if (pos -
_ps
.charPos > 0)
8715
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
8716
_ps
.charPos = pos;
8748
_ps
.charPos = pos;
8772
_ps
.charPos = pos;
8778
if (
_ps
.charPos ==
_ps
.charsUsed)
8783
Debug.Assert(
_ps
.chars != null);
8785
if (XmlCharType.IsNCNameSingleChar(
_ps
.chars[
_ps
.charPos]))
8787
int pos =
_ps
.charPos + 1;
8788
while (XmlCharType.IsNCNameSingleChar(
_ps
.chars[pos]))
8792
return new string(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
8796
Debug.Assert(
_ps
.charPos <
_ps
.charsUsed);
8797
return new string(
_ps
.chars,
_ps
.charPos, 1);
8861
Debug.Assert(
_ps
.chars != null);
8863
if (_v1Compat && pos ==
_ps
.charsUsed - 1 &&
_ps
.chars[pos] == (char)0 && ReadData() == 0 &&
_ps
.isStreamEof)
8865
_ps
.charsUsed--;
9371
_curNode.AdjustLineInfo(_readValueOffset,
_ps
.eolNormalized, ref _incReadLineInfo);
9385
Debug.Assert(
_ps
.chars != null);
9396
_incReadLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
9401
charsRead = _incReadDecoder.Decode(
_ps
.chars, startPos, endPos - startPos);
9416
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
9418
AdjustLineInfo(
_ps
.chars, startPos - charsRead, startPos,
_ps
.eolNormalized, ref _incReadLineInfo);
System\Xml\Core\XmlTextReaderImplAsync.cs (656)
97
_reportedEncoding =
_ps
.encoding;
128
_reportedEncoding =
_ps
.encoding;
143
_reportedEncoding =
_ps
.encoding;
178
Debug.Assert(!
_ps
.appendMode);
219
_reportedEncoding =
_ps
.encoding;
220
_reportedBaseUri =
_ps
.baseUriStr;
226
_curNode.SetLineInfo(
_ps
.lineNo,
_ps
.LinePos);
227
_reportedEncoding =
_ps
.encoding;
228
_reportedBaseUri =
_ps
.baseUriStr;
295
_reportedEncoding =
_ps
.encoding;
300
_reportedEncoding =
_ps
.encoding;
695
BlockCopyChars(
_ps
.chars, startPos, buffer, (index + readCount), copyCount);
718
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
786
if (e.ResString == SR.Xml_UnexpectedEOF &&
_ps
.entity != null)
788
SendValidationEvent(XmlSeverityType.Error, SR.Sch_ParEntityRefNesting, null,
_ps
.LineNo,
_ps
.LinePos);
818
entityId =
_ps
.entityId;
837
if (
_ps
.baseUri == null && !string.IsNullOrEmpty(
_ps
.baseUriStr))
839
_ps
.baseUri = _xmlResolver!.ResolveUri(null,
_ps
.baseUriStr);
841
await PushExternalEntityOrSubsetAsync(publicId, systemId,
_ps
.baseUri, null).ConfigureAwait(false);
843
_ps
.entity = null;
844
_ps
.entityId = 0;
846
Debug.Assert(
_ps
.appendMode);
847
int initialPos =
_ps
.charPos;
854
_ps
.charPos = initialPos;
868
Debug.Assert(
_ps
.charPos == 0 &&
_ps
.charsUsed == 0 &&
_ps
.textReader == null);
872
_ps
.stream = stream;
873
_ps
.baseUri = baseUri;
874
_ps
.baseUriStr = baseUriStr;
880
_ps
.bytes = bytes;
881
_ps
.bytesUsed = byteCount;
882
bufferSize =
_ps
.bytes.Length;
897
if (
_ps
.bytes == null ||
_ps
.bytes.Length < bufferSize)
899
_ps
.bytes = new byte[bufferSize];
904
if (
_ps
.chars == null ||
_ps
.chars.Length < bufferSize + 1)
906
_ps
.chars = new char[bufferSize + 1];
910
_ps
.bytePos = 0;
911
if (
_ps
.bytesUsed < 4 &&
_ps
.bytes.Length -
_ps
.bytesUsed > 0)
913
int bytesToRead = Math.Min(4,
_ps
.bytes.Length -
_ps
.bytesUsed);
914
int read = await stream.ReadAtLeastAsync(
_ps
.bytes.AsMemory(
_ps
.bytesUsed), bytesToRead, throwOnEndOfStream: false).ConfigureAwait(false);
917
_ps
.isStreamEof = true;
919
_ps
.bytesUsed += read;
929
_documentStartBytePos =
_ps
.bytePos;
931
_ps
.eolNormalized = !_normalize;
934
_ps
.appendMode = true;
944
Debug.Assert(
_ps
.charPos == 0 &&
_ps
.charsUsed == 0 &&
_ps
.stream == null);
947
_ps
.textReader = input;
948
_ps
.baseUriStr = baseUriStr;
949
_ps
.baseUri = baseUri;
951
if (
_ps
.chars == null)
964
_ps
.chars = new char[bufferSize + 1];
967
_ps
.encoding = Encoding.Unicode;
968
_ps
.eolNormalized = !_normalize;
971
_ps
.appendMode = true;
1001
if ((newEncoding.WebName !=
_ps
.encoding!.WebName ||
_ps
.decoder is SafeAsciiDecoder) && !_afterResetState)
1003
Debug.Assert(
_ps
.stream != null);
1005
_ps
.appendMode = false;
1026
if (
_ps
.isEof)
1032
if (
_ps
.appendMode)
1035
if (
_ps
.charsUsed ==
_ps
.chars.Length - 1)
1043
char[] newChars = new char[
_ps
.chars.Length * 2];
1044
BlockCopyChars(
_ps
.chars, 0, newChars, 0,
_ps
.chars.Length);
1045
_ps
.chars = newChars;
1048
if (
_ps
.stream != null)
1051
if (
_ps
.bytesUsed -
_ps
.bytePos < MaxByteSequenceLen)
1053
if (
_ps
.bytes!.Length -
_ps
.bytesUsed < MaxByteSequenceLen)
1055
byte[] newBytes = new byte[
_ps
.bytes.Length * 2];
1056
BlockCopy(
_ps
.bytes, 0, newBytes, 0,
_ps
.bytesUsed);
1057
_ps
.bytes = newBytes;
1062
charsRead =
_ps
.chars.Length -
_ps
.charsUsed - 1;
1070
int charsLen =
_ps
.chars.Length;
1071
if (charsLen -
_ps
.charsUsed <= charsLen / 2)
1080
int copyCharsCount =
_ps
.charsUsed -
_ps
.charPos;
1083
_ps
.lineStartPos -=
_ps
.charPos;
1086
BlockCopyChars(
_ps
.chars,
_ps
.charPos,
_ps
.chars, 0, copyCharsCount);
1088
_ps
.charPos = 0;
1089
_ps
.charsUsed = copyCharsCount;
1093
char[] newChars = new char[
_ps
.chars.Length * 2];
1094
BlockCopyChars(
_ps
.chars, 0, newChars, 0,
_ps
.chars.Length);
1095
_ps
.chars = newChars;
1099
if (
_ps
.stream != null)
1102
int bytesLeft =
_ps
.bytesUsed -
_ps
.bytePos;
1107
_ps
.bytesUsed = 0;
1111
BlockCopy(
_ps
.bytes!,
_ps
.bytePos,
_ps
.bytes!, 0, bytesLeft);
1112
_ps
.bytesUsed = bytesLeft;
1114
_ps
.bytePos = 0;
1117
charsRead =
_ps
.chars.Length -
_ps
.charsUsed - 1;
1120
if (
_ps
.stream != null)
1122
if (!
_ps
.isStreamEof)
1125
if (
_ps
.bytePos ==
_ps
.bytesUsed &&
_ps
.bytes!.Length -
_ps
.bytesUsed > 0)
1127
int read = await
_ps
.stream.ReadAsync(
_ps
.bytes.AsMemory(
_ps
.bytesUsed)).ConfigureAwait(false);
1130
_ps
.isStreamEof = true;
1132
_ps
.bytesUsed += read;
1136
int originalBytePos =
_ps
.bytePos;
1140
if (charsRead == 0 &&
_ps
.bytePos != originalBytePos)
1146
else if (
_ps
.textReader != null)
1149
charsRead = await
_ps
.textReader.ReadAsync(
_ps
.chars.AsMemory(
_ps
.charsUsed,
_ps
.chars.Length -
_ps
.charsUsed - 1)).ConfigureAwait(false);
1150
_ps
.charsUsed += charsRead;
1161
Debug.Assert(
_ps
.charsUsed <
_ps
.chars.Length);
1162
_ps
.isEof = true;
1164
_ps
.chars[
_ps
.charsUsed] = (char)0;
1171
while (
_ps
.charsUsed -
_ps
.charPos < 6)
1179
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith(XmlDeclarationBeginning) ||
1180
XmlCharType.IsNameSingleChar(
_ps
.chars[
_ps
.charPos + 5]))
1187
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos + 2);
1190
_ps
.charPos += 5;
1206
if (
_ps
.chars[
_ps
.charPos] == '?')
1210
if (
_ps
.chars[
_ps
.charPos + 1] == '>')
1217
_ps
.charPos += 2;
1238
string encodingName =
_ps
.encoding!.WebName;
1240
encodingName != "utf-16BE" && !(
_ps
.encoding is Ucs4Encoding))
1242
Throw(SR.Xml_EncodingSwitchAfterResetState, (
_ps
.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
1245
if (
_ps
.decoder is SafeAsciiDecoder)
1254
_ps
.appendMode = false;
1257
else if (
_ps
.charPos + 1 ==
_ps
.charsUsed)
1276
switch (
_ps
.chars.AsSpan(
_ps
.charPos, nameEndPos -
_ps
.charPos))
1313
attr!.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
1315
sb.Append(
_ps
.chars,
_ps
.charPos, nameEndPos -
_ps
.charPos);
1316
_ps
.charPos = nameEndPos;
1319
if (
_ps
.chars[
_ps
.charPos] != '=')
1322
if (
_ps
.chars[
_ps
.charPos] != '=')
1328
_ps
.charPos++;
1330
char quoteChar =
_ps
.chars[
_ps
.charPos];
1334
quoteChar =
_ps
.chars[
_ps
.charPos];
1341
_ps
.charPos++;
1345
attr.SetLineInfo2(
_ps
.LineNo,
_ps
.LinePos);
1349
int pos =
_ps
.charPos;
1352
chars =
_ps
.chars;
1359
if (
_ps
.chars[pos] == quoteChar)
1366
if (
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("1.0"))
1370
attr!.SetValue(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
1376
string badVersion = new string(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
1381
string encName = new string(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
1390
switch (
_ps
.chars.AsSpan(
_ps
.charPos, pos -
_ps
.charPos))
1400
Throw(SR.Xml_InvalidXmlDecl,
_ps
.LineNo,
_ps
.LinePos - 1);
1405
attr!.SetValue(
_ps
.chars,
_ps
.charPos, pos -
_ps
.charPos);
1413
sb.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
1415
_ps
.charPos = pos + 1;
1418
else if (pos ==
_ps
.charsUsed)
1435
if (
_ps
.isEof || await ReadDataAsync().ConfigureAwait(false) == 0)
1451
string encodingName =
_ps
.encoding!.WebName;
1453
encodingName != "utf-16BE" && !(
_ps
.encoding is Ucs4Encoding))
1455
Throw(SR.Xml_EncodingSwitchAfterResetState, (
_ps
.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16");
1458
if (
_ps
.decoder is SafeAsciiDecoder)
1462
_ps
.appendMode = false;
1474
int pos =
_ps
.charPos;
1475
char[] chars =
_ps
.chars;
1481
if (
_ps
.charsUsed - pos < 4) // minimum "<a/>"
1488
_ps
.charPos = pos + 1;
1492
if (
_ps
.charsUsed - pos < 2) // minimum characters expected "--"
1499
_ps
.charPos = pos + 2;
1513
if (
_ps
.charsUsed - pos < 6)
1519
_ps
.charPos = pos + 6;
1529
Throw(
_ps
.charPos, SR.Xml_InvalidRootData);
1538
_ps
.charPos = pos;
1570
_ps
.charPos = pos;
1580
else if (pos ==
_ps
.charsUsed || (_v1Compat && chars[pos] == 0x0))
1597
Debug.Assert(pos ==
_ps
.charsUsed && !
_ps
.isEof);
1612
int pos =
_ps
.charPos;
1733
int pos =
_ps
.charPos;
1734
char[] chars =
_ps
.chars;
1744
_ps
.charPos = pos + 2;
1748
if (
_ps
.charsUsed - pos < 2)
1755
_ps
.charPos = pos + 2;
1767
if (
_ps
.charsUsed - pos < 6)
1773
_ps
.charPos = pos + 6;
1795
_ps
.charPos = pos + 2;
1799
if (pos + 1 ==
_ps
.charsUsed)
1806
_ps
.charPos = pos + 1;
1815
if (pos ==
_ps
.charsUsed)
1833
if (
_ps
.charsUsed -
_ps
.charPos != 0)
1858
int pos =
_ps
.charPos;
1859
char[] chars =
_ps
.chars;
1862
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
1913
else if (pos + 1 <
_ps
.charsUsed)
1951
char[] chars =
_ps
.chars;
1960
_nameTable.Add(chars,
_ps
.charPos, pos -
_ps
.charPos));
1964
int startPos =
_ps
.charPos;
1977
_nameTable.Add(chars,
_ps
.charPos, prefixLen),
1989
_ps
.charPos = pos;
2003
int pos =
_ps
.charPos;
2004
char[] chars =
_ps
.chars;
2009
_ps
.charPos = pos + 1;
2015
if (pos + 1 ==
_ps
.charsUsed)
2017
_ps
.charPos = pos;
2025
_ps
.charPos = pos + 2;
2035
Throw(pos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
2067
if (
_ps
.charsUsed -
_ps
.charPos < prefLen + locLen + 1)
2089
while (
_ps
.charsUsed -
_ps
.charPos < prefLen + locLen + 1)
2105
char[] chars =
_ps
.chars;
2108
if (!chars.AsSpan(
_ps
.charPos).StartsWith(startTagNode.localName))
2116
int colonPos =
_ps
.charPos + prefLen;
2117
if (!chars.AsSpan(
_ps
.charPos).StartsWith(startTagNode.prefix) ||
2125
LineInfo endTagLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos);
2187
pos =
_ps
.charPos + nameLen;
2188
chars =
_ps
.chars;
2190
if (pos ==
_ps
.charsUsed)
2225
else if (pos ==
_ps
.charsUsed && !
_ps
.isEof)
2239
else if (pos ==
_ps
.charsUsed)
2260
_ps
.charPos = pos + 1;
2294
args[3] = new string(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
2307
int pos =
_ps
.charPos;
2308
char[] chars =
_ps
.chars;
2334
else if (pos + 1 !=
_ps
.charsUsed)
2341
_ps
.charPos = pos;
2362
_ps
.charPos = pos + 1;
2370
if (pos + 1 ==
_ps
.charsUsed)
2376
_ps
.charPos = pos + 2;
2387
else if (pos ==
_ps
.charsUsed)
2393
Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
2397
if (pos ==
_ps
.charPos)
2401
_ps
.charPos = pos;
2404
int attrNameLinePos =
_ps
.LinePos;
2407
int attrNameLineNo =
_ps
.LineNo;
2466
chars =
_ps
.chars;
2469
else if (pos + 1 >=
_ps
.charsUsed)
2476
chars =
_ps
.chars;
2480
attr.SetLineInfo(
_ps
.LineNo, attrNameLinePos);
2483
Debug.Assert(attrNameLineNo ==
_ps
.LineNo);
2489
_ps
.charPos = pos;
2491
pos =
_ps
.charPos;
2502
_ps
.charPos = pos;
2504
pos =
_ps
.charPos;
2512
_ps
.charPos = pos;
2515
attr.SetLineInfo2(
_ps
.LineNo,
_ps
.LinePos);
2529
string val = new string(chars,
_ps
.charPos, pos -
_ps
.charPos);
2533
attr.SetValue(chars,
_ps
.charPos, pos -
_ps
.charPos);
2535
_ps
.charPos = pos;
2540
pos =
_ps
.charPos;
2541
chars =
_ps
.chars;
2569
_ps
.lineNo -= lineNoDelta;
2572
pos =
_ps
.charPos;
2573
chars =
_ps
.chars;
2606
char[] chars =
_ps
.chars;
2607
int attributeBaseEntityId =
_ps
.entityId;
2610
LineInfo valueChunkLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos);
2623
if (pos -
_ps
.charPos > 0)
2625
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
2626
_ps
.charPos = pos;
2629
if (chars[pos] == quoteChar && attributeBaseEntityId ==
_ps
.entityId)
2644
_ps
.charPos++;
2653
_stringBuilder.Append(
_ps
.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA
2654
_ps
.charPos = pos;
2657
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
2663
_ps
.charPos = pos;
2678
_ps
.charPos++;
2692
if (pos -
_ps
.charPos > 0)
2694
_stringBuilder.Append(chars,
_ps
.charPos, pos -
_ps
.charPos);
2696
_ps
.charPos = pos;
2699
int enclosingEntityId =
_ps
.entityId;
2700
LineInfo entityLineInfo = new LineInfo(
_ps
.lineNo,
_ps
.LinePos + 1);
2713
if (_parsingMode == ParsingMode.Full &&
_ps
.entityId == attributeBaseEntityId)
2727
_ps
.charPos++;
2744
valueChunkLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
2750
_ps
.charPos++;
2753
pos =
_ps
.charPos;
2774
entityChunk.SetNamedNode(XmlNodeType.EntityReference,
_ps
.entity!.Name);
2782
pos =
_ps
.charPos;
2785
pos =
_ps
.charPos;
2788
chars =
_ps
.chars;
2792
if (pos ==
_ps
.charsUsed)
2802
if (pos + 1 ==
_ps
.charsUsed)
2813
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
2823
if (
_ps
.charsUsed -
_ps
.charPos > 0)
2825
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
2830
Debug.Assert(
_ps
.isEof);
2838
if (attributeBaseEntityId !=
_ps
.entityId)
2853
if (attributeBaseEntityId ==
_ps
.entityId)
2856
valueChunkLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
2861
pos =
_ps
.charPos;
2862
chars =
_ps
.chars;
2880
_ps
.charPos = pos + 1;
2898
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
2930
_curNode.SetValueNode(nodeType,
_ps
.chars, startPos, endPos - startPos);
2966
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
2989
_curNode.SetValueNode(nodeType,
_ps
.chars, startPos, endPos - startPos);
3004
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3015
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3040
_curNode.SetValueNode(XmlNodeType.Text,
_ps
.chars, startPos, endPos - startPos);
3049
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3062
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3169
Task<(int, int, int, bool)> task = ParseTextAsync(outOrChars,
_ps
.chars,
_ps
.charPos, 0, -1, outOrChars);
3268
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
3270
if (pos -
_ps
.charPos > 0)
3286
_ps
.charPos++;
3291
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
3293
if (!
_ps
.eolNormalized)
3318
if (
_ps
.charsUsed - pos < 3 && !
_ps
.isEof)
3333
if (pos ==
_ps
.charsUsed)
3373
if (pos >
_ps
.charPos)
3403
if (!XmlCharType.IsWhiteSpace(
_ps
.chars[pos - 1]))
3409
pos =
_ps
.charPos;
3412
chars =
_ps
.chars;
3425
if (pos + 1 ==
_ps
.charsUsed)
3441
int offset = pos -
_ps
.charPos;
3444
chars =
_ps
.chars;
3445
pos =
_ps
.charPos + offset;
3452
ThrowInvalidChar(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos + offset);
3460
if (pos >
_ps
.charPos)
3469
if (
_ps
.charsUsed -
_ps
.charPos > 0)
3471
if (
_ps
.chars[
_ps
.charPos] != (char)0xD &&
_ps
.chars[
_ps
.charPos] != ']')
3475
Debug.Assert(
_ps
.isEof);
3499
pos =
_ps
.charPos;
3500
chars =
_ps
.chars;
3517
int startPos =
_ps
.charPos;
3519
_ps
.charPos = pos;
3546
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3553
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3684
if (
_ps
.chars[
_ps
.charPos] == '<' ||
_ps
.charsUsed -
_ps
.charPos == 0 || await ZeroEndingStreamAsync(
_ps
.charPos).ConfigureAwait(false))
3691
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
3693
if (
_ps
.chars[
_ps
.charPos] == '<' ||
_ps
.charsUsed -
_ps
.charPos == 0 || await ZeroEndingStreamAsync(
_ps
.charPos).ConfigureAwait(false))
3705
if (XmlCharType.IsCharData(
_ps
.chars[
_ps
.charPos]))
3711
ThrowInvalidChar(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos);
3718
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
3719
_ps
.charPos++;
3721
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
3729
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
3731
if (
_ps
.charPos + 1 ==
_ps
.charsUsed)
3740
if (
_ps
.chars[
_ps
.charPos + 1] == '#')
3775
_ps
.charPos++;
3776
int savedLinePos =
_ps
.LinePos;
3783
Throw(SR.Xml_ErrorParsingEntityName,
_ps
.LineNo, savedLinePos);
3789
if (
_ps
.chars[endPos] != ';')
3794
int entityLinePos =
_ps
.LinePos;
3795
string entityName = _nameTable.Add(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
3796
_ps
.charPos = endPos + 1;
3800
_reportedBaseUri =
_ps
.baseUriStr;
3801
_reportedEncoding =
_ps
.encoding;
3829
Throw(SR.Xml_UndeclaredEntity, name,
_ps
.LineNo, entityStartLinePos);
3842
Throw(SR.Xml_UnparsedEntityRef, name,
_ps
.LineNo, entityStartLinePos);
3847
Throw(SR.Xml_ExternalEntityInStandAloneDocument, entity.Name,
_ps
.LineNo, entityStartLinePos);
3854
Throw(SR.Xml_ExternalEntityInAttValue, name,
_ps
.LineNo, entityStartLinePos);
3868
_curNode.entityId =
_ps
.entityId;
3876
_curNode.entityId =
_ps
.entityId;
3889
_curNode.entityId =
_ps
.entityId;
3905
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
3912
string target = _nameTable.Add(
_ps
.chars,
_ps
.charPos, nameEndPos -
_ps
.charPos);
3918
_ps
.charPos = nameEndPos;
3933
char ch =
_ps
.chars[
_ps
.charPos];
3934
Debug.Assert(
_ps
.charPos <
_ps
.charsUsed);
3937
if (
_ps
.charsUsed -
_ps
.charPos < 2)
3941
if (ch != '?' ||
_ps
.chars[
_ps
.charPos + 1] != '>')
3943
Throw(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(
_ps
.chars,
_ps
.charsUsed,
_ps
.charPos));
3964
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
3969
piInDtdStringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
3999
sb.Append(
_ps
.chars, startPos, endPos - startPos);
4006
sb.Append(
_ps
.chars, startPos, endPos - startPos);
4023
if (
_ps
.charsUsed -
_ps
.charPos < 2)
4027
Throw(
_ps
.charsUsed, SR.Xml_UnexpectedEOF, "PI");
4031
int pos =
_ps
.charPos;
4032
char[] chars =
_ps
.chars;
4053
Debug.Assert(!
_ps
.eolNormalized);
4061
outStartPos =
_ps
.charPos;
4062
_ps
.charPos = pos + 2;
4066
else if (pos + 1 ==
_ps
.charsUsed)
4083
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
4086
if (pos -
_ps
.charPos > 0)
4102
_ps
.charPos++;
4107
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
4109
if (!
_ps
.eolNormalized)
4129
if (pos ==
_ps
.charsUsed)
4139
if (pos + 1 ==
_ps
.charsUsed)
4150
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
4166
outStartPos =
_ps
.charPos;
4167
_ps
.charPos = pos;
4201
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
4210
_curNode.SetValueNode(type,
_ps
.chars, startPos, endPos - startPos);
4218
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
4225
_stringBuilder.Append(
_ps
.chars, startPos, endPos - startPos);
4247
if (
_ps
.charsUsed -
_ps
.charPos < 3)
4256
int pos =
_ps
.charPos;
4257
char[] chars =
_ps
.chars;
4279
Debug.Assert(!
_ps
.eolNormalized);
4287
outStartPos =
_ps
.charPos;
4288
_ps
.charPos = pos + 3;
4292
else if (pos + 2 ==
_ps
.charsUsed)
4301
else if (pos + 1 ==
_ps
.charsUsed)
4321
if (!
_ps
.eolNormalized && _parsingMode == ParsingMode.Full)
4323
if (pos -
_ps
.charPos > 0)
4339
_ps
.charPos++;
4344
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
4346
if (!
_ps
.eolNormalized)
4366
if (pos ==
_ps
.charsUsed)
4374
if (pos + 1 ==
_ps
.charsUsed)
4385
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
4400
outStartPos =
_ps
.charPos;
4402
_ps
.charPos = pos;
4417
while (
_ps
.charsUsed -
_ps
.charPos < 8)
4424
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("DOCTYPE"))
4428
if (!XmlCharType.IsWhiteSpace(
_ps
.chars[
_ps
.charPos + 7]))
4430
ThrowExpectingWhitespace(
_ps
.charPos + 7);
4435
Throw(
_ps
.charPos - 2, SR.Xml_MultipleDTDsProvided); // position just before <!DOCTYPE
4439
Throw(
_ps
.charPos - 2, SR.Xml_DtdAfterRootElement);
4442
_ps
.charPos += 8;
4449
_curNode.SetLineInfo(
_ps
.LineNo,
_ps
.LinePos);
4491
_ps
.charPos = pos;
4497
if (
_ps
.chars[
_ps
.charPos] == 'P')
4500
while (
_ps
.charsUsed -
_ps
.charPos < 6)
4508
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("PUBLIC"))
4512
_ps
.charPos += 6;
4517
ThrowExpectingWhitespace(
_ps
.charPos);
4526
ThrowExpectingWhitespace(
_ps
.charPos);
4534
else if (
_ps
.chars[
_ps
.charPos] == 'S')
4537
while (
_ps
.charsUsed -
_ps
.charPos < 6)
4545
if (!
_ps
.chars.AsSpan(
_ps
.charPos).StartsWith("SYSTEM"))
4549
_ps
.charPos += 6;
4554
ThrowExpectingWhitespace(
_ps
.charPos);
4562
else if (
_ps
.chars[
_ps
.charPos] != '[' &&
_ps
.chars[
_ps
.charPos] != '>')
4568
if (
_ps
.chars[
_ps
.charPos] == '[')
4570
_ps
.charPos++;
4575
if (
_ps
.chars[
_ps
.charPos] != '>')
4580
else if (
_ps
.chars[
_ps
.charPos] == '>')
4588
_ps
.charPos++;
4594
char quoteChar =
_ps
.chars[
_ps
.charPos];
4600
_ps
.charPos++;
4611
char[] chars =
_ps
.chars;
4612
int pos =
_ps
.charPos;
4626
_ps
.charPos = pos + 1;
4631
_ps
.charPos = pos;
4644
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
4670
if (pos + 3 >=
_ps
.charsUsed && !
_ps
.isEof)
4685
else if (pos + 1 >=
_ps
.charsUsed && !
_ps
.isEof)
4695
if (pos + 2 >=
_ps
.charsUsed && !
_ps
.isEof)
4713
if (pos + 1 >=
_ps
.charsUsed && !
_ps
.isEof)
4754
if (pos ==
_ps
.charsUsed)
4764
if (pos + 1 ==
_ps
.charsUsed)
4775
ThrowInvalidChar(chars,
_ps
.charsUsed, pos);
4784
if (
_ps
.charsUsed -
_ps
.charPos > 0)
4786
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
4791
Debug.Assert(
_ps
.isEof);
4798
chars =
_ps
.chars;
4799
pos =
_ps
.charPos;
4805
int pos =
_ps
.charPos;
4807
char[] chars =
_ps
.chars;
4822
int tmp1 = pos -
_ps
.charPos;
4823
if (sb != null && !
_ps
.eolNormalized)
4827
sb.Append(chars,
_ps
.charPos, tmp1);
4830
_ps
.charPos = pos + 1;
4834
else if (pos + 1 <
_ps
.charsUsed ||
_ps
.isEof)
4836
if (!
_ps
.eolNormalized)
4853
if (pos ==
_ps
.charsUsed)
4859
int tmp2 = pos -
_ps
.charPos;
4862
sb?.Append(
_ps
.chars,
_ps
.charPos, tmp2);
4863
_ps
.charPos = pos;
4872
int tmp3 = pos -
_ps
.charPos;
4875
sb?.Append(
_ps
.chars,
_ps
.charPos, tmp3);
4876
_ps
.charPos = pos;
4882
if (
_ps
.charsUsed -
_ps
.charPos == 0)
4886
if (
_ps
.chars[
_ps
.charPos] != (char)0xD)
4891
Debug.Assert(
_ps
.isEof);
4893
pos =
_ps
.charPos;
4894
chars =
_ps
.chars;
4912
switch (newPos = ParseNumericCharRefInline(
_ps
.charPos, expand, internalSubsetBuilder, out charCount, out entityType))
4920
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
4925
_ps
.charPos = newPos - charCount;
4944
switch (newPos = ParseNamedCharRefInline(
_ps
.charPos, expand, internalSubsetBuilder))
4954
Debug.Assert(
_ps
.chars[
_ps
.charPos] == '&');
4959
_ps
.charPos = newPos - 1;
4982
int pos =
_ps
.charPos + startOffset;
4985
char[] chars =
_ps
.chars;
4994
if (pos + 1 >=
_ps
.charsUsed)
5007
Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars,
_ps
.charsUsed, pos));
5034
colonOffset = pos -
_ps
.charPos;
5040
colonOffset = pos -
_ps
.charPos;
5046
else if (pos ==
_ps
.charsUsed)
5053
chars =
_ps
.chars;
5060
colonPos = (colonOffset == -1) ? -1 :
_ps
.charPos + colonOffset;
5067
int offset = pos -
_ps
.charPos;
5069
pos =
_ps
.charPos + offset;
5088
if (
_ps
.chars[endPos] != ';')
5093
string entityName = _nameTable.Add(
_ps
.chars,
_ps
.charPos, endPos -
_ps
.charPos);
5094
_ps
.charPos = endPos + 1;
5211
Debug.Assert(
_ps
.appendMode);
5212
int initialPos =
_ps
.charPos;
5219
_ps
.charPos = initialPos;
5225
Encoding? enc =
_ps
.encoding;
5245
if (_v1Compat && pos ==
_ps
.charsUsed - 1 &&
_ps
.chars[pos] == (char)0 && await ReadDataAsync().ConfigureAwait(false) == 0 &&
_ps
.isStreamEof)
5247
_ps
.charsUsed--;
5379
_curNode.AdjustLineInfo(_readValueOffset,
_ps
.eolNormalized, ref _incReadLineInfo);
5403
_incReadLineInfo.Set(
_ps
.LineNo,
_ps
.LinePos);
5413
charsRead = _incReadDecoder.Decode(
_ps
.chars, startPos, endPos - startPos);
5427
_curNode.SetValue(
_ps
.chars, startPos, endPos - startPos);
5429
AdjustLineInfo(
_ps
.chars, startPos - charsRead, startPos,
_ps
.eolNormalized, ref _incReadLineInfo);