From 0778b1308645d8b0fdda6565e36065aa86d14977 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 25 Feb 2026 09:15:40 +0000 Subject: [PATCH] add more docs --- .../IO/SharpCompressStream.Create.cs | 59 ++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/src/SharpCompress/IO/SharpCompressStream.Create.cs b/src/SharpCompress/IO/SharpCompressStream.Create.cs index 8011641b..ad4ca7ab 100644 --- a/src/SharpCompress/IO/SharpCompressStream.Create.cs +++ b/src/SharpCompress/IO/SharpCompressStream.Create.cs @@ -7,13 +7,66 @@ namespace SharpCompress.IO; public partial class SharpCompressStream { /// - /// Creates a SharpCompressStream that acts as a passthrough wrapper. - /// No buffering is performed; CanSeek delegates to the underlying stream. - /// The underlying stream will not be disposed when this stream is disposed. + /// Creates a that acts as a zero-overhead passthrough wrapper + /// around without taking ownership of it. /// + /// + /// + /// This is a thin wrapper: all reads, writes, and seeks are forwarded directly to the underlying + /// stream with no ring-buffer overhead. delegates to the underlying + /// stream's own value. + /// + /// + /// The resulting stream does not support , , + /// or . Call on the passthrough stream to obtain + /// a recording-capable wrapper when needed. + /// + /// + /// Because the stream does not take ownership, the underlying stream is never disposed when + /// this wrapper is disposed. Use this when you need to satisfy an API that expects a + /// without transferring lifetime responsibility. + /// + /// + /// The underlying stream to wrap. Must not be . + /// + /// A passthrough that does not dispose . + /// public static SharpCompressStream CreateNonDisposing(Stream stream) => new(stream, leaveStreamOpen: true, passthrough: true, bufferSize: null); + /// + /// Creates a that supports recording and rewinding over + /// , choosing the most efficient strategy based on the stream's + /// capabilities. + /// + /// + /// Seekable streams — wraps in a thin delegate that calls the underlying + /// stream's native directly. No ring buffer is allocated. + /// stores the current position; seeks + /// back to it. + /// Non-seekable streams (network streams, compressed streams, pipes) — allocates + /// a ring buffer of bytes. All bytes read from the underlying + /// stream are kept in the ring buffer so that can replay them without + /// re-reading the underlying stream. If more bytes have been read than the ring buffer can hold, + /// a subsequent rewind will throw ; increase + /// or to + /// avoid this. + /// Already-wrapped streams — if is already a + /// (or a stack that contains one), it is returned as-is to + /// prevent double-wrapping and double-buffering. + /// + /// The underlying stream to wrap. Must not be . + /// + /// Size in bytes of the ring buffer allocated for non-seekable streams. + /// Defaults to (81 920 bytes) when + /// . Has no effect when is seekable, because + /// no ring buffer is needed in that case. + /// + /// + /// A wrapping . The returned instance + /// owns the stream and will dispose it unless the original source was a non-disposing passthrough + /// wrapper. + /// public static SharpCompressStream Create(Stream stream, int? bufferSize = null) { var rewindableBufferSize = bufferSize ?? Constants.RewindableBufferSize;