Skip to content

Expose SharpCompressStream to allow ringbuffer to be used on non-seekable streams#1220

Merged
adamhathcock merged 3 commits intomasterfrom
adam/issue-936
Feb 14, 2026
Merged

Expose SharpCompressStream to allow ringbuffer to be used on non-seekable streams#1220
adamhathcock merged 3 commits intomasterfrom
adam/issue-936

Conversation

@adamhathcock
Copy link
Owner

fixes #936

This pull request makes the SharpCompressStream class public and adds new tests to ensure that XZStream can handle non-seekable streams, including both non-empty and empty cases. These changes improve the public API's usability and test coverage for edge cases involving stream types.

Public API changes

  • Changed the access modifier of SharpCompressStream and its partial class declarations from internal to public, making it accessible outside its assembly. [1] [2] [3]

Test improvements for non-seekable streams

  • Added tests in XZStreamTests and XZStreamAsyncTests to verify that XZStream can correctly read from non-seekable streams, both for regular and empty compressed data. [1] [2]
  • Included necessary using directives in test files to support the new tests. [1] [2]

@adamhathcock adamhathcock marked this pull request as ready for review February 14, 2026 10:24
Copilot AI review requested due to automatic review settings February 14, 2026 10:24
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 14, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
docs/API.md 494 Buffered example uses the direct constructor, which doesn't enable ring buffering.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
Files Reviewed (5 files)
  • docs/API.md - 1 issue
  • src/SharpCompress/IO/SharpCompressStream.Async.cs
  • src/SharpCompress/IO/SharpCompressStream.Create.cs
  • src/SharpCompress/IO/SharpCompressStream.cs
  • tests/SharpCompress.Test/Xz/XZStreamAsyncTests.cs
  • tests/SharpCompress.Test/Xz/XZStreamTests.cs

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 pull request addresses issue #936 by making SharpCompressStream public, which allows users to wrap non-seekable streams (like HTTP response streams) with a ring buffer before passing them to decompressors like XZStream. The PR includes comprehensive test coverage for both synchronous and asynchronous scenarios with empty and non-empty compressed data.

Changes:

  • Made SharpCompressStream class public to enable wrapping of non-seekable streams
  • Added test coverage for XZStream with non-seekable streams in both sync and async scenarios

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/SharpCompress/IO/SharpCompressStream.cs Changed class visibility from internal to public
src/SharpCompress/IO/SharpCompressStream.Create.cs Changed partial class visibility from internal to public
src/SharpCompress/IO/SharpCompressStream.Async.cs Changed partial class visibility from internal to public
tests/SharpCompress.Test/Xz/XZStreamTests.cs Added tests for non-seekable stream scenarios (regular and empty)
tests/SharpCompress.Test/Xz/XZStreamAsyncTests.cs Added async tests for non-seekable stream scenarios (regular and empty)

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 14, 2026 10:35
@adamhathcock adamhathcock merged commit b7f41ac into master Feb 14, 2026
9 checks passed
@adamhathcock adamhathcock deleted the adam/issue-936 branch February 14, 2026 10:35

```csharp
// Wrap a non-seekable stream with buffering
using (var bufferedStream = new SharpCompressStream(rawStream))
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: Buffered example uses the direct constructor, which doesn't enable ring buffering

SharpCompressStream(Stream) doesn't allocate a ring buffer, so the example won't provide the buffering described in the text. Use SharpCompressStream.Create(...) (or pass a buffer size) to ensure the wrapper is configured for non-seekable buffering.

Suggested change
using (var bufferedStream = new SharpCompressStream(rawStream))
using (var bufferedStream = SharpCompressStream.Create(rawStream))

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

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


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

/// (such as passthrough vs buffered mode and buffer size) for the underlying
/// stream and usage scenario.
/// </remarks>
public partial class SharpCompressStream : Stream, IStreamStack
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The public constructor at line 55 (public SharpCompressStream(Stream stream)) lacks XML documentation. According to the class-level remarks, users should prefer using SharpCompressStream.Create(...) methods instead of directly constructing instances. Consider adding XML documentation that explains this constructor's purpose and recommends using the Create methods for most use cases.

Copilot uses AI. Check for mistakes.

```csharp
// Wrap a non-seekable stream with buffering
using (var bufferedStream = new SharpCompressStream(rawStream))
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The documentation example uses the SharpCompressStream constructor directly (new SharpCompressStream(rawStream)), but according to the class-level documentation in SharpCompressStream.cs, users should prefer using the static SharpCompressStream.Create(...) methods. Consider updating this example to use SharpCompressStream.Create(rawStream) instead to align with the recommended usage pattern and ensure proper configuration (seekable vs buffered mode) is selected automatically.

Suggested change
using (var bufferedStream = new SharpCompressStream(rawStream))
using (var bufferedStream = SharpCompressStream.Create(rawStream))

Copilot uses AI. Check for mistakes.
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.

XZStream doesn't support non-seekable streams

2 participants