1 write to _ps
System.Private.Xml (1)
System\Xml\Core\XmlTextReaderImpl.cs (1)
8135_ps = _parsingStatesStack[_parsingStatesStackTop--];
1713 references to _ps
System.Private.Xml (1713)
System\Xml\Core\XmlTextReaderImpl.cs (1057)
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; 1237Debug.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; 1472if (_ps.entityId == _attributeValueBaseEntityId) 1508if (_ps.charsUsed - _ps.charPos == 0) 1529if (_ps.charsUsed - _ps.charPos == 0 && !_ps.entity!.IsExternal) 1547_ps.entityResolvedManually = true; 1867Debug.Assert(_ps.chars != null); 1868BlockCopyChars(_ps.chars, startPos, buffer, (index + readCount), copyCount); 1891Debug.Assert(_ps.chars != null); 1892_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 2020if (_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; 2363if (_ps.baseUriStr.Length > 0 && _ps.baseUri == null && _xmlResolver != null) 2365_ps.baseUri = _xmlResolver.ResolveUri(null, _ps.baseUriStr); 2368return _ps.baseUri; 2376return _ps.isEof; 2384return _ps.chars; 2392return _ps.charsUsed; 2400return _ps.charPos; 2404Debug.Assert(value >= 0 && value <= _ps.charsUsed); 2405_ps.charPos = value; 2421return _ps.eolNormalized; 2446return _ps.LineNo; 2454return _ps.lineStartPos; 2514if (e.ResString == SR.Xml_UnexpectedEOF && _ps.entity != null) 2516SendValidationEvent(XmlSeverityType.Error, SR.Sch_ParEntityRefNesting, null, _ps.LineNo, _ps.LinePos); 2555entityId = _ps.entityId; 2568oldEntity = _ps.entity; 2570newEntityId = _ps.entityId; 2588if (_ps.baseUri == null && !string.IsNullOrEmpty(_ps.baseUriStr)) 2590_ps.baseUri = _xmlResolver.ResolveUri(null, _ps.baseUriStr); 2593PushExternalEntityOrSubset(publicId, systemId, _ps.baseUri, null); 2595_ps.entity = null; 2596_ps.entityId = 0; 2598Debug.Assert(_ps.appendMode); 2599int 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; 2682Throw(new XmlException(res, string.Empty, lineNo, linePos, _ps.baseUriStr)); 2688Throw(new XmlException(res, arg, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); 2694Throw(new XmlException(res, arg, lineNo, linePos, _ps.baseUriStr)); 2700Throw(new XmlException(res, args, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); 2712Throw(new XmlException(res, args, innerException, _ps.LineNo, _ps.LinePos, _ps.baseUriStr)); 2732Throw(new XmlException(e.Message, (Exception?)null, lineNo, linePos, _ps.baseUriStr)); 2738Throw(new XmlException(res, string.Empty, _ps.baseUriStr)); 2744Throw(new XmlException(res, arg, _ps.baseUriStr)); 2750Throw(new XmlException(res, args, innerException, 0, 0, _ps.baseUriStr)); 2767SendValidationEvent(severity, new XmlSchemaException(code, arg, _ps.baseUriStr, lineNo, linePos)); 2800while (_ps.entityId != _attributeValueBaseEntityId) 2842Debug.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; 2856bufferSize = _ps.bytes.Length; 2869if (_ps.bytes == null || _ps.bytes.Length < bufferSize) 2871_ps.bytes = new byte[bufferSize]; 2876if (_ps.chars == null || _ps.chars.Length < bufferSize + 1) 2878_ps.chars = new char[bufferSize + 1]; 2882_ps.bytePos = 0; 2883if (_ps.bytesUsed < 4 && _ps.bytes.Length - _ps.bytesUsed > 0) 2885int bytesToRead = Math.Min(4, _ps.bytes.Length - _ps.bytesUsed); 2886int 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; 2917Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0 && _ps.stream == null); 2920_ps.textReader = input; 2921_ps.baseUriStr = baseUriStr; 2922_ps.baseUri = baseUri; 2924if (_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; 2946Debug.Assert(_ps.stream == null && _ps.textReader == null); 2947Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0); 2951_ps.baseUriStr = baseUriStr; 2952_ps.baseUri = null; 2955_ps.chars = new char[len + 1]; 2956str.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; 3060if (_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)); 3076if (_ps.stream == null) 3078ThrowWithoutLineInfo(SR.Xml_CannotResolveUrl, _ps.baseUriStr); 3081Debug.Assert(_ps.stream != null); 3082InitStreamInput(_ps.baseUri, _ps.baseUriStr, _ps.stream, null); 3083_reportedEncoding = _ps.encoding; 3089Debug.Assert(_ps.bytes != null); 3090Debug.Assert(_ps.bytePos == 0); 3092if (_ps.bytesUsed < 2) 3097int first2Bytes = _ps.bytes[0] << 8 | _ps.bytes[1]; 3098int next2Bytes = (_ps.bytesUsed >= 4) ? (_ps.bytes[2] << 8 | _ps.bytes[3]) : 0; 3176Debug.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 3194Debug.Assert(_ps.encoding != null); 3195Debug.Assert(_ps.bytes != null); 3196ReadOnlySpan<byte> preamble = _ps.encoding.Preamble; 3197if (_ps.bytes.AsSpan(0, _ps.bytesUsed).StartsWith(preamble)) 3199_ps.bytePos = preamble.Length; 3206Debug.Assert(_ps.encoding != null); 3207if ((newEncoding.WebName != _ps.encoding.WebName || _ps.decoder is SafeAsciiDecoder) && !_afterResetState) 3209Debug.Assert(_ps.stream != null); 3211_ps.appendMode = false; 3221Debug.Assert(_ps.encoding != null); 3224if (_ps.stream == null) 3226return _ps.encoding; 3234if (_ps.encoding.WebName != "utf-16BE" && 3235_ps.encoding.WebName != "utf-16" && 3247return _ps.encoding; 3275if (_afterResetState && _ps.encoding.WebName != newEncoding.WebName) 3285Debug.Assert(_ps.stream != null && _ps.decoder != null && _ps.bytes != null); 3286Debug.Assert(_ps.appendMode, "UnDecodeChars cannot be called after ps.appendMode has been changed to false"); 3288Debug.Assert(_ps.charsUsed >= _ps.charPos, "The current position must be in the valid character range."); 3296Debug.Assert(_charactersInDocument >= _ps.charsUsed - _ps.charPos, 3298_charactersInDocument -= _ps.charsUsed - _ps.charPos; 3305Debug.Assert(_charactersFromEntities >= _ps.charsUsed - _ps.charPos, 3307_charactersFromEntities -= _ps.charsUsed - _ps.charPos; 3311_ps.bytePos = _documentStartBytePos; // byte position after preamble 3312if (_ps.charPos > 0) 3314Debug.Assert(_ps.encoding != null); 3315Debug.Assert(_ps.chars != null); 3316if (_ps.decoder is SafeAsciiDecoder) 3323_ps.bytePos += _ps.charPos; 3324int encodingByteCount = _ps.encoding.GetByteCount(_ps.chars, 0, _ps.charPos); 3325if (encodingByteCount != _ps.charPos) 3332_ps.bytePos += _ps.encoding.GetByteCount(_ps.chars, 0, _ps.charPos); 3336_ps.charsUsed = _ps.charPos; 3337_ps.isEof = false; 3353if (_ps.isEof) 3358Debug.Assert(_ps.chars != null); 3360if (_ps.appendMode) 3363if (_ps.charsUsed == _ps.chars.Length - 1) 3371char[] newChars = new char[_ps.chars.Length * 2]; 3372BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); 3373_ps.chars = newChars; 3376if (_ps.stream != null) 3379if (_ps.bytesUsed - _ps.bytePos < MaxByteSequenceLen) 3381Debug.Assert(_ps.bytes != null); 3382if (_ps.bytes.Length - _ps.bytesUsed < MaxByteSequenceLen) 3384byte[] newBytes = new byte[_ps.bytes.Length * 2]; 3385BlockCopy(_ps.bytes, 0, newBytes, 0, _ps.bytesUsed); 3386_ps.bytes = newBytes; 3391charsRead = _ps.chars.Length - _ps.charsUsed - 1; 3399int charsLen = _ps.chars.Length; 3400if (charsLen - _ps.charsUsed <= charsLen / 2) 3409int copyCharsCount = _ps.charsUsed - _ps.charPos; 3412_ps.lineStartPos -= _ps.charPos; 3415BlockCopyChars(_ps.chars, _ps.charPos, _ps.chars, 0, copyCharsCount); 3417_ps.charPos = 0; 3418_ps.charsUsed = copyCharsCount; 3422char[] newChars = new char[_ps.chars.Length * 2]; 3423BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); 3424_ps.chars = newChars; 3428if (_ps.stream != null) 3431int bytesLeft = _ps.bytesUsed - _ps.bytePos; 3436_ps.bytesUsed = 0; 3440Debug.Assert(_ps.bytes != null); 3441BlockCopy(_ps.bytes, _ps.bytePos, _ps.bytes, 0, bytesLeft); 3442_ps.bytesUsed = bytesLeft; 3445_ps.bytePos = 0; 3448charsRead = _ps.chars.Length - _ps.charsUsed - 1; 3451if (_ps.stream != null) 3453if (!_ps.isStreamEof) 3455Debug.Assert(_ps.bytes != null); 3458if (_ps.bytePos == _ps.bytesUsed && _ps.bytes.Length - _ps.bytesUsed > 0) 3460int read = _ps.stream.Read(_ps.bytes, _ps.bytesUsed, _ps.bytes.Length - _ps.bytesUsed); 3463_ps.isStreamEof = true; 3465_ps.bytesUsed += read; 3469int originalBytePos = _ps.bytePos; 3473if (charsRead == 0 && _ps.bytePos != originalBytePos) 3479else if (_ps.textReader != null) 3482charsRead = _ps.textReader.Read(_ps.chars, _ps.charsUsed, _ps.chars.Length - _ps.charsUsed - 1); 3483_ps.charsUsed += charsRead; 3494Debug.Assert(_ps.charsUsed < _ps.chars.Length); 3495_ps.isEof = true; 3498_ps.chars[_ps.charsUsed] = (char)0; 3505Debug.Assert(_ps.stream != null && _ps.decoder != null && _ps.bytes != null); 3506Debug.Assert(_ps.chars != null); 3507Debug.Assert(maxCharsCount <= _ps.chars.Length - _ps.charsUsed - 1); 3510int bytesCount = _ps.bytesUsed - _ps.bytePos; 3521_ps.decoder.Convert(_ps.bytes, _ps.bytePos, bytesCount, _ps.chars, _ps.charsUsed, maxCharsCount, false, out bytesCount, out charsCount, out completed); 3529_ps.bytePos += bytesCount; 3530_ps.charsUsed += charsCount; 3546Debug.Assert(_ps.decoder != null); 3547Debug.Assert(_ps.bytes != null); 3548Debug.Assert(_ps.chars != null); 3549_ps.decoder.Convert(_ps.bytes, _ps.bytePos + bytesDecoded, 1, _ps.chars, _ps.charsUsed + charsDecoded, 2, false, out bDec, out chDec, out completed); 3562Throw(_ps.charsUsed, SR.Xml_InvalidCharInThisEncoding); 3581_ps.Close(closeInput); 3596Debug.Assert(_ps.chars != null); 3597BlockCopyChars(_ps.chars, sourcePos, _ps.chars, destPos, count); 3603while (_ps.charsUsed - _ps.charPos < 6) 3611if (!_ps.chars.AsSpan(_ps.charPos).StartsWith(XmlDeclarationBeginning) || 3612XmlCharType.IsNameSingleChar(_ps.chars![_ps.charPos + 5])) 3619_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos + 2); 3623_ps.charPos += 5; 3639if (_ps.chars[_ps.charPos] == '?') 3643if (_ps.chars[_ps.charPos + 1] == '>') 3650_ps.charPos += 2; 3670Debug.Assert(_ps.encoding != null); 3671string encodingName = _ps.encoding.WebName; 3673encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) 3675Throw(SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); 3678if (_ps.decoder is SafeAsciiDecoder) 3687_ps.appendMode = false; 3690else if (_ps.charPos + 1 == _ps.charsUsed) 3709switch (_ps.chars.AsSpan(_ps.charPos, nameEndPos - _ps.charPos)) 3748attr.SetLineInfo(_ps.LineNo, _ps.LinePos); 3750sb.Append(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); 3751_ps.charPos = nameEndPos; 3754if (_ps.chars[_ps.charPos] != '=') 3757if (_ps.chars[_ps.charPos] != '=') 3763_ps.charPos++; 3765char quoteChar = _ps.chars[_ps.charPos]; 3769quoteChar = _ps.chars[_ps.charPos]; 3776_ps.charPos++; 3781attr.SetLineInfo2(_ps.LineNo, _ps.LinePos); 3785int pos = _ps.charPos; 3788chars = _ps.chars; 3794if (_ps.chars[pos] == quoteChar) 3801if (_ps.chars.AsSpan(_ps.charPos).StartsWith("1.0")) 3806attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); 3812string badVersion = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 3817string encName = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 3827switch (_ps.chars.AsSpan(_ps.charPos, pos - _ps.charPos)) 3837Throw(SR.Xml_InvalidXmlDecl, _ps.LineNo, _ps.LinePos - 1); 3843attr.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); 3851sb.Append(chars, _ps.charPos, pos - _ps.charPos); 3853_ps.charPos = pos + 1; 3856else if (pos == _ps.charsUsed) 3873if (_ps.isEof || ReadData() == 0) 3888Debug.Assert(_ps.encoding != null); 3889string encodingName = _ps.encoding.WebName; 3891encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) 3893Throw(SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); 3896if (_ps.decoder is SafeAsciiDecoder) 3900_ps.appendMode = false; 3911int pos = _ps.charPos; 3912Debug.Assert(_ps.chars != null); 3913char[] chars = _ps.chars; 3919if (_ps.charsUsed - pos < 4) // minimum "<a/>" 3926_ps.charPos = pos + 1; 3934if (_ps.charsUsed - pos < 2) // minimum characters expected "--" 3941_ps.charPos = pos + 2; 3959if (_ps.charsUsed - pos < 6) 3965_ps.charPos = pos + 6; 3980Throw(_ps.charPos, SR.Xml_InvalidRootData); 3989_ps.charPos = pos; 4025_ps.charPos = pos; 4066else if (pos == _ps.charsUsed || ((_v1Compat || mangoQuirks) && chars[pos] == 0x0)) 4094Debug.Assert(pos == _ps.charsUsed && !_ps.isEof); 4136int pos = _ps.charPos; 4137Debug.Assert(_ps.chars != null); 4138char[] chars = _ps.chars; 4148_ps.charPos = pos + 2; 4156if (_ps.charsUsed - pos < 2) 4163_ps.charPos = pos + 2; 4179if (_ps.charsUsed - pos < 6) 4185_ps.charPos = pos + 6; 4208_ps.charPos = pos + 2; 4213if (pos + 1 == _ps.charsUsed) 4220_ps.charPos = pos + 1; 4234if (pos == _ps.charsUsed) 4253if (_ps.charsUsed - _ps.charPos != 0) 4279Throw(_ps.charsUsed, SR.Xml_UnexpectedEOF1); 4303Throw(_ps.charsUsed, SR.Xml_UnexpectedEOFInElementContent, _stringBuilder.ToString()); 4310int pos = _ps.charPos; 4311Debug.Assert(_ps.chars != null); 4312char[] chars = _ps.chars; 4315_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 4366else if (pos + 1 < _ps.charsUsed) 4373chars = _ps.chars; 4384_nameTable.Add(chars, _ps.charPos, pos - _ps.charPos)); 4388int startPos = _ps.charPos; 4401_nameTable.Add(chars, _ps.charPos, prefixLen), 4412_ps.charPos = pos; 4422_ps.charPos = pos + 1; 4428if (pos + 1 == _ps.charsUsed) 4430_ps.charPos = pos; 4435pos = _ps.charPos; 4436chars = _ps.chars; 4443_ps.charPos = pos + 2; 4453Throw(pos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 4553while (_ps.charsUsed - _ps.charPos < prefLen + locLen + 1) 4562Debug.Assert(_ps.chars != null); 4563char[] chars = _ps.chars; 4566if (!chars.AsSpan(_ps.charPos).StartsWith(startTagNode.localName)) 4574int colonPos = _ps.charPos + prefLen; 4575if (!chars.AsSpan(_ps.charPos).StartsWith(startTagNode.prefix) || 4584LineInfo endTagLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); 4589pos = _ps.charPos + nameLen; 4590chars = _ps.chars; 4592if (pos == _ps.charsUsed) 4619else if (pos == _ps.charsUsed && !_ps.isEof) 4633else if (pos == _ps.charsUsed) 4659_ps.charPos = pos + 1; 4673Debug.Assert(_ps.chars != null); 4678args[3] = new string(_ps.chars, _ps.charPos, endPos - _ps.charPos); 4691int pos = _ps.charPos; 4692Debug.Assert(_ps.chars != null); 4693char[] chars = _ps.chars; 4718else if (pos + 1 != _ps.charsUsed) 4725_ps.charPos = pos; 4746_ps.charPos = pos + 1; 4754if (pos + 1 == _ps.charsUsed) 4760_ps.charPos = pos + 2; 4771else if (pos == _ps.charsUsed) 4777Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 4781if (pos == _ps.charPos) 4785_ps.charPos = pos; 4788int attrNameLinePos = _ps.LinePos; 4791int attrNameLineNo = _ps.LineNo; 4844chars = _ps.chars; 4847else if (pos + 1 >= _ps.charsUsed) 4850chars = _ps.chars; 4854attr.SetLineInfo(_ps.LineNo, attrNameLinePos); 4857Debug.Assert(attrNameLineNo == _ps.LineNo); 4863_ps.charPos = pos; 4865pos = _ps.charPos; 4876_ps.charPos = pos; 4878pos = _ps.charPos; 4886_ps.charPos = pos; 4889attr.SetLineInfo2(_ps.LineNo, _ps.LinePos); 4903string val = new string(chars, _ps.charPos, pos - _ps.charPos); 4907attr.SetValue(chars, _ps.charPos, pos - _ps.charPos); 4909_ps.charPos = pos; 4914pos = _ps.charPos; 4915chars = _ps.chars; 4943_ps.lineNo -= lineNoDelta; 4946pos = _ps.charPos; 4947chars = _ps.chars; 5113Debug.Assert(_ps.chars != null); 5114char[] chars = _ps.chars; 5115int attributeBaseEntityId = _ps.entityId; 5117LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); 5130if (pos - _ps.charPos > 0) 5132_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 5133_ps.charPos = pos; 5136if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId) 5151_ps.charPos++; 5160_stringBuilder.Append(_ps.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA 5161_ps.charPos = pos; 5164else if (pos + 1 < _ps.charsUsed || _ps.isEof) 5170_ps.charPos = pos; 5185_ps.charPos++; 5199if (pos - _ps.charPos > 0) 5201_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 5203_ps.charPos = pos; 5205int enclosingEntityId = _ps.entityId; 5206LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1); 5214if (_parsingMode == ParsingMode.Full && _ps.entityId == attributeBaseEntityId) 5228_ps.charPos++; 5245valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 5251_ps.charPos++; 5254pos = _ps.charPos; 5275Debug.Assert(_ps.entity != null); 5276entityChunk.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name); 5284pos = _ps.charPos; 5287pos = _ps.charPos; 5290chars = _ps.chars; 5294if (pos == _ps.charsUsed) 5304if (pos + 1 == _ps.charsUsed) 5315ThrowInvalidChar(chars, _ps.charsUsed, pos); 5325if (_ps.charsUsed - _ps.charPos > 0) 5327if (_ps.chars[_ps.charPos] != (char)0xD) 5332Debug.Assert(_ps.isEof); 5340if (attributeBaseEntityId != _ps.entityId) 5354if (attributeBaseEntityId == _ps.entityId) 5357valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 5362pos = _ps.charPos; 5363chars = _ps.chars; 5380_ps.charPos = pos + 1; 5418_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5436Debug.Assert(_ps.chars != null); 5437_curNode.SetValueNode(nodeType, _ps.chars, startPos, endPos - startPos); 5450_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5456_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5481Debug.Assert(_ps.chars != null); 5482_curNode.SetValueNode(XmlNodeType.Text, _ps.chars, startPos, endPos - startPos); 5491_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5498_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5556Debug.Assert(_ps.chars != null); 5557char[] chars = _ps.chars; 5558int pos = _ps.charPos; 5586if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 5588if (pos - _ps.charPos > 0) 5604_ps.charPos++; 5609else if (pos + 1 < _ps.charsUsed || _ps.isEof) 5611if (!_ps.eolNormalized) 5649if (pos > _ps.charPos) 5670if (!XmlCharType.IsWhiteSpace(_ps.chars[pos - 1])) 5676pos = _ps.charPos; 5679chars = _ps.chars; 5683if (_ps.charsUsed - pos < 3 && !_ps.isEof) 5696if (pos == _ps.charsUsed) 5706if (pos + 1 == _ps.charsUsed) 5718int offset = pos - _ps.charPos; 5721pos = _ps.charPos + offset; 5726ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos + offset); 5733if (pos > _ps.charPos) 5740if (_ps.charsUsed - _ps.charPos > 0) 5742if (_ps.chars[_ps.charPos] != (char)0xD && _ps.chars[_ps.charPos] != ']') 5746Debug.Assert(_ps.isEof); 5765pos = _ps.charPos; 5766chars = _ps.chars; 5778startPos = _ps.charPos; 5780_ps.charPos = pos; 5799_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5801_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5921Debug.Assert(_ps.chars != null); 5925if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || ZeroEndingStream(_ps.charPos)) 5932_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5934if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || ZeroEndingStream(_ps.charPos)) 5946if (XmlCharType.IsCharData(_ps.chars[_ps.charPos])) 5952ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos); 5959Debug.Assert(_ps.chars != null); 5960Debug.Assert(_ps.chars[_ps.charPos] == '&'); 5961_ps.charPos++; 5963_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5969Debug.Assert(_ps.chars != null); 5970Debug.Assert(_ps.chars[_ps.charPos] == '&'); 5972if (_ps.charPos + 1 == _ps.charsUsed) 5981if (_ps.chars[_ps.charPos + 1] == '#') 6009_ps.charPos++; 6010int savedLinePos = _ps.LinePos; 6017Throw(SR.Xml_ErrorParsingEntityName, _ps.LineNo, savedLinePos); 6022if (_ps.chars[endPos] != ';') 6027int entityLinePos = _ps.LinePos; 6028string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 6029_ps.charPos = endPos + 1; 6033_reportedBaseUri = _ps.baseUriStr; 6034_reportedEncoding = _ps.encoding; 6060Throw(SR.Xml_UndeclaredEntity, name, _ps.LineNo, entityStartLinePos); 6074Throw(SR.Xml_UnparsedEntityRef, name, _ps.LineNo, entityStartLinePos); 6079Throw(SR.Xml_ExternalEntityInStandAloneDocument, entity.Name, _ps.LineNo, entityStartLinePos); 6086Throw(SR.Xml_ExternalEntityInAttValue, name, _ps.LineNo, entityStartLinePos); 6100_curNode.entityId = _ps.entityId; 6108_curNode.entityId = _ps.entityId; 6121_curNode.entityId = _ps.entityId; 6143if (_ps.entityResolvedManually) 6149if (_ps.entityId != _nodes[_index].entityId) 6155_lastEntity = _ps.entity; // save last entity for the EndEntity node 6164if (_ps.entityId != _nodes[_index].entityId) 6172_reportedEncoding = _ps.encoding; 6173_reportedBaseUri = _ps.baseUriStr; 6182_reportedEncoding = _ps.encoding; 6183_reportedBaseUri = _ps.baseUriStr; 6188_curNode.lineInfo.Set(_ps.lineNo, _ps.LinePos - 1); 6217_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6224Debug.Assert(_ps.chars != null); 6225string target = _nameTable.Add(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); 6231_ps.charPos = nameEndPos; 6246char ch = _ps.chars[_ps.charPos]; 6247Debug.Assert(_ps.charPos < _ps.charsUsed); 6250if (_ps.charsUsed - _ps.charPos < 2) 6254if (ch != '?' || _ps.chars[_ps.charPos + 1] != '>') 6256Throw(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(_ps.chars, _ps.charsUsed, _ps.charPos)); 6272_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 6277piInDtdStringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6300sb.Append(_ps.chars, startPos, endPos - startPos); 6302sb.Append(_ps.chars, startPos, endPos - startPos); 6317if (_ps.charsUsed - _ps.charPos < 2) 6321Throw(_ps.charsUsed, SR.Xml_UnexpectedEOF, "PI"); 6325Debug.Assert(_ps.chars != null); 6326int pos = _ps.charPos; 6327char[] chars = _ps.chars; 6347Debug.Assert(!_ps.eolNormalized); 6355outStartPos = _ps.charPos; 6356_ps.charPos = pos + 2; 6359else if (pos + 1 == _ps.charsUsed) 6376if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 6379if (pos - _ps.charPos > 0) 6395_ps.charPos++; 6400else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6402if (!_ps.eolNormalized) 6422if (pos == _ps.charsUsed) 6432if (pos + 1 == _ps.charsUsed) 6443ThrowInvalidChar(chars, _ps.charsUsed, pos); 6459outStartPos = _ps.charPos; 6460_ps.charPos = pos; 6493_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6497Debug.Assert(_ps.chars != null); 6498_curNode.SetValueNode(type, _ps.chars, startPos, endPos - startPos); 6504_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6507_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6521if (_ps.charsUsed - _ps.charPos < 3) 6530Debug.Assert(_ps.chars != null); 6531int pos = _ps.charPos; 6532char[] chars = _ps.chars; 6554Debug.Assert(!_ps.eolNormalized); 6562outStartPos = _ps.charPos; 6563_ps.charPos = pos + 3; 6566else if (pos + 2 == _ps.charsUsed) 6575else if (pos + 1 == _ps.charsUsed) 6595if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 6597if (pos - _ps.charPos > 0) 6613_ps.charPos++; 6618else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6620if (!_ps.eolNormalized) 6640if (pos == _ps.charsUsed) 6648if (pos + 1 == _ps.charsUsed) 6659ThrowInvalidChar(chars, _ps.charsUsed, pos); 6674outStartPos = _ps.charPos; 6676_ps.charPos = pos; 6690while (_ps.charsUsed - _ps.charPos < 8) 6698if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("DOCTYPE")) 6703Debug.Assert(_ps.chars != null); 6704if (!XmlCharType.IsWhiteSpace(_ps.chars[_ps.charPos + 7])) 6706ThrowExpectingWhitespace(_ps.charPos + 7); 6711Throw(_ps.charPos - 2, SR.Xml_MultipleDTDsProvided); // position just before <!DOCTYPE 6716Throw(_ps.charPos - 2, SR.Xml_DtdAfterRootElement); 6719_ps.charPos += 8; 6725_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6762_ps.charPos = pos; 6768Debug.Assert(_ps.chars != null); 6769if (_ps.chars[_ps.charPos] == 'P') 6772while (_ps.charsUsed - _ps.charPos < 6) 6780if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("PUBLIC")) 6784_ps.charPos += 6; 6789ThrowExpectingWhitespace(_ps.charPos); 6798ThrowExpectingWhitespace(_ps.charPos); 6806else if (_ps.chars[_ps.charPos] == 'S') 6809while (_ps.charsUsed - _ps.charPos < 6) 6817if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("SYSTEM")) 6821_ps.charPos += 6; 6826ThrowExpectingWhitespace(_ps.charPos); 6834else if (_ps.chars[_ps.charPos] != '[' && _ps.chars[_ps.charPos] != '>') 6840if (_ps.chars[_ps.charPos] == '[') 6842_ps.charPos++; 6847if (_ps.chars[_ps.charPos] != '>') 6852else if (_ps.chars[_ps.charPos] == '>') 6860_ps.charPos++; 6865Debug.Assert(_ps.chars != null); 6867char quoteChar = _ps.chars[_ps.charPos]; 6873_ps.charPos++; 6884Debug.Assert(_ps.chars != null); 6885char[] chars = _ps.chars; 6886int pos = _ps.charPos; 6900_ps.charPos = pos + 1; 6905_ps.charPos = pos; 6918else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6944if (pos + 3 >= _ps.charsUsed && !_ps.isEof) 6959else if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 6969if (pos + 2 >= _ps.charsUsed && !_ps.isEof) 6987if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 7028if (pos == _ps.charsUsed) 7038if (pos + 1 == _ps.charsUsed) 7049ThrowInvalidChar(chars, _ps.charsUsed, pos); 7058if (_ps.charsUsed - _ps.charPos > 0) 7060if (_ps.chars[_ps.charPos] != (char)0xD) 7065Debug.Assert(_ps.isEof); 7072chars = _ps.chars; 7073pos = _ps.charPos; 7079int pos = _ps.charPos; 7081Debug.Assert(_ps.chars != null); 7082char[] chars = _ps.chars; 7097int tmp1 = pos - _ps.charPos; 7098if (sb != null && !_ps.eolNormalized) 7102sb.Append(chars, _ps.charPos, tmp1); 7105_ps.charPos = pos + 1; 7109else if (pos + 1 < _ps.charsUsed || _ps.isEof) 7111if (!_ps.eolNormalized) 7128if (pos == _ps.charsUsed) 7134int tmp2 = pos - _ps.charPos; 7137sb?.Append(_ps.chars, _ps.charPos, tmp2); 7138_ps.charPos = pos; 7147int tmp3 = pos - _ps.charPos; 7150sb?.Append(_ps.chars, _ps.charPos, tmp3); 7151_ps.charPos = pos; 7157if (_ps.charsUsed - _ps.charPos == 0) 7161if (_ps.chars[_ps.charPos] != (char)0xD) 7166Debug.Assert(_ps.isEof); 7168pos = _ps.charPos; 7169chars = _ps.chars; 7175Debug.Assert(_ps.chars != null); 7176Debug.Assert(_ps.chars[startPos] == '&'); 7177if (_ps.chars[startPos + 1] == '#') 7200switch (newPos = ParseNumericCharRefInline(_ps.charPos, expand, internalSubsetBuilder, out charCount, out entityType)) 7209Debug.Assert(_ps.chars != null); 7210Debug.Assert(_ps.chars[_ps.charPos] == '&'); 7215_ps.charPos = newPos - charCount; 7230Debug.Assert(_ps.chars != null); 7231Debug.Assert(_ps.chars[startPos] == '&' && _ps.chars[startPos + 1] == '#'); 7239chars = _ps.chars; 7261else if (pos < _ps.charsUsed) 7281_ps.charPos = pos; 7290if (pos == _ps.charsUsed) 7308Throw((_ps.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(ch, '\0')); 7313internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos + 1); 7334Throw((_ps.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(high, low)); 7341internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos + 1); 7361switch (newPos = ParseNamedCharRefInline(_ps.charPos, expand, internalSubsetBuilder)) 7372Debug.Assert(_ps.chars != null); 7373Debug.Assert(_ps.chars[_ps.charPos] == '&'); 7378_ps.charPos = newPos - 1; 7393Debug.Assert(startPos < _ps.charsUsed); 7394Debug.Assert(_ps.chars != null); 7395Debug.Assert(_ps.chars[startPos] == '&'); 7396Debug.Assert(_ps.chars[startPos + 1] != '#'); 7399char[] chars = _ps.chars; 7410if (_ps.charsUsed - pos >= 3) 7427if (_ps.charsUsed - pos >= 4) 7442else if (pos < _ps.charsUsed) 7449if (_ps.charsUsed - pos >= 5) 7466if (_ps.charsUsed - pos >= 3) 7482if (_ps.charsUsed - pos >= 3) 7507internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos); 7508_ps.chars[pos - 1] = ch; 7526int pos = _ps.charPos + startOffset; 7529Debug.Assert(_ps.chars != null); 7530char[] chars = _ps.chars; 7539if (pos + 1 >= _ps.charsUsed) 7549Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 7576colonOffset = pos - _ps.charPos; 7582colonOffset = pos - _ps.charPos; 7588else if (pos == _ps.charsUsed) 7592Debug.Assert(_ps.chars != null); 7593chars = _ps.chars; 7600colonPos = (colonOffset == -1) ? -1 : _ps.charPos + colonOffset; 7606int offset = pos - _ps.charPos; 7608pos = _ps.charPos + offset; 7625Debug.Assert(_ps.chars != null); 7628if (_ps.chars[endPos] != ';') 7633string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 7634_ps.charPos = endPos + 1; 7678Debug.Assert(_ps.chars != null); 7683string localName = _nameTable.Add(_ps.chars, _ps.charPos, endNamePos - _ps.charPos); 7689int startPos = _ps.charPos; 7691if (prefixLen == _lastPrefix.Length && _ps.chars.AsSpan(_ps.charPos).StartsWith(_lastPrefix)) 7693return AddAttribute(_nameTable.Add(_ps.chars, colonPos + 1, endNamePos - colonPos - 1), 7699string prefix = _nameTable.Add(_ps.chars, startPos, prefixLen); 7701return AddAttribute(_nameTable.Add(_ps.chars, colonPos + 1, endNamePos - colonPos - 1), 7760_ps.lineNo++; 7761_ps.lineStartPos = pos - 1; 7766Debug.Assert(_ps.isEof); 7769_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 8019Debug.Assert(_ps.appendMode); 8020int initialPos = _ps.charPos; 8028_ps.charPos = initialPos; 8035Encoding? enc = _ps.encoding; 8052Encoding? enc = _ps.encoding; 8060_ps.lineNo = entity.LineNumber; 8061_ps.lineStartPos = -entity.LinePosition - 1; 8063_ps.eolNormalized = true; 8070_ps.stream?.Dispose(); 8074_curNode.entityId = _ps.entityId; 8090_ps.entity = entity; 8091_ps.entityId = _nextEntityId++; 8105if (_ps.entity != null) 8107_currentEntities!.Remove(_ps.entity); 8125_parsingStatesStack[_parsingStatesStackTop] = _ps; 8127_ps.Clear(); 8134_ps.Close(true); 8146_incReadLeftStartPos = _ps.charPos; 8147_incReadLeftEndPos = _ps.charPos; 8148_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 8191Debug.Assert(_ps.chars != null); 8201count = _incReadDecoder.Decode(_ps.chars, _incReadLeftStartPos, charsLeft); 8240Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 2).StartsWith("?>")); 8241_ps.charPos -= 2; 8248Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 3).StartsWith("-->")); 8249_ps.charPos -= 3; 8256Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 3).StartsWith("]]>")); 8257_ps.charPos -= 3; 8285char[] chars = _ps.chars; 8286startPos = _ps.charPos; 8291_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 8332else if (pos + 1 < _ps.charsUsed) 8349if (_ps.charsUsed - pos < 2) 8362if (_ps.charsUsed - pos < 4) 8372if (_ps.charsUsed - pos < 9) 8390Debug.Assert(_ps.charPos - pos == 0); 8391Debug.Assert(_ps.charPos - startPos == 0); 8396if ((endPos - _ps.charPos - 2) == checkName.Length && chars.AsSpan(_ps.charPos + 2).StartsWith(checkName) && 8397(_ps.chars[endPos] == '>' || XmlCharType.IsWhiteSpace(_ps.chars[endPos]))) 8405_ps.charPos = endPos; 8406if (XmlCharType.IsWhiteSpace(_ps.chars[endPos])) 8410if (_ps.chars[_ps.charPos] != '>') 8414_ps.charPos++; 8422startPos = _ps.charPos; 8423chars = _ps.chars; 8430Debug.Assert(_ps.charPos - pos == 0); 8431Debug.Assert(_ps.charPos - startPos == 0); 8435if (endPos - _ps.charPos - 1 == _curNode.localName.Length && _ps.chars.AsSpan(_ps.charPos + 1).StartsWith(_curNode.localName) && 8436(_ps.chars[endPos] == '>' || _ps.chars[endPos] == '/' || XmlCharType.IsWhiteSpace(_ps.chars[endPos]))) 8444startPos = _ps.charPos; 8445chars = _ps.chars; 8454if (_ps.charsUsed - pos < 2) 8493if (pos == _ps.charsUsed) 8510_ps.charPos = pos; 8520count = _incReadDecoder.Decode(_ps.chars, startPos, charsParsed); 8558ParseAttributeValueSlow(_ps.charPos, ' ', _curNode); // The quote char is intentionally empty (space) because we need to parse ' and " into the attribute value 8581Debug.Assert(_ps.chars != null); 8583char[] chars = _ps.chars; 8584int pos = _ps.charPos; 8587_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 8607Debug.Assert(_ps.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!"); 8630if (pos - _ps.charPos > 0) 8632_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8635_ps.charPos = pos; 8643chars = _ps.chars; 8644if (_normalize && XmlCharType.IsWhiteSpace(chars[_ps.charPos]) && pos - _ps.charPos == 1) 8646chars[_ps.charPos] = (char)0x20; // CDATA normalization of character references in entities 8653_ps.charPos++; 8665chars = _ps.chars; 8669if (pos == _ps.charsUsed) 8679if (pos + 1 == _ps.charsUsed) 8692ThrowInvalidChar(chars, _ps.charsUsed, pos); 8698if (pos - _ps.charPos > 0) 8700_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8701_ps.charPos = pos; 8725pos = _ps.charPos; 8726chars = _ps.chars; 8730if (pos - _ps.charPos > 0) 8732_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8733_ps.charPos = pos; 8765_ps.charPos = pos; 8789_ps.charPos = pos; 8795if (_ps.charPos == _ps.charsUsed) 8800Debug.Assert(_ps.chars != null); 8802if (XmlCharType.IsNCNameSingleChar(_ps.chars[_ps.charPos])) 8804int pos = _ps.charPos + 1; 8805while (XmlCharType.IsNCNameSingleChar(_ps.chars[pos])) 8809return new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 8813Debug.Assert(_ps.charPos < _ps.charsUsed); 8814return new string(_ps.chars, _ps.charPos, 1); 8878Debug.Assert(_ps.chars != null); 8880if (_v1Compat && pos == _ps.charsUsed - 1 && _ps.chars[pos] == (char)0 && ReadData() == 0 && _ps.isStreamEof) 8882_ps.charsUsed--; 9388_curNode.AdjustLineInfo(_readValueOffset, _ps.eolNormalized, ref _incReadLineInfo); 9402Debug.Assert(_ps.chars != null); 9413_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 9418charsRead = _incReadDecoder.Decode(_ps.chars, startPos, endPos - startPos); 9433_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 9435AdjustLineInfo(_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; 178Debug.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; 695BlockCopyChars(_ps.chars, startPos, buffer, (index + readCount), copyCount); 718_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 786if (e.ResString == SR.Xml_UnexpectedEOF && _ps.entity != null) 788SendValidationEvent(XmlSeverityType.Error, SR.Sch_ParEntityRefNesting, null, _ps.LineNo, _ps.LinePos); 818entityId = _ps.entityId; 837if (_ps.baseUri == null && !string.IsNullOrEmpty(_ps.baseUriStr)) 839_ps.baseUri = _xmlResolver!.ResolveUri(null, _ps.baseUriStr); 841await PushExternalEntityOrSubsetAsync(publicId, systemId, _ps.baseUri, null).ConfigureAwait(false); 843_ps.entity = null; 844_ps.entityId = 0; 846Debug.Assert(_ps.appendMode); 847int initialPos = _ps.charPos; 854_ps.charPos = initialPos; 868Debug.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; 882bufferSize = _ps.bytes.Length; 897if (_ps.bytes == null || _ps.bytes.Length < bufferSize) 899_ps.bytes = new byte[bufferSize]; 904if (_ps.chars == null || _ps.chars.Length < bufferSize + 1) 906_ps.chars = new char[bufferSize + 1]; 910_ps.bytePos = 0; 911if (_ps.bytesUsed < 4 && _ps.bytes.Length - _ps.bytesUsed > 0) 913int bytesToRead = Math.Min(4, _ps.bytes.Length - _ps.bytesUsed); 914int 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; 944Debug.Assert(_ps.charPos == 0 && _ps.charsUsed == 0 && _ps.stream == null); 947_ps.textReader = input; 948_ps.baseUriStr = baseUriStr; 949_ps.baseUri = baseUri; 951if (_ps.chars == null) 964_ps.chars = new char[bufferSize + 1]; 967_ps.encoding = Encoding.Unicode; 968_ps.eolNormalized = !_normalize; 971_ps.appendMode = true; 1001if ((newEncoding.WebName != _ps.encoding!.WebName || _ps.decoder is SafeAsciiDecoder) && !_afterResetState) 1003Debug.Assert(_ps.stream != null); 1005_ps.appendMode = false; 1026if (_ps.isEof) 1032if (_ps.appendMode) 1035if (_ps.charsUsed == _ps.chars.Length - 1) 1043char[] newChars = new char[_ps.chars.Length * 2]; 1044BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); 1045_ps.chars = newChars; 1048if (_ps.stream != null) 1051if (_ps.bytesUsed - _ps.bytePos < MaxByteSequenceLen) 1053if (_ps.bytes!.Length - _ps.bytesUsed < MaxByteSequenceLen) 1055byte[] newBytes = new byte[_ps.bytes.Length * 2]; 1056BlockCopy(_ps.bytes, 0, newBytes, 0, _ps.bytesUsed); 1057_ps.bytes = newBytes; 1062charsRead = _ps.chars.Length - _ps.charsUsed - 1; 1070int charsLen = _ps.chars.Length; 1071if (charsLen - _ps.charsUsed <= charsLen / 2) 1080int copyCharsCount = _ps.charsUsed - _ps.charPos; 1083_ps.lineStartPos -= _ps.charPos; 1086BlockCopyChars(_ps.chars, _ps.charPos, _ps.chars, 0, copyCharsCount); 1088_ps.charPos = 0; 1089_ps.charsUsed = copyCharsCount; 1093char[] newChars = new char[_ps.chars.Length * 2]; 1094BlockCopyChars(_ps.chars, 0, newChars, 0, _ps.chars.Length); 1095_ps.chars = newChars; 1099if (_ps.stream != null) 1102int bytesLeft = _ps.bytesUsed - _ps.bytePos; 1107_ps.bytesUsed = 0; 1111BlockCopy(_ps.bytes!, _ps.bytePos, _ps.bytes!, 0, bytesLeft); 1112_ps.bytesUsed = bytesLeft; 1114_ps.bytePos = 0; 1117charsRead = _ps.chars.Length - _ps.charsUsed - 1; 1120if (_ps.stream != null) 1122if (!_ps.isStreamEof) 1125if (_ps.bytePos == _ps.bytesUsed && _ps.bytes!.Length - _ps.bytesUsed > 0) 1127int read = await _ps.stream.ReadAsync(_ps.bytes.AsMemory(_ps.bytesUsed)).ConfigureAwait(false); 1130_ps.isStreamEof = true; 1132_ps.bytesUsed += read; 1136int originalBytePos = _ps.bytePos; 1140if (charsRead == 0 && _ps.bytePos != originalBytePos) 1146else if (_ps.textReader != null) 1149charsRead = await _ps.textReader.ReadAsync(_ps.chars.AsMemory(_ps.charsUsed, _ps.chars.Length - _ps.charsUsed - 1)).ConfigureAwait(false); 1150_ps.charsUsed += charsRead; 1161Debug.Assert(_ps.charsUsed < _ps.chars.Length); 1162_ps.isEof = true; 1164_ps.chars[_ps.charsUsed] = (char)0; 1171while (_ps.charsUsed - _ps.charPos < 6) 1179if (!_ps.chars.AsSpan(_ps.charPos).StartsWith(XmlDeclarationBeginning) || 1180XmlCharType.IsNameSingleChar(_ps.chars[_ps.charPos + 5])) 1187_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos + 2); 1190_ps.charPos += 5; 1206if (_ps.chars[_ps.charPos] == '?') 1210if (_ps.chars[_ps.charPos + 1] == '>') 1217_ps.charPos += 2; 1238string encodingName = _ps.encoding!.WebName; 1240encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) 1242Throw(SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); 1245if (_ps.decoder is SafeAsciiDecoder) 1254_ps.appendMode = false; 1257else if (_ps.charPos + 1 == _ps.charsUsed) 1276switch (_ps.chars.AsSpan(_ps.charPos, nameEndPos - _ps.charPos)) 1313attr!.SetLineInfo(_ps.LineNo, _ps.LinePos); 1315sb.Append(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); 1316_ps.charPos = nameEndPos; 1319if (_ps.chars[_ps.charPos] != '=') 1322if (_ps.chars[_ps.charPos] != '=') 1328_ps.charPos++; 1330char quoteChar = _ps.chars[_ps.charPos]; 1334quoteChar = _ps.chars[_ps.charPos]; 1341_ps.charPos++; 1345attr.SetLineInfo2(_ps.LineNo, _ps.LinePos); 1349int pos = _ps.charPos; 1352chars = _ps.chars; 1359if (_ps.chars[pos] == quoteChar) 1366if (_ps.chars.AsSpan(_ps.charPos).StartsWith("1.0")) 1370attr!.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); 1376string badVersion = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 1381string encName = new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 1390switch (_ps.chars.AsSpan(_ps.charPos, pos - _ps.charPos)) 1400Throw(SR.Xml_InvalidXmlDecl, _ps.LineNo, _ps.LinePos - 1); 1405attr!.SetValue(_ps.chars, _ps.charPos, pos - _ps.charPos); 1413sb.Append(chars, _ps.charPos, pos - _ps.charPos); 1415_ps.charPos = pos + 1; 1418else if (pos == _ps.charsUsed) 1435if (_ps.isEof || await ReadDataAsync().ConfigureAwait(false) == 0) 1451string encodingName = _ps.encoding!.WebName; 1453encodingName != "utf-16BE" && !(_ps.encoding is Ucs4Encoding)) 1455Throw(SR.Xml_EncodingSwitchAfterResetState, (_ps.encoding.GetByteCount("A") == 1) ? "UTF-8" : "UTF-16"); 1458if (_ps.decoder is SafeAsciiDecoder) 1462_ps.appendMode = false; 1474int pos = _ps.charPos; 1475char[] chars = _ps.chars; 1481if (_ps.charsUsed - pos < 4) // minimum "<a/>" 1488_ps.charPos = pos + 1; 1492if (_ps.charsUsed - pos < 2) // minimum characters expected "--" 1499_ps.charPos = pos + 2; 1513if (_ps.charsUsed - pos < 6) 1519_ps.charPos = pos + 6; 1529Throw(_ps.charPos, SR.Xml_InvalidRootData); 1538_ps.charPos = pos; 1570_ps.charPos = pos; 1580else if (pos == _ps.charsUsed || (_v1Compat && chars[pos] == 0x0)) 1597Debug.Assert(pos == _ps.charsUsed && !_ps.isEof); 1612int pos = _ps.charPos; 1733int pos = _ps.charPos; 1734char[] chars = _ps.chars; 1744_ps.charPos = pos + 2; 1748if (_ps.charsUsed - pos < 2) 1755_ps.charPos = pos + 2; 1767if (_ps.charsUsed - pos < 6) 1773_ps.charPos = pos + 6; 1795_ps.charPos = pos + 2; 1799if (pos + 1 == _ps.charsUsed) 1806_ps.charPos = pos + 1; 1815if (pos == _ps.charsUsed) 1833if (_ps.charsUsed - _ps.charPos != 0) 1858int pos = _ps.charPos; 1859char[] chars = _ps.chars; 1862_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 1913else if (pos + 1 < _ps.charsUsed) 1951char[] chars = _ps.chars; 1960_nameTable.Add(chars, _ps.charPos, pos - _ps.charPos)); 1964int startPos = _ps.charPos; 1977_nameTable.Add(chars, _ps.charPos, prefixLen), 1989_ps.charPos = pos; 2003int pos = _ps.charPos; 2004char[] chars = _ps.chars; 2009_ps.charPos = pos + 1; 2015if (pos + 1 == _ps.charsUsed) 2017_ps.charPos = pos; 2025_ps.charPos = pos + 2; 2035Throw(pos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 2067if (_ps.charsUsed - _ps.charPos < prefLen + locLen + 1) 2089while (_ps.charsUsed - _ps.charPos < prefLen + locLen + 1) 2105char[] chars = _ps.chars; 2108if (!chars.AsSpan(_ps.charPos).StartsWith(startTagNode.localName)) 2116int colonPos = _ps.charPos + prefLen; 2117if (!chars.AsSpan(_ps.charPos).StartsWith(startTagNode.prefix) || 2125LineInfo endTagLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); 2187pos = _ps.charPos + nameLen; 2188chars = _ps.chars; 2190if (pos == _ps.charsUsed) 2225else if (pos == _ps.charsUsed && !_ps.isEof) 2239else if (pos == _ps.charsUsed) 2260_ps.charPos = pos + 1; 2294args[3] = new string(_ps.chars, _ps.charPos, endPos - _ps.charPos); 2307int pos = _ps.charPos; 2308char[] chars = _ps.chars; 2334else if (pos + 1 != _ps.charsUsed) 2341_ps.charPos = pos; 2362_ps.charPos = pos + 1; 2370if (pos + 1 == _ps.charsUsed) 2376_ps.charPos = pos + 2; 2387else if (pos == _ps.charsUsed) 2393Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 2397if (pos == _ps.charPos) 2401_ps.charPos = pos; 2404int attrNameLinePos = _ps.LinePos; 2407int attrNameLineNo = _ps.LineNo; 2466chars = _ps.chars; 2469else if (pos + 1 >= _ps.charsUsed) 2476chars = _ps.chars; 2480attr.SetLineInfo(_ps.LineNo, attrNameLinePos); 2483Debug.Assert(attrNameLineNo == _ps.LineNo); 2489_ps.charPos = pos; 2491pos = _ps.charPos; 2502_ps.charPos = pos; 2504pos = _ps.charPos; 2512_ps.charPos = pos; 2515attr.SetLineInfo2(_ps.LineNo, _ps.LinePos); 2529string val = new string(chars, _ps.charPos, pos - _ps.charPos); 2533attr.SetValue(chars, _ps.charPos, pos - _ps.charPos); 2535_ps.charPos = pos; 2540pos = _ps.charPos; 2541chars = _ps.chars; 2569_ps.lineNo -= lineNoDelta; 2572pos = _ps.charPos; 2573chars = _ps.chars; 2606char[] chars = _ps.chars; 2607int attributeBaseEntityId = _ps.entityId; 2610LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); 2623if (pos - _ps.charPos > 0) 2625_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 2626_ps.charPos = pos; 2629if (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; 2657else if (pos + 1 < _ps.charsUsed || _ps.isEof) 2663_ps.charPos = pos; 2678_ps.charPos++; 2692if (pos - _ps.charPos > 0) 2694_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 2696_ps.charPos = pos; 2699int enclosingEntityId = _ps.entityId; 2700LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1); 2713if (_parsingMode == ParsingMode.Full && _ps.entityId == attributeBaseEntityId) 2727_ps.charPos++; 2744valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 2750_ps.charPos++; 2753pos = _ps.charPos; 2774entityChunk.SetNamedNode(XmlNodeType.EntityReference, _ps.entity!.Name); 2782pos = _ps.charPos; 2785pos = _ps.charPos; 2788chars = _ps.chars; 2792if (pos == _ps.charsUsed) 2802if (pos + 1 == _ps.charsUsed) 2813ThrowInvalidChar(chars, _ps.charsUsed, pos); 2823if (_ps.charsUsed - _ps.charPos > 0) 2825if (_ps.chars[_ps.charPos] != (char)0xD) 2830Debug.Assert(_ps.isEof); 2838if (attributeBaseEntityId != _ps.entityId) 2853if (attributeBaseEntityId == _ps.entityId) 2856valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 2861pos = _ps.charPos; 2862chars = _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); 3169Task<(int, int, int, bool)> task = ParseTextAsync(outOrChars, _ps.chars, _ps.charPos, 0, -1, outOrChars); 3268if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 3270if (pos - _ps.charPos > 0) 3286_ps.charPos++; 3291else if (pos + 1 < _ps.charsUsed || _ps.isEof) 3293if (!_ps.eolNormalized) 3318if (_ps.charsUsed - pos < 3 && !_ps.isEof) 3333if (pos == _ps.charsUsed) 3373if (pos > _ps.charPos) 3403if (!XmlCharType.IsWhiteSpace(_ps.chars[pos - 1])) 3409pos = _ps.charPos; 3412chars = _ps.chars; 3425if (pos + 1 == _ps.charsUsed) 3441int offset = pos - _ps.charPos; 3444chars = _ps.chars; 3445pos = _ps.charPos + offset; 3452ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos + offset); 3460if (pos > _ps.charPos) 3469if (_ps.charsUsed - _ps.charPos > 0) 3471if (_ps.chars[_ps.charPos] != (char)0xD && _ps.chars[_ps.charPos] != ']') 3475Debug.Assert(_ps.isEof); 3499pos = _ps.charPos; 3500chars = _ps.chars; 3517int startPos = _ps.charPos; 3519_ps.charPos = pos; 3546_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 3553_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 3684if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || await ZeroEndingStreamAsync(_ps.charPos).ConfigureAwait(false)) 3691_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 3693if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || await ZeroEndingStreamAsync(_ps.charPos).ConfigureAwait(false)) 3705if (XmlCharType.IsCharData(_ps.chars[_ps.charPos])) 3711ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos); 3718Debug.Assert(_ps.chars[_ps.charPos] == '&'); 3719_ps.charPos++; 3721_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 3729Debug.Assert(_ps.chars[_ps.charPos] == '&'); 3731if (_ps.charPos + 1 == _ps.charsUsed) 3740if (_ps.chars[_ps.charPos + 1] == '#') 3775_ps.charPos++; 3776int savedLinePos = _ps.LinePos; 3783Throw(SR.Xml_ErrorParsingEntityName, _ps.LineNo, savedLinePos); 3789if (_ps.chars[endPos] != ';') 3794int entityLinePos = _ps.LinePos; 3795string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 3796_ps.charPos = endPos + 1; 3800_reportedBaseUri = _ps.baseUriStr; 3801_reportedEncoding = _ps.encoding; 3829Throw(SR.Xml_UndeclaredEntity, name, _ps.LineNo, entityStartLinePos); 3842Throw(SR.Xml_UnparsedEntityRef, name, _ps.LineNo, entityStartLinePos); 3847Throw(SR.Xml_ExternalEntityInStandAloneDocument, entity.Name, _ps.LineNo, entityStartLinePos); 3854Throw(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); 3912string target = _nameTable.Add(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); 3918_ps.charPos = nameEndPos; 3933char ch = _ps.chars[_ps.charPos]; 3934Debug.Assert(_ps.charPos < _ps.charsUsed); 3937if (_ps.charsUsed - _ps.charPos < 2) 3941if (ch != '?' || _ps.chars[_ps.charPos + 1] != '>') 3943Throw(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(_ps.chars, _ps.charsUsed, _ps.charPos)); 3964_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 3969piInDtdStringBuilder.Append(_ps.chars, startPos, endPos - startPos); 3999sb.Append(_ps.chars, startPos, endPos - startPos); 4006sb.Append(_ps.chars, startPos, endPos - startPos); 4023if (_ps.charsUsed - _ps.charPos < 2) 4027Throw(_ps.charsUsed, SR.Xml_UnexpectedEOF, "PI"); 4031int pos = _ps.charPos; 4032char[] chars = _ps.chars; 4053Debug.Assert(!_ps.eolNormalized); 4061outStartPos = _ps.charPos; 4062_ps.charPos = pos + 2; 4066else if (pos + 1 == _ps.charsUsed) 4083if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 4086if (pos - _ps.charPos > 0) 4102_ps.charPos++; 4107else if (pos + 1 < _ps.charsUsed || _ps.isEof) 4109if (!_ps.eolNormalized) 4129if (pos == _ps.charsUsed) 4139if (pos + 1 == _ps.charsUsed) 4150ThrowInvalidChar(chars, _ps.charsUsed, pos); 4166outStartPos = _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); 4247if (_ps.charsUsed - _ps.charPos < 3) 4256int pos = _ps.charPos; 4257char[] chars = _ps.chars; 4279Debug.Assert(!_ps.eolNormalized); 4287outStartPos = _ps.charPos; 4288_ps.charPos = pos + 3; 4292else if (pos + 2 == _ps.charsUsed) 4301else if (pos + 1 == _ps.charsUsed) 4321if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 4323if (pos - _ps.charPos > 0) 4339_ps.charPos++; 4344else if (pos + 1 < _ps.charsUsed || _ps.isEof) 4346if (!_ps.eolNormalized) 4366if (pos == _ps.charsUsed) 4374if (pos + 1 == _ps.charsUsed) 4385ThrowInvalidChar(chars, _ps.charsUsed, pos); 4400outStartPos = _ps.charPos; 4402_ps.charPos = pos; 4417while (_ps.charsUsed - _ps.charPos < 8) 4424if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("DOCTYPE")) 4428if (!XmlCharType.IsWhiteSpace(_ps.chars[_ps.charPos + 7])) 4430ThrowExpectingWhitespace(_ps.charPos + 7); 4435Throw(_ps.charPos - 2, SR.Xml_MultipleDTDsProvided); // position just before <!DOCTYPE 4439Throw(_ps.charPos - 2, SR.Xml_DtdAfterRootElement); 4442_ps.charPos += 8; 4449_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 4491_ps.charPos = pos; 4497if (_ps.chars[_ps.charPos] == 'P') 4500while (_ps.charsUsed - _ps.charPos < 6) 4508if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("PUBLIC")) 4512_ps.charPos += 6; 4517ThrowExpectingWhitespace(_ps.charPos); 4526ThrowExpectingWhitespace(_ps.charPos); 4534else if (_ps.chars[_ps.charPos] == 'S') 4537while (_ps.charsUsed - _ps.charPos < 6) 4545if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("SYSTEM")) 4549_ps.charPos += 6; 4554ThrowExpectingWhitespace(_ps.charPos); 4562else if (_ps.chars[_ps.charPos] != '[' && _ps.chars[_ps.charPos] != '>') 4568if (_ps.chars[_ps.charPos] == '[') 4570_ps.charPos++; 4575if (_ps.chars[_ps.charPos] != '>') 4580else if (_ps.chars[_ps.charPos] == '>') 4588_ps.charPos++; 4594char quoteChar = _ps.chars[_ps.charPos]; 4600_ps.charPos++; 4611char[] chars = _ps.chars; 4612int pos = _ps.charPos; 4626_ps.charPos = pos + 1; 4631_ps.charPos = pos; 4644else if (pos + 1 < _ps.charsUsed || _ps.isEof) 4670if (pos + 3 >= _ps.charsUsed && !_ps.isEof) 4685else if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 4695if (pos + 2 >= _ps.charsUsed && !_ps.isEof) 4713if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 4754if (pos == _ps.charsUsed) 4764if (pos + 1 == _ps.charsUsed) 4775ThrowInvalidChar(chars, _ps.charsUsed, pos); 4784if (_ps.charsUsed - _ps.charPos > 0) 4786if (_ps.chars[_ps.charPos] != (char)0xD) 4791Debug.Assert(_ps.isEof); 4798chars = _ps.chars; 4799pos = _ps.charPos; 4805int pos = _ps.charPos; 4807char[] chars = _ps.chars; 4822int tmp1 = pos - _ps.charPos; 4823if (sb != null && !_ps.eolNormalized) 4827sb.Append(chars, _ps.charPos, tmp1); 4830_ps.charPos = pos + 1; 4834else if (pos + 1 < _ps.charsUsed || _ps.isEof) 4836if (!_ps.eolNormalized) 4853if (pos == _ps.charsUsed) 4859int tmp2 = pos - _ps.charPos; 4862sb?.Append(_ps.chars, _ps.charPos, tmp2); 4863_ps.charPos = pos; 4872int tmp3 = pos - _ps.charPos; 4875sb?.Append(_ps.chars, _ps.charPos, tmp3); 4876_ps.charPos = pos; 4882if (_ps.charsUsed - _ps.charPos == 0) 4886if (_ps.chars[_ps.charPos] != (char)0xD) 4891Debug.Assert(_ps.isEof); 4893pos = _ps.charPos; 4894chars = _ps.chars; 4912switch (newPos = ParseNumericCharRefInline(_ps.charPos, expand, internalSubsetBuilder, out charCount, out entityType)) 4920Debug.Assert(_ps.chars[_ps.charPos] == '&'); 4925_ps.charPos = newPos - charCount; 4944switch (newPos = ParseNamedCharRefInline(_ps.charPos, expand, internalSubsetBuilder)) 4954Debug.Assert(_ps.chars[_ps.charPos] == '&'); 4959_ps.charPos = newPos - 1; 4982int pos = _ps.charPos + startOffset; 4985char[] chars = _ps.chars; 4994if (pos + 1 >= _ps.charsUsed) 5007Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 5034colonOffset = pos - _ps.charPos; 5040colonOffset = pos - _ps.charPos; 5046else if (pos == _ps.charsUsed) 5053chars = _ps.chars; 5060colonPos = (colonOffset == -1) ? -1 : _ps.charPos + colonOffset; 5067int offset = pos - _ps.charPos; 5069pos = _ps.charPos + offset; 5088if (_ps.chars[endPos] != ';') 5093string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 5094_ps.charPos = endPos + 1; 5211Debug.Assert(_ps.appendMode); 5212int initialPos = _ps.charPos; 5219_ps.charPos = initialPos; 5225Encoding? enc = _ps.encoding; 5245if (_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); 5413charsRead = _incReadDecoder.Decode(_ps.chars, startPos, endPos - startPos); 5427_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 5429AdjustLineInfo(_ps.chars, startPos - charsRead, startPos, _ps.eolNormalized, ref _incReadLineInfo);