private int WritePropertyNameIndented(ReadOnlySpan <char> escapedPropertyName) { int idx = 0; if (_currentDepth < 0) { if (_buffer.Length <= idx) { GrowAndEnsure(); } _buffer[idx++] = JsonConstants.ListSeparator; } if (_tokenType != JsonTokenType.None) { WriteNewLine(ref idx); } int indent = Indentation; while (true) { bool result = JsonWriterHelper.TryWriteIndentation(_buffer.Slice(idx), indent, out int bytesWritten); idx += bytesWritten; if (result) { break; } indent -= bytesWritten; AdvanceAndGrow(ref idx); } if (_buffer.Length <= idx) { AdvanceAndGrow(ref idx); } _buffer[idx++] = JsonConstants.Quote; ReadOnlySpan <byte> byteSpan = MemoryMarshal.AsBytes(escapedPropertyName); int partialConsumed = 0; while (true) { OperationStatus status = JsonWriterHelper.ToUtf8(byteSpan.Slice(partialConsumed), _buffer.Slice(idx), out int consumed, out int written); idx += written; if (status == OperationStatus.Done) { break; } partialConsumed += consumed; AdvanceAndGrow(ref idx); } if (_buffer.Length <= idx) { AdvanceAndGrow(ref idx); } _buffer[idx++] = JsonConstants.Quote; if (_buffer.Length <= idx) { AdvanceAndGrow(ref idx); } _buffer[idx++] = JsonConstants.KeyValueSeperator; if (_buffer.Length <= idx) { AdvanceAndGrow(ref idx); } _buffer[idx++] = JsonConstants.Space; return(idx); }