Some API clean up from GPT 5.4#1243
Conversation
There was a problem hiding this comment.
Pull request overview
This PR performs a broad API cleanup and consistency pass across the SharpCompress library. It standardizes naming conventions, improves type safety, adds async archive detection APIs, and fixes writer factory stream ownership behavior.
Changes:
- Renames properties (
ArchiveType→Type,WriterType→Type), parameters (path→filePath), and interface (IWriteableArchiveFactory→IWritableArchiveFactory); changes multi-archive API signatures fromIEnumerable<T>toIReadOnlyList<T>and async writer return types fromIAsyncWritertoValueTask<IAsyncWriter>. - Adds new
IsArchiveAsyncand promotesFindFactoryAsyncto public API onArchiveFactory, with corresponding tests in the newArchiveFactoryTests.cs. - Standardizes
ReaderOptionsdefaults to useForFilePath/ForExternalStreampresets and fixes writer factories to setLeaveStreamOpen = falsewhen opening fromFileInfo.
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/SharpCompress/Archives/ArchiveFactory.cs | Add IsArchiveAsync methods, rename path→filePath, IEnumerable→IReadOnlyList |
| src/SharpCompress/Archives/ArchiveFactory.Async.cs | Make FindFactoryAsync public, rename params, IEnumerable→IReadOnlyList |
| src/SharpCompress/Archives/IWriteableArchiveFactory.cs | Rename interface to IWritableArchiveFactory, fix XML doc |
| src/SharpCompress/Archives/IMultiArchiveOpenable.cs | IEnumerable→IReadOnlyList for multi-archive params |
| src/SharpCompress/Archives/IArchiveOpenable.cs | Rename path→filePath |
| src/SharpCompress/Archives/IWritableArchiveExtensions.cs | Bug: changes new FileInfo(path) to new FileInfo(filePath) — regression |
| src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs | Bug: same regression as sync version |
| src/SharpCompress/Archives/Zip/ZipArchive.Factory.cs | IEnumerable→IReadOnlyList, use ReaderOptions.ForExternalStream |
| src/SharpCompress/Archives/Tar/TarArchive.Factory.cs | IEnumerable→IReadOnlyList, use presets, rename params |
| src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs | IEnumerable→IReadOnlyList, use presets, rename params |
| src/SharpCompress/Archives/Rar/RarArchive.Factory.cs | IEnumerable→IReadOnlyList, use presets, rename params |
| src/SharpCompress/Archives/GZip/GZipArchive.Factory.cs | IEnumerable→IReadOnlyList, use presets, rename params |
| src/SharpCompress/Readers/IReader.cs | ArchiveType→Type |
| src/SharpCompress/Readers/IAsyncReader.cs | ArchiveType→Type |
| src/SharpCompress/Readers/AbstractReader.cs | ArchiveType→Type |
| src/SharpCompress/Readers/IReaderOpenable.cs | Rename path→filePath |
| src/SharpCompress/Readers/IReaderFactory.cs | Add default for cancellationToken param |
| src/SharpCompress/Readers/*/Factory.cs | Rename params, add ReaderOptions.ForFilePath defaults |
| src/SharpCompress/Writers/IWriter.cs | WriterType→Type |
| src/SharpCompress/Writers/AbstractWriter.cs | WriterType→Type |
| src/SharpCompress/Writers/IWriterOpenable.cs | Change return type to ValueTask<IAsyncWriter>, add CancellationToken |
| src/SharpCompress/Writers/*/Factory.cs | Update async return types, add LeaveStreamOpen = false for FileInfo overloads |
| src/SharpCompress/Factories/ZipFactory.cs | IWriteableArchiveFactory→IWritableArchiveFactory |
| src/SharpCompress/Factories/TarFactory.cs | Same rename |
| src/SharpCompress/Factories/GZipFactory.cs | Same rename |
| tests/SharpCompress.Test/ArchiveFactoryTests.cs | New tests for FindFactoryAsync and IsArchiveAsync |
| tests/SharpCompress.Test/ArchiveTests.cs | Add .ToArray() for IReadOnlyList compatibility |
| tests/SharpCompress.Test/Rar/*.cs | Update for .ToArray() and Type rename |
| tests/SharpCompress.Test/Tar/*.cs | Update for Type rename |
| tests/SharpCompress.Test/Lzw/*.cs | Update for Type rename |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review SummaryStatus: 9 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (47 files)
Key Concerns1. Regression Bugs (CRITICAL severity impact)The Fix required: Revert lines 25 and 27 to use 2. Breaking API ChangesThis PR introduces multiple breaking API changes:
These should be documented in the changelog with migration guidance. 3. New Public APIThe Recommendation: Address the regression bugs before merging, as they will cause runtime failures. The breaking API changes should be acceptable if properly documented. |
|
@adamhathcock I've opened a new pull request, #1244, to work on those changes. Once the pull request is ready, I'll request review from you. |
…atch interface name Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Rename IWriteableArchiveFactory.cs to IWritableArchiveFactory.cs
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated [SharpCompress](https://github.com/adamhathcock/sharpcompress) from 0.48.1 to 0.49.1. <details> <summary>Release notes</summary> _Sourced from [SharpCompress's releases](https://github.com/adamhathcock/sharpcompress/releases)._ ## 0.49.1 ## What's Changed * Close writable entry streams during async archive disposal by @Copilot in adamhathcock/sharpcompress#1338 * Restore `WriteToDirectoryAsync` progress callbacks for solid 7z archives by @Copilot in adamhathcock/sharpcompress#1340 * Try to fix global.json to avoid churn in locks by @adamhathcock in adamhathcock/sharpcompress#1341 * Fix tar archive enumeration after fully reading entry streams by @adamhathcock in adamhathcock/sharpcompress#1342 **Full Changelog**: adamhathcock/sharpcompress@0.49.0...0.49.1 ## 0.49.0 This should contain a lot of write async fixes and some breaking API changes that fix previous broke `net48` usage ## What's Changed * Rename IWriteableArchiveFactory.cs to IWritableArchiveFactory.cs by @Copilot in adamhathcock/sharpcompress#1244 * Some API clean up from GPT 5.4 by @adamhathcock in adamhathcock/sharpcompress#1243 * Release to master by @adamhathcock in adamhathcock/sharpcompress#1267 * Fix three BLAKE2sp correctness bugs and eliminate allocations in hot path by @coderb in adamhathcock/sharpcompress#1266 * Corrected async examples. by @dlemstra in adamhathcock/sharpcompress#1277 * Fix setting invalid access time fails extraction by @aromaa in adamhathcock/sharpcompress#1279 * Fix incorrect code examples in docs for sync/async usage by @Copilot in adamhathcock/sharpcompress#1280 * Replace APPNOTE.TXT contents with reference link note by @puk06 in adamhathcock/sharpcompress#1286 * Release to Master by @adamhathcock in adamhathcock/sharpcompress#1274 * update docs for tar gap analysis and XZ usage by @adamhathcock in adamhathcock/sharpcompress#1288 * Add a PooledMemoryStream to avoid allocating by @adamhathcock in adamhathcock/sharpcompress#1275 * fix: Change LeaveStreamOpen default from true to false by @puk06 in adamhathcock/sharpcompress#1293 * Fix usage of ReaderOptions and pre-defined values by @adamhathcock in adamhathcock/sharpcompress#1295 * Enforce seekable, readable and writable on streams by @adamhathcock in adamhathcock/sharpcompress#1297 * Add ArchiveInformation record for consolidated archive detection and capability inspection by @Copilot in adamhathcock/sharpcompress#1299 * merge release to master by @adamhathcock in adamhathcock/sharpcompress#1314 * Some clean up and test clean up by @adamhathcock in adamhathcock/sharpcompress#1321 * Finish Write Async by @adamhathcock in adamhathcock/sharpcompress#1323 * More complete Tar implementation: USTAR, PAX, etc. by @adamhathcock in adamhathcock/sharpcompress#1289 * Add Polysharp and adjustments that do not break legacy frameworks by @adamhathcock in adamhathcock/sharpcompress#1330 * Fix null `IVolume.FileName` for single-volume file-based archives by @Copilot in adamhathcock/sharpcompress#1333 * Add skills by @adamhathcock in adamhathcock/sharpcompress#1332 * add AOT smoke and missing tests by @adamhathcock in adamhathcock/sharpcompress#1334 ## New Contributors * @dlemstra made their first contribution in adamhathcock/sharpcompress#1277 * @aromaa made their first contribution in adamhathcock/sharpcompress#1279 * @puk06 made their first contribution in adamhathcock/sharpcompress#1286 **Full Changelog**: adamhathcock/sharpcompress@0.48.1...0.49.0 ## 0.49.0-beta.140 ## What's Changed * Add Polysharp and adjustments that do not break legacy frameworks by @adamhathcock in adamhathcock/sharpcompress#1330 **Full Changelog**: adamhathcock/sharpcompress@0.49.0-beta.136...0.49.0-beta.140 ## 0.49.0-beta.136 ## What's Changed * Rename IWriteableArchiveFactory.cs to IWritableArchiveFactory.cs by @Copilot in adamhathcock/sharpcompress#1244 * Some API clean up from GPT 5.4 by @adamhathcock in adamhathcock/sharpcompress#1243 * Release to master by @adamhathcock in adamhathcock/sharpcompress#1267 * Fix three BLAKE2sp correctness bugs and eliminate allocations in hot path by @coderb in adamhathcock/sharpcompress#1266 * Corrected async examples. by @dlemstra in adamhathcock/sharpcompress#1277 * Fix setting invalid access time fails extraction by @aromaa in adamhathcock/sharpcompress#1279 * Fix incorrect code examples in docs for sync/async usage by @Copilot in adamhathcock/sharpcompress#1280 * Replace APPNOTE.TXT contents with reference link note by @puk06 in adamhathcock/sharpcompress#1286 * Release to Master by @adamhathcock in adamhathcock/sharpcompress#1274 * update docs for tar gap analysis and XZ usage by @adamhathcock in adamhathcock/sharpcompress#1288 * Add a PooledMemoryStream to avoid allocating by @adamhathcock in adamhathcock/sharpcompress#1275 * fix: Change LeaveStreamOpen default from true to false by @puk06 in adamhathcock/sharpcompress#1293 * Fix usage of ReaderOptions and pre-defined values by @adamhathcock in adamhathcock/sharpcompress#1295 * Enforce seekable, readable and writable on streams by @adamhathcock in adamhathcock/sharpcompress#1297 * Add ArchiveInformation record for consolidated archive detection and capability inspection by @Copilot in adamhathcock/sharpcompress#1299 * merge release to master by @adamhathcock in adamhathcock/sharpcompress#1314 * Some clean up and test clean up by @adamhathcock in adamhathcock/sharpcompress#1321 * Finish Write Async by @adamhathcock in adamhathcock/sharpcompress#1323 * More complete Tar implementation: USTAR, PAX, etc. by @adamhathcock in adamhathcock/sharpcompress#1289 ## New Contributors * @dlemstra made their first contribution in adamhathcock/sharpcompress#1277 * @aromaa made their first contribution in adamhathcock/sharpcompress#1279 * @puk06 made their first contribution in adamhathcock/sharpcompress#1286 **Full Changelog**: adamhathcock/sharpcompress@0.48.1...0.49.0-beta1 Commits viewable in [compare view](adamhathcock/sharpcompress@0.48.1...0.49.1). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This pull request refactors and improves the archive factory and related classes to be more consistent, modern, and type-safe. The main changes include standardizing parameter naming, replacing
IEnumerablewithIReadOnlyListfor multi-file and multi-stream APIs, introducing async archive detection, and improving options handling. Several interface and type names are also corrected for clarity.Key changes:
API Consistency and Type Safety
IEnumerable<FileInfo>/IEnumerable<Stream>toIReadOnlyList<FileInfo>/IReadOnlyList<Stream>inArchiveFactory,GZipArchive,RarArchive, and related interfaces to ensure immutability and direct access by index. [1] [2] [3] [4] [5] [6] [7]IWriteableArchiveFactorytoIWritableArchiveFactoryfor correct spelling and clarity. [1] [2] [3]Parameter Naming and Option Handling
pathtofilePathacross all relevant methods for clarity and consistency. [1] [2] [3] [4] [5] [6]ReaderOptionsusage to useReaderOptions.ForFilePathorReaderOptions.ForExternalStreamas appropriate, improving option handling and reducing unnecessary allocations. [1] [2] [3] [4] [5] [6]Async and Utility Enhancements
IsArchiveAsync(string filePath, ...)andIsArchiveAsync(Stream, ...)to allow asynchronous archive type checking.FindFactoryAsync<T>(FileInfo, ...)andFindFactoryAsync<T>(Stream, ...)public and added optional cancellation tokens for consistency with other async APIs. [1] [2]Bug Fixes
AddAllFromDirectoryandAddAllFromDirectoryAsyncwhereFileInfowas incorrectly constructed with the directory path instead of the file path. [1] [2]Minor Improvements
usingdirectives forSystem.ThreadingandSystem.Threading.TasksinArchiveFactory.cs.These changes make the archive APIs more robust, easier to use, and consistent across both sync and async scenarios.