Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StreamWriter.cs
Go to the documentation of this file.
4using System.Text;
7
8namespace System.IO;
9
11{
12 public new static readonly StreamWriter Null = new StreamWriter(Stream.Null, UTF8NoBOM, 128, leaveOpen: true);
13
14 private readonly Stream _stream;
15
16 private readonly Encoding _encoding;
17
18 private readonly Encoder _encoder;
19
20 private byte[] _byteBuffer;
21
22 private readonly char[] _charBuffer;
23
24 private int _charPos;
25
26 private int _charLen;
27
28 private bool _autoFlush;
29
31
32 private readonly bool _closable;
33
34 private bool _disposed;
35
37
39
40 public virtual bool AutoFlush
41 {
42 get
43 {
44 return _autoFlush;
45 }
46 set
47 {
50 if (value)
51 {
52 Flush(flushStream: true, flushEncoder: false);
53 }
54 }
55 }
56
57 public virtual Stream BaseStream => _stream;
58
59 public override Encoding Encoding => _encoding;
60
62 {
64 {
66 }
67 }
68
69 [DoesNotReturn]
74
76 : this(stream, UTF8NoBOM, 1024, leaveOpen: false)
77 {
78 }
79
81 : this(stream, encoding, 1024, leaveOpen: false)
82 {
83 }
84
85 public StreamWriter(Stream stream, Encoding encoding, int bufferSize)
86 : this(stream, encoding, bufferSize, leaveOpen: false)
87 {
88 }
89
90 public StreamWriter(Stream stream, Encoding? encoding = null, int bufferSize = -1, bool leaveOpen = false)
91 : base(null)
92 {
93 if (stream == null)
94 {
96 }
97 if (encoding == null)
98 {
99 encoding = UTF8NoBOM;
100 }
101 if (!stream.CanWrite)
102 {
104 }
105 if (bufferSize == -1)
106 {
107 bufferSize = 1024;
108 }
109 else if (bufferSize <= 0)
110 {
112 }
113 _stream = stream;
114 _encoding = encoding;
116 if (bufferSize < 128)
117 {
118 bufferSize = 128;
119 }
120 _charBuffer = new char[bufferSize];
121 _charLen = bufferSize;
122 if (_stream.CanSeek && _stream.Position > 0)
123 {
125 }
126 _closable = !leaveOpen;
127 }
128
129 public StreamWriter(string path)
130 : this(path, append: false, UTF8NoBOM, 1024)
131 {
132 }
133
134 public StreamWriter(string path, bool append)
135 : this(path, append, UTF8NoBOM, 1024)
136 {
137 }
138
139 public StreamWriter(string path, bool append, Encoding encoding)
140 : this(path, append, encoding, 1024)
141 {
142 }
143
144 public StreamWriter(string path, bool append, Encoding encoding, int bufferSize)
145 : this(ValidateArgsAndOpenPath(path, append, encoding, bufferSize), encoding, bufferSize, leaveOpen: false)
146 {
147 }
148
150 : this(path, UTF8NoBOM, options)
151 {
152 }
153
154 public StreamWriter(string path, Encoding encoding, FileStreamOptions options)
155 : this(ValidateArgsAndOpenPath(path, encoding, options), encoding, 4096)
156 {
157 }
158
159 private static Stream ValidateArgsAndOpenPath(string path, Encoding encoding, FileStreamOptions options)
160 {
161 ValidateArgs(path, encoding);
162 if (options == null)
163 {
164 throw new ArgumentNullException("options");
165 }
166 if ((options.Access & FileAccess.Write) == 0)
167 {
168 throw new ArgumentException(SR.Argument_StreamNotWritable, "options");
169 }
170 return new FileStream(path, options);
171 }
172
173 private static Stream ValidateArgsAndOpenPath(string path, bool append, Encoding encoding, int bufferSize)
174 {
175 ValidateArgs(path, encoding);
176 if (bufferSize <= 0)
177 {
179 }
180 return new FileStream(path, append ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.Read, 4096);
181 }
182
183 private static void ValidateArgs(string path, Encoding encoding)
184 {
185 if (path == null)
186 {
187 throw new ArgumentNullException("path");
188 }
189 if (encoding == null)
190 {
191 throw new ArgumentNullException("encoding");
192 }
193 if (path.Length == 0)
194 {
196 }
197 }
198
199 public override void Close()
200 {
201 Dispose(disposing: true);
202 GC.SuppressFinalize(this);
203 }
204
205 protected override void Dispose(bool disposing)
206 {
207 try
208 {
209 if (!_disposed && disposing)
210 {
212 Flush(flushStream: true, flushEncoder: true);
213 }
214 }
215 finally
216 {
217 CloseStreamFromDispose(disposing);
218 }
219 }
220
221 private void CloseStreamFromDispose(bool disposing)
222 {
223 if (!_closable || _disposed)
224 {
225 return;
226 }
227 try
228 {
229 if (disposing)
230 {
231 _stream.Close();
232 }
233 }
234 finally
235 {
236 _disposed = true;
237 _charLen = 0;
238 base.Dispose(disposing);
239 }
240 }
241
242 public override ValueTask DisposeAsync()
243 {
244 if (!(GetType() != typeof(StreamWriter)))
245 {
246 return DisposeAsyncCore();
247 }
248 return base.DisposeAsync();
249 }
250
252 {
253 try
254 {
255 if (!_disposed)
256 {
257 await FlushAsync().ConfigureAwait(continueOnCapturedContext: false);
258 }
259 }
260 finally
261 {
262 CloseStreamFromDispose(disposing: true);
263 }
264 GC.SuppressFinalize(this);
265 }
266
267 public override void Flush()
268 {
270 Flush(flushStream: true, flushEncoder: true);
271 }
272
273 private void Flush(bool flushStream, bool flushEncoder)
274 {
276 if (_charPos == 0 && !flushStream && !flushEncoder)
277 {
278 return;
279 }
281 {
284 if (preamble.Length > 0)
285 {
286 _stream.Write(preamble);
287 }
288 }
289 Span<byte> span = default(Span<byte>);
290 if (_byteBuffer != null)
291 {
292 span = _byteBuffer;
293 }
294 else
295 {
296 int maxByteCount = _encoding.GetMaxByteCount(_charPos);
297 Span<byte> span2 = ((maxByteCount > 1024) ? ((Span<byte>)(_byteBuffer = new byte[_encoding.GetMaxByteCount(_charBuffer.Length)])) : stackalloc byte[1024]);
298 span = span2;
299 }
300 int bytes = _encoder.GetBytes(new ReadOnlySpan<char>(_charBuffer, 0, _charPos), span, flushEncoder);
301 _charPos = 0;
302 if (bytes > 0)
303 {
304 _stream.Write(span.Slice(0, bytes));
305 }
306 if (flushStream)
307 {
308 _stream.Flush();
309 }
310 }
311
312 public override void Write(char value)
313 {
315 if (_charPos == _charLen)
316 {
317 Flush(flushStream: false, flushEncoder: false);
318 }
320 _charPos++;
321 if (_autoFlush)
322 {
323 Flush(flushStream: true, flushEncoder: false);
324 }
325 }
326
327 [MethodImpl(MethodImplOptions.NoInlining)]
328 public override void Write(char[]? buffer)
329 {
330 WriteSpan(buffer, appendNewLine: false);
331 }
332
333 [MethodImpl(MethodImplOptions.NoInlining)]
334 public override void Write(char[] buffer, int index, int count)
335 {
336 if (buffer == null)
337 {
338 throw new ArgumentNullException("buffer", SR.ArgumentNull_Buffer);
339 }
340 if (index < 0)
341 {
343 }
344 if (count < 0)
345 {
347 }
348 if (buffer.Length - index < count)
349 {
351 }
352 WriteSpan(buffer.AsSpan(index, count), appendNewLine: false);
353 }
354
355 [MethodImpl(MethodImplOptions.NoInlining)]
356 public override void Write(ReadOnlySpan<char> buffer)
357 {
358 if (GetType() == typeof(StreamWriter))
359 {
360 WriteSpan(buffer, appendNewLine: false);
361 }
362 else
363 {
364 base.Write(buffer);
365 }
366 }
367
368 [MethodImpl(MethodImplOptions.AggressiveInlining)]
369 private unsafe void WriteSpan(ReadOnlySpan<char> buffer, bool appendNewLine)
370 {
372 if (buffer.Length <= 4 && buffer.Length <= _charLen - _charPos)
373 {
374 for (int i = 0; i < buffer.Length; i++)
375 {
377 }
378 }
379 else
380 {
382 char[] charBuffer = _charBuffer;
383 fixed (char* ptr = &MemoryMarshal.GetReference(buffer))
384 {
385 fixed (char* ptr3 = &charBuffer[0])
386 {
387 char* ptr2 = ptr;
388 int num = buffer.Length;
389 int num2 = _charPos;
390 while (num > 0)
391 {
392 if (num2 == charBuffer.Length)
393 {
394 Flush(flushStream: false, flushEncoder: false);
395 num2 = 0;
396 }
397 int num3 = Math.Min(charBuffer.Length - num2, num);
398 int num4 = num3 * 2;
399 Buffer.MemoryCopy(ptr2, ptr3 + num2, num4, num4);
400 _charPos += num3;
401 num2 += num3;
402 ptr2 += num3;
403 num -= num3;
404 }
405 }
406 }
407 }
408 if (appendNewLine)
409 {
410 char[] coreNewLine = CoreNewLine;
411 for (int j = 0; j < coreNewLine.Length; j++)
412 {
413 if (_charPos == _charLen)
414 {
415 Flush(flushStream: false, flushEncoder: false);
416 }
417 _charBuffer[_charPos] = coreNewLine[j];
418 _charPos++;
419 }
420 }
421 if (_autoFlush)
422 {
423 Flush(flushStream: true, flushEncoder: false);
424 }
425 }
426
427 [MethodImpl(MethodImplOptions.NoInlining)]
428 public override void Write(string? value)
429 {
430 WriteSpan(value, appendNewLine: false);
431 }
432
433 [MethodImpl(MethodImplOptions.NoInlining)]
434 public override void WriteLine(string? value)
435 {
437 WriteSpan(value, appendNewLine: true);
438 }
439
440 [MethodImpl(MethodImplOptions.NoInlining)]
441 public override void WriteLine(ReadOnlySpan<char> buffer)
442 {
443 if (GetType() == typeof(StreamWriter))
444 {
446 WriteSpan(buffer, appendNewLine: true);
447 }
448 else
449 {
450 base.WriteLine(buffer);
451 }
452 }
453
454 private void WriteFormatHelper(string format, ParamsArray args, bool appendNewLine)
455 {
456 StringBuilder stringBuilder = StringBuilderCache.Acquire((format?.Length ?? 0) + args.Length * 8).AppendFormatHelper(null, format, args);
457 StringBuilder.ChunkEnumerator chunks = stringBuilder.GetChunks();
458 bool flag = chunks.MoveNext();
459 while (flag)
460 {
461 ReadOnlySpan<char> span = chunks.Current.Span;
462 flag = chunks.MoveNext();
463 WriteSpan(span, !flag && appendNewLine);
464 }
465 StringBuilderCache.Release(stringBuilder);
466 }
467
468 public override void Write(string format, object? arg0)
469 {
470 if (GetType() == typeof(StreamWriter))
471 {
472 WriteFormatHelper(format, new ParamsArray(arg0), appendNewLine: false);
473 }
474 else
475 {
476 base.Write(format, arg0);
477 }
478 }
479
480 public override void Write(string format, object? arg0, object? arg1)
481 {
482 if (GetType() == typeof(StreamWriter))
483 {
484 WriteFormatHelper(format, new ParamsArray(arg0, arg1), appendNewLine: false);
485 }
486 else
487 {
488 base.Write(format, arg0, arg1);
489 }
490 }
491
492 public override void Write(string format, object? arg0, object? arg1, object? arg2)
493 {
494 if (GetType() == typeof(StreamWriter))
495 {
496 WriteFormatHelper(format, new ParamsArray(arg0, arg1, arg2), appendNewLine: false);
497 }
498 else
499 {
500 base.Write(format, arg0, arg1, arg2);
501 }
502 }
503
504 public override void Write(string format, params object?[] arg)
505 {
506 if (GetType() == typeof(StreamWriter))
507 {
508 if (arg == null)
509 {
510 throw new ArgumentNullException((format == null) ? "format" : "arg");
511 }
512 WriteFormatHelper(format, new ParamsArray(arg), appendNewLine: false);
513 }
514 else
515 {
516 base.Write(format, arg);
517 }
518 }
519
520 public override void WriteLine(string format, object? arg0)
521 {
522 if (GetType() == typeof(StreamWriter))
523 {
524 WriteFormatHelper(format, new ParamsArray(arg0), appendNewLine: true);
525 }
526 else
527 {
528 base.WriteLine(format, arg0);
529 }
530 }
531
532 public override void WriteLine(string format, object? arg0, object? arg1)
533 {
534 if (GetType() == typeof(StreamWriter))
535 {
536 WriteFormatHelper(format, new ParamsArray(arg0, arg1), appendNewLine: true);
537 }
538 else
539 {
540 base.WriteLine(format, arg0, arg1);
541 }
542 }
543
544 public override void WriteLine(string format, object? arg0, object? arg1, object? arg2)
545 {
546 if (GetType() == typeof(StreamWriter))
547 {
548 WriteFormatHelper(format, new ParamsArray(arg0, arg1, arg2), appendNewLine: true);
549 }
550 else
551 {
552 base.WriteLine(format, arg0, arg1, arg2);
553 }
554 }
555
556 public override void WriteLine(string format, params object?[] arg)
557 {
558 if (GetType() == typeof(StreamWriter))
559 {
560 if (arg == null)
561 {
562 throw new ArgumentNullException("arg");
563 }
564 WriteFormatHelper(format, new ParamsArray(arg), appendNewLine: true);
565 }
566 else
567 {
568 base.WriteLine(format, arg);
569 }
570 }
571
572 public override Task WriteAsync(char value)
573 {
574 if (GetType() != typeof(StreamWriter))
575 {
576 return base.WriteAsync(value);
577 }
580 return _asyncWriteTask = WriteAsyncInternal(value, appendNewLine: false);
581 }
582
583 private async Task WriteAsyncInternal(char value, bool appendNewLine)
584 {
585 if (_charPos == _charLen)
586 {
587 await FlushAsyncInternal(flushStream: false, flushEncoder: false).ConfigureAwait(continueOnCapturedContext: false);
588 }
590 if (appendNewLine)
591 {
592 for (int i = 0; i < CoreNewLine.Length; i++)
593 {
594 if (_charPos == _charLen)
595 {
596 await FlushAsyncInternal(flushStream: false, flushEncoder: false).ConfigureAwait(continueOnCapturedContext: false);
597 }
599 }
600 }
601 if (_autoFlush)
602 {
603 await FlushAsyncInternal(flushStream: true, flushEncoder: false).ConfigureAwait(continueOnCapturedContext: false);
604 }
605 }
606
607 public override Task WriteAsync(string? value)
608 {
609 if (GetType() != typeof(StreamWriter))
610 {
611 return base.WriteAsync(value);
612 }
613 if (value != null)
614 {
617 return _asyncWriteTask = WriteAsyncInternal(value.AsMemory(), appendNewLine: false, default(CancellationToken));
618 }
619 return Task.CompletedTask;
620 }
621
622 public override Task WriteAsync(char[] buffer, int index, int count)
623 {
624 if (buffer == null)
625 {
626 throw new ArgumentNullException("buffer", SR.ArgumentNull_Buffer);
627 }
628 if (index < 0)
629 {
631 }
632 if (count < 0)
633 {
635 }
636 if (buffer.Length - index < count)
637 {
639 }
640 if (GetType() != typeof(StreamWriter))
641 {
642 return base.WriteAsync(buffer, index, count);
643 }
646 return _asyncWriteTask = WriteAsyncInternal(new ReadOnlyMemory<char>(buffer, index, count), appendNewLine: false, default(CancellationToken));
647 }
648
650 {
651 if (GetType() != typeof(StreamWriter))
652 {
653 return base.WriteAsync(buffer, cancellationToken);
654 }
657 if (cancellationToken.IsCancellationRequested)
658 {
660 }
661 return _asyncWriteTask = WriteAsyncInternal(buffer, appendNewLine: false, cancellationToken);
662 }
663
665 {
666 int num;
667 for (int copied = 0; copied < source.Length; copied += num)
668 {
669 if (_charPos == _charLen)
670 {
671 await FlushAsyncInternal(flushStream: false, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
672 }
673 num = Math.Min(_charLen - _charPos, source.Length - copied);
674 ReadOnlySpan<char> readOnlySpan = source.Span;
675 readOnlySpan = readOnlySpan.Slice(copied, num);
676 readOnlySpan.CopyTo(new Span<char>(_charBuffer, _charPos, num));
677 _charPos += num;
678 }
679 if (appendNewLine)
680 {
681 for (int i = 0; i < CoreNewLine.Length; i++)
682 {
683 if (_charPos == _charLen)
684 {
685 await FlushAsyncInternal(flushStream: false, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
686 }
688 }
689 }
690 if (_autoFlush)
691 {
692 await FlushAsyncInternal(flushStream: true, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
693 }
694 }
695
696 public override Task WriteLineAsync()
697 {
698 if (GetType() != typeof(StreamWriter))
699 {
700 return base.WriteLineAsync();
701 }
704 return _asyncWriteTask = WriteAsyncInternal(ReadOnlyMemory<char>.Empty, appendNewLine: true, default(CancellationToken));
705 }
706
707 public override Task WriteLineAsync(char value)
708 {
709 if (GetType() != typeof(StreamWriter))
710 {
711 return base.WriteLineAsync(value);
712 }
715 return _asyncWriteTask = WriteAsyncInternal(value, appendNewLine: true);
716 }
717
718 public override Task WriteLineAsync(string? value)
719 {
720 if (value == null)
721 {
722 return WriteLineAsync();
723 }
724 if (GetType() != typeof(StreamWriter))
725 {
726 return base.WriteLineAsync(value);
727 }
730 return _asyncWriteTask = WriteAsyncInternal(value.AsMemory(), appendNewLine: true, default(CancellationToken));
731 }
732
733 public override Task WriteLineAsync(char[] buffer, int index, int count)
734 {
735 if (buffer == null)
736 {
737 throw new ArgumentNullException("buffer", SR.ArgumentNull_Buffer);
738 }
739 if (index < 0)
740 {
742 }
743 if (count < 0)
744 {
746 }
747 if (buffer.Length - index < count)
748 {
750 }
751 if (GetType() != typeof(StreamWriter))
752 {
753 return base.WriteLineAsync(buffer, index, count);
754 }
757 return _asyncWriteTask = WriteAsyncInternal(new ReadOnlyMemory<char>(buffer, index, count), appendNewLine: true, default(CancellationToken));
758 }
759
761 {
762 if (GetType() != typeof(StreamWriter))
763 {
764 return base.WriteLineAsync(buffer, cancellationToken);
765 }
768 if (cancellationToken.IsCancellationRequested)
769 {
771 }
772 return _asyncWriteTask = WriteAsyncInternal(buffer, appendNewLine: true, cancellationToken);
773 }
774
775 public override Task FlushAsync()
776 {
777 if (GetType() != typeof(StreamWriter))
778 {
779 return base.FlushAsync();
780 }
783 return _asyncWriteTask = FlushAsyncInternal(flushStream: true, flushEncoder: true);
784 }
785
786 private Task FlushAsyncInternal(bool flushStream, bool flushEncoder, CancellationToken cancellationToken = default(CancellationToken))
787 {
788 if (cancellationToken.IsCancellationRequested)
789 {
791 }
792 if (_charPos == 0 && !flushStream && !flushEncoder)
793 {
794 return Task.CompletedTask;
795 }
796 return Core(flushStream, flushEncoder, cancellationToken);
797 async Task Core(bool flushStream, bool flushEncoder, CancellationToken cancellationToken)
798 {
800 {
802 byte[] preamble = _encoding.GetPreamble();
803 if (preamble.Length != 0)
804 {
805 await _stream.WriteAsync(new ReadOnlyMemory<byte>(preamble), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
806 }
807 }
808 byte[] array = _byteBuffer ?? (_byteBuffer = new byte[_encoding.GetMaxByteCount(_charBuffer.Length)]);
809 int bytes = _encoder.GetBytes(new ReadOnlySpan<char>(_charBuffer, 0, _charPos), array, flushEncoder);
810 _charPos = 0;
811 if (bytes > 0)
812 {
813 await _stream.WriteAsync(new ReadOnlyMemory<byte>(array, 0, bytes), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
814 }
815 if (flushStream)
816 {
817 await _stream.FlushAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
818 }
819 }
820 }
821
822 private void ThrowIfDisposed()
823 {
824 if (_disposed)
825 {
826 ThrowObjectDisposedException();
827 }
828 void ThrowObjectDisposedException()
829 {
831 }
832 }
833}
static unsafe void MemoryCopy(void *source, void *destination, long destinationSizeInBytes, long sourceBytesToCopy)
Definition Buffer.cs:195
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
static readonly Encoding UTF8NoBOM
override void WriteLine(string format, params object?[] arg)
void Flush(bool flushStream, bool flushEncoder)
StreamWriter(string path, Encoding encoding, FileStreamOptions options)
override void Dispose(bool disposing)
override void Write(char[] buffer, int index, int count)
override void WriteLine(string? value)
override void Write(string? value)
static void ValidateArgs(string path, Encoding encoding)
override void WriteLine(string format, object? arg0, object? arg1)
readonly bool _closable
readonly Stream _stream
StreamWriter(Stream stream, Encoding? encoding=null, int bufferSize=-1, bool leaveOpen=false)
static Encoding UTF8NoBOM
static void ThrowAsyncIOInProgress()
readonly Encoder _encoder
StreamWriter(string path, bool append, Encoding encoding)
readonly char[] _charBuffer
override Task WriteAsync(ReadOnlyMemory< char > buffer, CancellationToken cancellationToken=default(CancellationToken))
readonly Encoding _encoding
override void Flush()
override void Close()
static Stream ValidateArgsAndOpenPath(string path, bool append, Encoding encoding, int bufferSize)
override Task WriteLineAsync(string? value)
StreamWriter(string path, FileStreamOptions options)
override ValueTask DisposeAsync()
override Task WriteAsync(char value)
async Task WriteAsyncInternal(char value, bool appendNewLine)
static new readonly StreamWriter Null
override Task WriteLineAsync(char[] buffer, int index, int count)
override void Write(ReadOnlySpan< char > buffer)
override void Write(char[]? buffer)
override Task WriteAsync(char[] buffer, int index, int count)
unsafe void WriteSpan(ReadOnlySpan< char > buffer, bool appendNewLine)
override void Write(string format, object? arg0)
static Stream ValidateArgsAndOpenPath(string path, Encoding encoding, FileStreamOptions options)
StreamWriter(Stream stream)
override void Write(string format, object? arg0, object? arg1, object? arg2)
virtual Stream BaseStream
override Task FlushAsync()
async ValueTask DisposeAsyncCore()
override Task WriteLineAsync(ReadOnlyMemory< char > buffer, CancellationToken cancellationToken=default(CancellationToken))
override void Write(char value)
override void Write(string format, object? arg0, object? arg1)
override Task WriteAsync(string? value)
override void Write(string format, params object?[] arg)
StreamWriter(Stream stream, Encoding encoding)
StreamWriter(string path, bool append)
StreamWriter(string path, bool append, Encoding encoding, int bufferSize)
StreamWriter(string path)
StreamWriter(Stream stream, Encoding encoding, int bufferSize)
override Task WriteLineAsync()
async Task WriteAsyncInternal(ReadOnlyMemory< char > source, bool appendNewLine, CancellationToken cancellationToken)
override void WriteLine(string format, object? arg0, object? arg1, object? arg2)
override void WriteLine(string format, object? arg0)
void WriteFormatHelper(string format, ParamsArray args, bool appendNewLine)
override void WriteLine(ReadOnlySpan< char > buffer)
Task FlushAsyncInternal(bool flushStream, bool flushEncoder, CancellationToken cancellationToken=default(CancellationToken))
override Task WriteLineAsync(char value)
void CloseStreamFromDispose(bool disposing)
Task FlushAsync()
Definition Stream.cs:669
virtual void Close()
Definition Stream.cs:644
Task WriteAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:914
void Write(byte[] buffer, int offset, int count)
static readonly Stream Null
Definition Stream.cs:488
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static string ArgumentOutOfRange_NeedPosNum
Definition SR.cs:20
static string ObjectDisposed_WriterClosed
Definition SR.cs:1746
static string Argument_StreamNotWritable
Definition SR.cs:878
static string Argument_EmptyPath
Definition SR.cs:38
static string ArgumentNull_Buffer
Definition SR.cs:22
static string Argument_InvalidOffLen
Definition SR.cs:22
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
static string InvalidOperation_AsyncIOInProgress
Definition SR.cs:1398
Definition SR.cs:7
int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
virtual ReadOnlySpan< byte > Preamble
Definition Encoding.cs:347
int GetMaxByteCount(int charCount)
virtual Encoder GetEncoder()
Definition Encoding.cs:1009
virtual byte[] GetPreamble()
Definition Encoding.cs:689
static void Release(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
ChunkEnumerator GetChunks()
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363
static Task CompletedTask
Definition Task.cs:1120
static void ThrowArgumentNullException(string name)
unsafe ReadOnlySpan< T > Span
void CopyTo(Span< T > destination)
ReadOnlySpan< T > Slice(int start)
Span< T > Slice(int start)
Definition Span.cs:271