1 write to _ps
System.Private.Xml (1)
System\Xml\Core\XmlTextReaderImpl.cs (1)
8128_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; 5106Debug.Assert(_ps.chars != null); 5107char[] chars = _ps.chars; 5108int attributeBaseEntityId = _ps.entityId; 5110LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos); 5123if (pos - _ps.charPos > 0) 5125_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 5126_ps.charPos = pos; 5129if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId) 5144_ps.charPos++; 5153_stringBuilder.Append(_ps.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA 5154_ps.charPos = pos; 5157else if (pos + 1 < _ps.charsUsed || _ps.isEof) 5163_ps.charPos = pos; 5178_ps.charPos++; 5192if (pos - _ps.charPos > 0) 5194_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 5196_ps.charPos = pos; 5198int enclosingEntityId = _ps.entityId; 5199LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1); 5207if (_parsingMode == ParsingMode.Full && _ps.entityId == attributeBaseEntityId) 5221_ps.charPos++; 5238valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 5244_ps.charPos++; 5247pos = _ps.charPos; 5268Debug.Assert(_ps.entity != null); 5269entityChunk.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name); 5277pos = _ps.charPos; 5280pos = _ps.charPos; 5283chars = _ps.chars; 5287if (pos == _ps.charsUsed) 5297if (pos + 1 == _ps.charsUsed) 5308ThrowInvalidChar(chars, _ps.charsUsed, pos); 5318if (_ps.charsUsed - _ps.charPos > 0) 5320if (_ps.chars[_ps.charPos] != (char)0xD) 5325Debug.Assert(_ps.isEof); 5333if (attributeBaseEntityId != _ps.entityId) 5347if (attributeBaseEntityId == _ps.entityId) 5350valueChunkLineInfo.Set(_ps.LineNo, _ps.LinePos); 5355pos = _ps.charPos; 5356chars = _ps.chars; 5373_ps.charPos = pos + 1; 5411_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5429Debug.Assert(_ps.chars != null); 5430_curNode.SetValueNode(nodeType, _ps.chars, startPos, endPos - startPos); 5443_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5449_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5474Debug.Assert(_ps.chars != null); 5475_curNode.SetValueNode(XmlNodeType.Text, _ps.chars, startPos, endPos - startPos); 5484_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5491_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5549Debug.Assert(_ps.chars != null); 5550char[] chars = _ps.chars; 5551int pos = _ps.charPos; 5579if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 5581if (pos - _ps.charPos > 0) 5597_ps.charPos++; 5602else if (pos + 1 < _ps.charsUsed || _ps.isEof) 5604if (!_ps.eolNormalized) 5642if (pos > _ps.charPos) 5663if (!XmlCharType.IsWhiteSpace(_ps.chars[pos - 1])) 5669pos = _ps.charPos; 5672chars = _ps.chars; 5676if (_ps.charsUsed - pos < 3 && !_ps.isEof) 5689if (pos == _ps.charsUsed) 5699if (pos + 1 == _ps.charsUsed) 5711int offset = pos - _ps.charPos; 5714pos = _ps.charPos + offset; 5719ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos + offset); 5726if (pos > _ps.charPos) 5733if (_ps.charsUsed - _ps.charPos > 0) 5735if (_ps.chars[_ps.charPos] != (char)0xD && _ps.chars[_ps.charPos] != ']') 5739Debug.Assert(_ps.isEof); 5758pos = _ps.charPos; 5759chars = _ps.chars; 5771startPos = _ps.charPos; 5773_ps.charPos = pos; 5792_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5794_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 5914Debug.Assert(_ps.chars != null); 5918if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || ZeroEndingStream(_ps.charPos)) 5925_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5927if (_ps.chars[_ps.charPos] == '<' || _ps.charsUsed - _ps.charPos == 0 || ZeroEndingStream(_ps.charPos)) 5939if (XmlCharType.IsCharData(_ps.chars[_ps.charPos])) 5945ThrowInvalidChar(_ps.chars, _ps.charsUsed, _ps.charPos); 5952Debug.Assert(_ps.chars != null); 5953Debug.Assert(_ps.chars[_ps.charPos] == '&'); 5954_ps.charPos++; 5956_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 5962Debug.Assert(_ps.chars != null); 5963Debug.Assert(_ps.chars[_ps.charPos] == '&'); 5965if (_ps.charPos + 1 == _ps.charsUsed) 5974if (_ps.chars[_ps.charPos + 1] == '#') 6002_ps.charPos++; 6003int savedLinePos = _ps.LinePos; 6010Throw(SR.Xml_ErrorParsingEntityName, _ps.LineNo, savedLinePos); 6015if (_ps.chars[endPos] != ';') 6020int entityLinePos = _ps.LinePos; 6021string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 6022_ps.charPos = endPos + 1; 6026_reportedBaseUri = _ps.baseUriStr; 6027_reportedEncoding = _ps.encoding; 6053Throw(SR.Xml_UndeclaredEntity, name, _ps.LineNo, entityStartLinePos); 6067Throw(SR.Xml_UnparsedEntityRef, name, _ps.LineNo, entityStartLinePos); 6072Throw(SR.Xml_ExternalEntityInStandAloneDocument, entity.Name, _ps.LineNo, entityStartLinePos); 6079Throw(SR.Xml_ExternalEntityInAttValue, name, _ps.LineNo, entityStartLinePos); 6093_curNode.entityId = _ps.entityId; 6101_curNode.entityId = _ps.entityId; 6114_curNode.entityId = _ps.entityId; 6136if (_ps.entityResolvedManually) 6142if (_ps.entityId != _nodes[_index].entityId) 6148_lastEntity = _ps.entity; // save last entity for the EndEntity node 6157if (_ps.entityId != _nodes[_index].entityId) 6165_reportedEncoding = _ps.encoding; 6166_reportedBaseUri = _ps.baseUriStr; 6175_reportedEncoding = _ps.encoding; 6176_reportedBaseUri = _ps.baseUriStr; 6181_curNode.lineInfo.Set(_ps.lineNo, _ps.LinePos - 1); 6210_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6217Debug.Assert(_ps.chars != null); 6218string target = _nameTable.Add(_ps.chars, _ps.charPos, nameEndPos - _ps.charPos); 6224_ps.charPos = nameEndPos; 6239char ch = _ps.chars[_ps.charPos]; 6240Debug.Assert(_ps.charPos < _ps.charsUsed); 6243if (_ps.charsUsed - _ps.charPos < 2) 6247if (ch != '?' || _ps.chars[_ps.charPos + 1] != '>') 6249Throw(SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(_ps.chars, _ps.charsUsed, _ps.charPos)); 6265_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 6270piInDtdStringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6293sb.Append(_ps.chars, startPos, endPos - startPos); 6295sb.Append(_ps.chars, startPos, endPos - startPos); 6310if (_ps.charsUsed - _ps.charPos < 2) 6314Throw(_ps.charsUsed, SR.Xml_UnexpectedEOF, "PI"); 6318Debug.Assert(_ps.chars != null); 6319int pos = _ps.charPos; 6320char[] chars = _ps.chars; 6340Debug.Assert(!_ps.eolNormalized); 6348outStartPos = _ps.charPos; 6349_ps.charPos = pos + 2; 6352else if (pos + 1 == _ps.charsUsed) 6369if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 6372if (pos - _ps.charPos > 0) 6388_ps.charPos++; 6393else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6395if (!_ps.eolNormalized) 6415if (pos == _ps.charsUsed) 6425if (pos + 1 == _ps.charsUsed) 6436ThrowInvalidChar(chars, _ps.charsUsed, pos); 6452outStartPos = _ps.charPos; 6453_ps.charPos = pos; 6486_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6490Debug.Assert(_ps.chars != null); 6491_curNode.SetValueNode(type, _ps.chars, startPos, endPos - startPos); 6497_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6500_stringBuilder.Append(_ps.chars, startPos, endPos - startPos); 6514if (_ps.charsUsed - _ps.charPos < 3) 6523Debug.Assert(_ps.chars != null); 6524int pos = _ps.charPos; 6525char[] chars = _ps.chars; 6547Debug.Assert(!_ps.eolNormalized); 6555outStartPos = _ps.charPos; 6556_ps.charPos = pos + 3; 6559else if (pos + 2 == _ps.charsUsed) 6568else if (pos + 1 == _ps.charsUsed) 6588if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full) 6590if (pos - _ps.charPos > 0) 6606_ps.charPos++; 6611else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6613if (!_ps.eolNormalized) 6633if (pos == _ps.charsUsed) 6641if (pos + 1 == _ps.charsUsed) 6652ThrowInvalidChar(chars, _ps.charsUsed, pos); 6667outStartPos = _ps.charPos; 6669_ps.charPos = pos; 6683while (_ps.charsUsed - _ps.charPos < 8) 6691if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("DOCTYPE")) 6696Debug.Assert(_ps.chars != null); 6697if (!XmlCharType.IsWhiteSpace(_ps.chars[_ps.charPos + 7])) 6699ThrowExpectingWhitespace(_ps.charPos + 7); 6704Throw(_ps.charPos - 2, SR.Xml_MultipleDTDsProvided); // position just before <!DOCTYPE 6709Throw(_ps.charPos - 2, SR.Xml_DtdAfterRootElement); 6712_ps.charPos += 8; 6718_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 6755_ps.charPos = pos; 6761Debug.Assert(_ps.chars != null); 6762if (_ps.chars[_ps.charPos] == 'P') 6765while (_ps.charsUsed - _ps.charPos < 6) 6773if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("PUBLIC")) 6777_ps.charPos += 6; 6782ThrowExpectingWhitespace(_ps.charPos); 6791ThrowExpectingWhitespace(_ps.charPos); 6799else if (_ps.chars[_ps.charPos] == 'S') 6802while (_ps.charsUsed - _ps.charPos < 6) 6810if (!_ps.chars.AsSpan(_ps.charPos).StartsWith("SYSTEM")) 6814_ps.charPos += 6; 6819ThrowExpectingWhitespace(_ps.charPos); 6827else if (_ps.chars[_ps.charPos] != '[' && _ps.chars[_ps.charPos] != '>') 6833if (_ps.chars[_ps.charPos] == '[') 6835_ps.charPos++; 6840if (_ps.chars[_ps.charPos] != '>') 6845else if (_ps.chars[_ps.charPos] == '>') 6853_ps.charPos++; 6858Debug.Assert(_ps.chars != null); 6860char quoteChar = _ps.chars[_ps.charPos]; 6866_ps.charPos++; 6877Debug.Assert(_ps.chars != null); 6878char[] chars = _ps.chars; 6879int pos = _ps.charPos; 6893_ps.charPos = pos + 1; 6898_ps.charPos = pos; 6911else if (pos + 1 < _ps.charsUsed || _ps.isEof) 6937if (pos + 3 >= _ps.charsUsed && !_ps.isEof) 6952else if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 6962if (pos + 2 >= _ps.charsUsed && !_ps.isEof) 6980if (pos + 1 >= _ps.charsUsed && !_ps.isEof) 7021if (pos == _ps.charsUsed) 7031if (pos + 1 == _ps.charsUsed) 7042ThrowInvalidChar(chars, _ps.charsUsed, pos); 7051if (_ps.charsUsed - _ps.charPos > 0) 7053if (_ps.chars[_ps.charPos] != (char)0xD) 7058Debug.Assert(_ps.isEof); 7065chars = _ps.chars; 7066pos = _ps.charPos; 7072int pos = _ps.charPos; 7074Debug.Assert(_ps.chars != null); 7075char[] chars = _ps.chars; 7090int tmp1 = pos - _ps.charPos; 7091if (sb != null && !_ps.eolNormalized) 7095sb.Append(chars, _ps.charPos, tmp1); 7098_ps.charPos = pos + 1; 7102else if (pos + 1 < _ps.charsUsed || _ps.isEof) 7104if (!_ps.eolNormalized) 7121if (pos == _ps.charsUsed) 7127int tmp2 = pos - _ps.charPos; 7130sb?.Append(_ps.chars, _ps.charPos, tmp2); 7131_ps.charPos = pos; 7140int tmp3 = pos - _ps.charPos; 7143sb?.Append(_ps.chars, _ps.charPos, tmp3); 7144_ps.charPos = pos; 7150if (_ps.charsUsed - _ps.charPos == 0) 7154if (_ps.chars[_ps.charPos] != (char)0xD) 7159Debug.Assert(_ps.isEof); 7161pos = _ps.charPos; 7162chars = _ps.chars; 7168Debug.Assert(_ps.chars != null); 7169Debug.Assert(_ps.chars[startPos] == '&'); 7170if (_ps.chars[startPos + 1] == '#') 7193switch (newPos = ParseNumericCharRefInline(_ps.charPos, expand, internalSubsetBuilder, out charCount, out entityType)) 7202Debug.Assert(_ps.chars != null); 7203Debug.Assert(_ps.chars[_ps.charPos] == '&'); 7208_ps.charPos = newPos - charCount; 7223Debug.Assert(_ps.chars != null); 7224Debug.Assert(_ps.chars[startPos] == '&' && _ps.chars[startPos + 1] == '#'); 7232chars = _ps.chars; 7254else if (pos < _ps.charsUsed) 7274_ps.charPos = pos; 7283if (pos == _ps.charsUsed) 7301Throw((_ps.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(ch, '\0')); 7306internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos + 1); 7327Throw((_ps.chars[startPos + 2] == 'x') ? startPos + 3 : startPos + 2, SR.Xml_InvalidCharacter, XmlException.BuildCharExceptionArgs(high, low)); 7334internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos + 1); 7354switch (newPos = ParseNamedCharRefInline(_ps.charPos, expand, internalSubsetBuilder)) 7365Debug.Assert(_ps.chars != null); 7366Debug.Assert(_ps.chars[_ps.charPos] == '&'); 7371_ps.charPos = newPos - 1; 7386Debug.Assert(startPos < _ps.charsUsed); 7387Debug.Assert(_ps.chars != null); 7388Debug.Assert(_ps.chars[startPos] == '&'); 7389Debug.Assert(_ps.chars[startPos + 1] != '#'); 7392char[] chars = _ps.chars; 7403if (_ps.charsUsed - pos >= 3) 7420if (_ps.charsUsed - pos >= 4) 7435else if (pos < _ps.charsUsed) 7442if (_ps.charsUsed - pos >= 5) 7459if (_ps.charsUsed - pos >= 3) 7475if (_ps.charsUsed - pos >= 3) 7500internalSubsetBuilder?.Append(_ps.chars, _ps.charPos, pos - _ps.charPos); 7501_ps.chars[pos - 1] = ch; 7519int pos = _ps.charPos + startOffset; 7522Debug.Assert(_ps.chars != null); 7523char[] chars = _ps.chars; 7532if (pos + 1 >= _ps.charsUsed) 7542Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos)); 7569colonOffset = pos - _ps.charPos; 7575colonOffset = pos - _ps.charPos; 7581else if (pos == _ps.charsUsed) 7585Debug.Assert(_ps.chars != null); 7586chars = _ps.chars; 7593colonPos = (colonOffset == -1) ? -1 : _ps.charPos + colonOffset; 7599int offset = pos - _ps.charPos; 7601pos = _ps.charPos + offset; 7618Debug.Assert(_ps.chars != null); 7621if (_ps.chars[endPos] != ';') 7626string entityName = _nameTable.Add(_ps.chars, _ps.charPos, endPos - _ps.charPos); 7627_ps.charPos = endPos + 1; 7671Debug.Assert(_ps.chars != null); 7676string localName = _nameTable.Add(_ps.chars, _ps.charPos, endNamePos - _ps.charPos); 7682int startPos = _ps.charPos; 7684if (prefixLen == _lastPrefix.Length && _ps.chars.AsSpan(_ps.charPos).StartsWith(_lastPrefix)) 7686return AddAttribute(_nameTable.Add(_ps.chars, colonPos + 1, endNamePos - colonPos - 1), 7692string prefix = _nameTable.Add(_ps.chars, startPos, prefixLen); 7694return AddAttribute(_nameTable.Add(_ps.chars, colonPos + 1, endNamePos - colonPos - 1), 7753_ps.lineNo++; 7754_ps.lineStartPos = pos - 1; 7759Debug.Assert(_ps.isEof); 7762_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 8012Debug.Assert(_ps.appendMode); 8013int initialPos = _ps.charPos; 8021_ps.charPos = initialPos; 8028Encoding? enc = _ps.encoding; 8045Encoding? enc = _ps.encoding; 8053_ps.lineNo = entity.LineNumber; 8054_ps.lineStartPos = -entity.LinePosition - 1; 8056_ps.eolNormalized = true; 8063_ps.stream?.Dispose(); 8067_curNode.entityId = _ps.entityId; 8083_ps.entity = entity; 8084_ps.entityId = _nextEntityId++; 8098if (_ps.entity != null) 8100_currentEntities!.Remove(_ps.entity); 8118_parsingStatesStack[_parsingStatesStackTop] = _ps; 8120_ps.Clear(); 8127_ps.Close(true); 8139_incReadLeftStartPos = _ps.charPos; 8140_incReadLeftEndPos = _ps.charPos; 8141_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 8184Debug.Assert(_ps.chars != null); 8194count = _incReadDecoder.Decode(_ps.chars, _incReadLeftStartPos, charsLeft); 8233Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 2).StartsWith("?>")); 8234_ps.charPos -= 2; 8241Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 3).StartsWith("-->")); 8242_ps.charPos -= 3; 8249Debug.Assert(_ps.chars.AsSpan(_ps.charPos - 3).StartsWith("]]>")); 8250_ps.charPos -= 3; 8278char[] chars = _ps.chars; 8279startPos = _ps.charPos; 8284_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 8325else if (pos + 1 < _ps.charsUsed) 8342if (_ps.charsUsed - pos < 2) 8355if (_ps.charsUsed - pos < 4) 8365if (_ps.charsUsed - pos < 9) 8383Debug.Assert(_ps.charPos - pos == 0); 8384Debug.Assert(_ps.charPos - startPos == 0); 8389if ((endPos - _ps.charPos - 2) == checkName.Length && chars.AsSpan(_ps.charPos + 2).StartsWith(checkName) && 8390(_ps.chars[endPos] == '>' || XmlCharType.IsWhiteSpace(_ps.chars[endPos]))) 8398_ps.charPos = endPos; 8399if (XmlCharType.IsWhiteSpace(_ps.chars[endPos])) 8403if (_ps.chars[_ps.charPos] != '>') 8407_ps.charPos++; 8415startPos = _ps.charPos; 8416chars = _ps.chars; 8423Debug.Assert(_ps.charPos - pos == 0); 8424Debug.Assert(_ps.charPos - startPos == 0); 8428if (endPos - _ps.charPos - 1 == _curNode.localName.Length && _ps.chars.AsSpan(_ps.charPos + 1).StartsWith(_curNode.localName) && 8429(_ps.chars[endPos] == '>' || _ps.chars[endPos] == '/' || XmlCharType.IsWhiteSpace(_ps.chars[endPos]))) 8437startPos = _ps.charPos; 8438chars = _ps.chars; 8447if (_ps.charsUsed - pos < 2) 8486if (pos == _ps.charsUsed) 8503_ps.charPos = pos; 8513count = _incReadDecoder.Decode(_ps.chars, startPos, charsParsed); 8551ParseAttributeValueSlow(_ps.charPos, ' ', _curNode); // The quote char is intentionally empty (space) because we need to parse ' and " into the attribute value 8574Debug.Assert(_ps.chars != null); 8576char[] chars = _ps.chars; 8577int pos = _ps.charPos; 8580_curNode.SetLineInfo(_ps.LineNo, _ps.LinePos); 8600Debug.Assert(_ps.eolNormalized, "Entity replacement text for attribute values should be EOL-normalized!"); 8623if (pos - _ps.charPos > 0) 8625_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8628_ps.charPos = pos; 8636chars = _ps.chars; 8637if (_normalize && XmlCharType.IsWhiteSpace(chars[_ps.charPos]) && pos - _ps.charPos == 1) 8639chars[_ps.charPos] = (char)0x20; // CDATA normalization of character references in entities 8646_ps.charPos++; 8658chars = _ps.chars; 8662if (pos == _ps.charsUsed) 8672if (pos + 1 == _ps.charsUsed) 8685ThrowInvalidChar(chars, _ps.charsUsed, pos); 8691if (pos - _ps.charPos > 0) 8693_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8694_ps.charPos = pos; 8718pos = _ps.charPos; 8719chars = _ps.chars; 8723if (pos - _ps.charPos > 0) 8725_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos); 8726_ps.charPos = pos; 8758_ps.charPos = pos; 8782_ps.charPos = pos; 8788if (_ps.charPos == _ps.charsUsed) 8793Debug.Assert(_ps.chars != null); 8795if (XmlCharType.IsNCNameSingleChar(_ps.chars[_ps.charPos])) 8797int pos = _ps.charPos + 1; 8798while (XmlCharType.IsNCNameSingleChar(_ps.chars[pos])) 8802return new string(_ps.chars, _ps.charPos, pos - _ps.charPos); 8806Debug.Assert(_ps.charPos < _ps.charsUsed); 8807return new string(_ps.chars, _ps.charPos, 1); 8871Debug.Assert(_ps.chars != null); 8873if (_v1Compat && pos == _ps.charsUsed - 1 && _ps.chars[pos] == (char)0 && ReadData() == 0 && _ps.isStreamEof) 8875_ps.charsUsed--; 9381_curNode.AdjustLineInfo(_readValueOffset, _ps.eolNormalized, ref _incReadLineInfo); 9395Debug.Assert(_ps.chars != null); 9406_incReadLineInfo.Set(_ps.LineNo, _ps.LinePos); 9411charsRead = _incReadDecoder.Decode(_ps.chars, startPos, endPos - startPos); 9426_curNode.SetValue(_ps.chars, startPos, endPos - startPos); 9428AdjustLineInfo(_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);