Conversation
Code Review SummaryStatus: 7 Issues Already Identified | Recommendation: Address existing comments before merge Overview
DetailsThe PR introduces significant API changes separating Already Documented Issues (7 total):
Architecture AssessmentThe separation of concerns is sound:
The implementation correctly:
Files Reviewed (19 files)
|
There was a problem hiding this comment.
Pull request overview
This PR reintroduces ExtractionOptions and updates SharpCompress extraction APIs/docs to separate open-time settings (ReaderOptions) from extract-time behavior (ExtractionOptions), addressing confusion introduced in recent releases.
Changes:
- Added new
ExtractionOptionstype and routed extract-time decisions (overwrite, path handling, timestamps, symlinks) through it. - Updated extraction extension methods (sync/async) across readers/archives to accept
ExtractionOptions? options = null. - Updated tests and documentation to reflect the new extraction option flow and presets.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/SharpCompress.Test/Zip/ZipArchiveAsyncTests.cs | Updates call site to pass progress by name after signature change. |
| tests/SharpCompress.Test/WriterTests.cs | Updates async extraction call to use named cancellationToken. |
| tests/SharpCompress.Test/ReaderTests.cs | Updates async extraction call to use named cancellationToken. |
| tests/SharpCompress.Test/OptionsUsabilityTests.cs | Moves preset expectations from ReaderOptions to ExtractionOptions. |
| tests/SharpCompress.Test/GZip/AsyncTests.cs | Updates async extraction call to use named cancellationToken. |
| tests/SharpCompress.Test/ExtractionTests.cs | Passes explicit ExtractionOptions into extraction tests for new API. |
| src/SharpCompress/Readers/ReaderOptionsExtensions.cs | Removes extraction-related fluent helpers from ReaderOptions. |
| src/SharpCompress/Readers/ReaderOptions.cs | Removes extraction-related properties/presets from ReaderOptions. |
| src/SharpCompress/Readers/IReaderExtensions.cs | Adds ExtractionOptions? to sync reader extraction helpers. |
| src/SharpCompress/Readers/IAsyncReaderExtensions.cs | Adds ExtractionOptions? to async reader extraction helpers. |
| src/SharpCompress/Common/Options/IReaderOptions.cs | Removes IExtractionOptions from IReaderOptions inheritance. |
| src/SharpCompress/Common/IEntry.Extensions.cs | Preserves timestamps/attributes based on ExtractionOptions instead of entry options. |
| src/SharpCompress/Common/ExtractionOptions.cs | Introduces new ExtractionOptions record with presets + symlink handler. |
| src/SharpCompress/Common/ExtractionMethods.cs | Routes sync extraction decisions through ExtractionOptions. |
| src/SharpCompress/Common/ExtractionMethods.Async.cs | Routes async extraction decisions through ExtractionOptions. |
| src/SharpCompress/Archives/IAsyncArchiveExtensions.cs | Adds ExtractionOptions? to async archive WriteToDirectoryAsync flow. |
| src/SharpCompress/Archives/IArchiveExtensions.cs | Adds ExtractionOptions? to sync archive WriteToDirectory flow. |
| src/SharpCompress/Archives/IArchiveEntryExtensions.cs | Adds ExtractionOptions? to entry extract helpers. |
| src/SharpCompress/Archives/IArchive.cs | Updates docs to clarify ReaderOptions are open-time only. |
| src/SharpCompress/Archives/ArchiveFactory.cs | Updates convenience WriteToDirectory API to use ExtractionOptions. |
| docs/USAGE.md | Updates examples to pass ExtractionOptions at extract time. |
| docs/PERFORMANCE.md | Updates examples for named cancellation token usage. |
| docs/ARCHITECTURE.md | Documents ExtractionOptions as a distinct extract-time type. |
| docs/API.md | Updates presets/options matrix and extraction examples for the new model. |
Comments suppressed due to low confidence (1)
src/SharpCompress/Readers/ReaderOptionsExtensions.cs:100
- The fluent
ReaderOptionshelpers for extraction behavior (WithOverwrite,WithExtractFullPath, etc.) were removed, but there isn't an equivalent fluent helper surface forExtractionOptions(e.g.,ExtractionOptionsExtensions.WithOverwrite(...)). If the project intends to keep the fluent pattern for options, consider adding correspondingWith*extension methods forExtractionOptionsto replace the removed API.
/// <summary>
/// Creates a copy with the specified rewindable buffer size.
/// </summary>
public static ReaderOptions WithRewindableBufferSize(
this ReaderOptions options,
int? rewindableBufferSize
) => options with { RewindableBufferSize = rewindableBufferSize };
/// <summary>
/// Creates a copy with the specified compression provider registry.
/// </summary>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="providers"/> is null.</exception>
public static ReaderOptions WithProviders(
this ReaderOptions options,
CompressionProviderRegistry providers
)
{
_ = providers ?? throw new ArgumentNullException(nameof(providers));
return options with { Providers = providers };
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- `Tomlyn` required switching from `Toml.ToModel()` to `TomlSerializer.Deserialze<TomlTable>()` - `SharpCompress` removed `ReaderOptions`, which have been replaced with `ExtractionOptions` ([Reference](adamhathcock/sharpcompress#1239))
- `Tomlyn` required switching from `Toml.ToModel()` to `TomlSerializer.Deserialze<TomlTable>()` - `SharpCompress` removed `ReaderOptions`, which have been replaced with `ExtractionOptions` ([Reference](adamhathcock/sharpcompress#1239))
- `Tomlyn` required switching from `Toml.ToModel()` to `TomlSerializer.Deserialze<TomlTable>()` - `SharpCompress` removed `ReaderOptions`, which have been replaced with `ExtractionOptions` ([Reference](adamhathcock/sharpcompress#1239))
Put back ExtractionOptions. Was always dubious I could get rid of them anyway: #1228
This pull request introduces a significant improvement to the extraction API by separating open-time and extract-time behaviors, clarifying usage of
ReaderOptionsand introducingExtractionOptionsfor extraction-specific settings. The documentation and codebase have been updated for consistency, and method signatures now explicitly accept extraction options, providing users with more granular control over extraction behavior.API and Extraction Behavior Refactoring
Introduced
ExtractionOptionsas a distinct type for extract-time settings (such as overwrite, path handling, timestamps, and attributes), and updated method signatures throughout the codebase to acceptExtractionOptions?instead ofReaderOptions?for extraction operations. This change affects methods likeWriteToDirectoryandWriteToFileinIArchiveEntryExtensions,IArchiveExtensions, andIAsyncArchiveExtensions, ensuring clearer separation of concerns between archive opening and extraction behavior. [1] [2] [3] [4] [5] [6] [7]Updated all relevant documentation (
API.md,USAGE.md,PERFORMANCE.md,ARCHITECTURE.md) to reflect the new extraction options paradigm, clarifying when to useReaderOptions(for open-time settings like password and encoding) versusExtractionOptions(for extract-time settings like overwrite and path preservation). Examples and option matrices were revised for accuracy and clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Default Option Changes and Consistency
ReaderOptions.ForOwnedFiletoReaderOptions.ForFilePaththroughout the codebase, ensuring consistent and more intuitive behavior for users opening archives via file paths. [1] [2] [3] [4]Minor Improvements and Fixes
Updated method calls to use named parameters for
cancellationTokenin async extraction examples for clarity and consistency in documentation. [1] [2] [3] [4] [5] [6]Updated interface and documentation comments to reflect the separation of open-time and extract-time options, improving maintainability and reducing confusion.
These changes make the extraction API more robust, intuitive, and easier to use, while also improving documentation and code clarity.