Skip to content

Make SharpCompressStream public#1233

Merged
adamhathcock merged 5 commits intoreleasefrom
adam/expose-sc-stream
Feb 25, 2026
Merged

Make SharpCompressStream public#1233
adamhathcock merged 5 commits intoreleasefrom
adam/expose-sc-stream

Conversation

@adamhathcock
Copy link
Owner

This pull request primarily makes the SharpCompressStream class and its related partial classes public, updates documentation for stream creation methods, and adjusts visibility of certain members. These changes improve API accessibility and clarity, and refine internal stream management.

API accessibility improvements:

  • Changed SharpCompressStream and its partial classes from internal to public, allowing them to be used outside the assembly. (src/SharpCompress/IO/SharpCompressStream.cs, src/SharpCompress/IO/SharpCompressStream.Create.cs, src/SharpCompress/IO/SharpCompressStream.Async.cs) [1] [2] [3]

Documentation and usability enhancements:

  • Expanded and clarified XML documentation for the Create and CreateNonDisposing factory methods in SharpCompressStream, detailing passthrough and recording behaviors, ownership semantics, and buffer usage. (src/SharpCompress/IO/SharpCompressStream.Create.cs)

Internal API refinements:

  • Changed the ThrowOnDispose property in SharpCompressStream from public to internal, restricting its usage to within the assembly. (src/SharpCompress/IO/SharpCompressStream.cs)
  • Removed the override of ThrowOnDispose in SeekableSharpCompressStream, simplifying stream disposal handling. (src/SharpCompress/IO/SeekableSharpCompressStream.cs)

Development tooling:

  • Added a VS Code setting for auto-approving the dotnet csharpier tool in terminal tasks. (.vscode/settings.json)

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 25, 2026

Code Review Summary

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 6
Issue Details (click to expand)

CRITICAL

File Line Issue
src/SharpCompress/IO/SharpCompressStream.cs 41 Breaking API change - ThrowOnDispose changed from public virtual to internal, breaking existing code

SUGGESTION

File Line Issue
.vscode/settings.json 31 Committing chat.tools.terminal.autoApprove enables automatic command approval without user interaction
src/SharpCompress/IO/SharpCompressStream.Create.cs 35 CreateNonDisposing(Stream stream) documents that stream must not be null but lacks runtime validation
src/SharpCompress/IO/SharpCompressStream.Create.cs 53 The XML docs claim that for non-seekable streams a ring buffer is always allocated, but the buffer size parameter is ignored when the stream is seekable
src/SharpCompress/IO/SharpCompressStream.Create.cs 53 @copilot open a new pull request to apply changes based on this review
src/SharpCompress/IO/SharpCompressStream.Create.cs 56 The "Already-wrapped streams" remark says an existing SharpCompressStream is returned as-is, but the implementation returns different types depending on the underlying stream
src/SharpCompress/IO/SharpCompressStream.Create.cs 72 Create(Stream stream, int? bufferSize = null) also lacks a null check despite claiming the parameter must not be null
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
tests/SharpCompress.Test/ArchiveTests.cs 60, 67, 72, 157, 160, 635, 638 Code uses stream.ThrowOnDispose = false; which will fail to compile after the API change makes ThrowOnDispose internal
Files Reviewed (6 files)
  • .vscode/settings.json - 1 issue
  • src/SharpCompress/IO/SeekableSharpCompressStream.cs - 1 issue
  • src/SharpCompress/IO/SharpCompressStream.Async.cs - No issues
  • src/SharpCompress/IO/SharpCompressStream.Create.cs - 5 issues
  • src/SharpCompress/IO/SharpCompressStream.cs - 1 issue
  • tests/SharpCompress.Test/packages.lock.json - No issues (generated file)

Fix these issues in Kilo Cloud

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes SharpCompressStream as a public API type (including its partial class files), improves the XML documentation around stream creation/wrapping behavior, and makes small related visibility/tooling adjustments.

Changes:

  • Made SharpCompressStream and its partial definitions public.
  • Expanded XML docs for SharpCompressStream.Create(...) / CreateNonDisposing(...) to better describe passthrough vs rewindable behavior and ownership semantics.
  • Restricted ThrowOnDispose visibility and adjusted SeekableSharpCompressStream accordingly; updated repo VS Code settings.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/SharpCompress/IO/SharpCompressStream.cs Makes the core stream wrapper public and narrows ThrowOnDispose visibility.
src/SharpCompress/IO/SharpCompressStream.Create.cs Makes factory helpers public and significantly expands XML documentation for stream creation behavior.
src/SharpCompress/IO/SharpCompressStream.Async.cs Makes async partial definition public to match the now-public type.
src/SharpCompress/IO/SeekableSharpCompressStream.cs Removes the ThrowOnDispose override now that the base member is no longer public/virtual.
.vscode/settings.json Adds a VS Code terminal tool auto-approval setting for dotnet csharpier.
Comments suppressed due to low confidence (1)

src/SharpCompress/IO/SharpCompressStream.cs:46

  • Now that SharpCompressStream is public, the public constructor should validate the input stream. Currently this.stream = stream; allows null, which will lead to a NullReferenceException later; prefer throwing ArgumentNullException immediately to make the public API safer and consistent with other stream wrappers in this repo.
    internal bool ThrowOnDispose { get; set; }

    public SharpCompressStream(Stream stream)
    {
        this.stream = stream;
        _logicalPosition = 0;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to +53
/// <para><b>Non-seekable streams</b> (network streams, compressed streams, pipes) — allocates
/// a ring buffer of <paramref name="bufferSize"/> bytes. All bytes read from the underlying
/// stream are kept in the ring buffer so that <see cref="Rewind()"/> 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 <see cref="InvalidOperationException"/>; increase
/// <paramref name="bufferSize"/> or <see cref="Common.Constants.RewindableBufferSize"/> to
/// avoid this.</para>
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML docs claim that for non-seekable streams a ring buffer of bufferSize bytes is allocated (defaulting to Constants.RewindableBufferSize). However, the current implementation can end up allocating the buffer later via StartRecording() using Constants.BufferSize, and if bufferSize is null the non-seekable path may not allocate a ring buffer up-front. Please align docs and implementation so the actual buffer size/behavior matches what is documented (ideally honoring Constants.RewindableBufferSize when bufferSize is null).

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Feb 25, 2026

@adamhathcock I've opened a new pull request, #1234, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 25, 2026 10:41
…reate() and StartRecording()

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Fix SharpCompressStream.Create() buffer size misalignment for non-seekable streams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants