(Release) Buffer size consolidation#1165
Conversation
294560d to
0a50386
Compare
There was a problem hiding this comment.
Pull request overview
This pull request consolidates buffer size constants across the SharpCompress codebase by introducing a centralized Constants.BufferSize field (81920 bytes) and removing scattered magic numbers and previous constants. The PR also simplifies API signatures by removing the bufferSize parameter from archive detection methods across all factory classes and archive types.
Changes:
- Introduced
Constants.BufferSizeconstant to replace hardcoded buffer sizes and the removedReaderOptions.DefaultBufferSizeconstant - Removed
bufferSizeparameters fromIsArchive,IsZipFile, and related detection methods across the factory pattern and archive implementations - Updated all stream copy operations throughout the codebase to consistently use
Constants.BufferSize
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 |
|---|---|
| src/SharpCompress/Common/Constants.cs | Introduces new Constants.BufferSize field (81920 bytes) as centralized buffer size constant |
| src/SharpCompress/Readers/ReaderOptions.cs | Removes DefaultBufferSize constant and updates BufferSize property to use Constants.BufferSize |
| src/SharpCompress/Utility.cs | Removes TEMP_BUFFER_SIZE constant and updates TransferTo, TransferToAsync, and SkipAsync methods to use Constants.BufferSize |
| src/SharpCompress/Factories/*.cs | Removes bufferSize parameter from IsArchive method signatures across all factory implementations |
| src/SharpCompress/Archives/Zip/ZipArchive.cs | Removes bufferSize parameter from IsZipFile and IsZipMulti public methods and updates internal calls |
| src/SharpCompress/Archives/ArchiveFactory.cs | Removes bufferSize parameter from public IsArchive methods |
| src/SharpCompress/Archives/Tar/TarArchive.cs | Updates stream copy operation to use Constants.BufferSize |
| src/SharpCompress/Archives/IArchiveEntryExtensions.cs | Removes local BufferSize constant and updates copy operations to use Constants.BufferSize |
| src/SharpCompress/Readers/AbstractReader.cs | Updates all CopyTo and CopyToAsync calls to use Constants.BufferSize |
| src/SharpCompress/Writers/Zip/ZipWriter.cs | Adds using alias for Constants and updates stream copy to use Constants.BufferSize |
| src/SharpCompress/Writers/GZip/GZipWriter.cs | Updates stream copy operation to use Constants.BufferSize |
| tests/SharpCompress.Test/Mocks/ForwardOnlyStream.cs | Updates constructor to use nullable buffer size parameter with Constants.BufferSize default |
| tests/SharpCompress.Test/packages.lock.json | Removes Mono.Posix.NETStandard package entries (unrelated to buffer size changes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@adamhathcock I've opened a new pull request, #1166, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@adamhathcock I've opened a new pull request, #1167, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: adamhathcock <[email protected]>
Co-authored-by: adamhathcock <[email protected]>
Co-authored-by: adamhathcock <[email protected]>
Add [Obsolete] attribute to ReaderOptions.DefaultBufferSize for backward compatibility
Fix grammatical errors in ArcFactory comment documentation
…ement minor versions
…into adam/buffer-size-consolidation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (21 files)
|
This pull request standardizes and centralizes the default buffer size used for stream operations across the codebase by introducing a new
Constants.BufferSizevalue. It also simplifies method signatures for archive detection by removing thebufferSizeparameter where possible, and updates all relevant usages to reference the new constant. These changes improve consistency, maintainability, and make it easier to change the buffer size globally in the future.Buffer Size Centralization and Usage Updates:
Constants.BufferSize(default 81920 bytes) insrc/SharpCompress/Common/Constants.cs, replacing scattered magic numbers and previous constants for buffer sizes throughout the codebase.IArchiveEntryExtensions.cs,TarArchive.cs,AbstractReader.cs) to useConstants.BufferSizeinstead of hardcoded values or previous constants. [1] [2] [3] [4]API Simplification and Consistency:
bufferSizeparameter fromIsArchiveand related methods in interfaces and factories (e.g.,IFactory,Factory, and all concrete factory classes), simplifying their signatures and usage. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]IsArchive,IsZipFile, and similar methods to match the new signatures, removing the buffer size argument and ensuring consistent use ofConstants.BufferSizeinternally. [1] [2] [3] [4]Legacy Constant Cleanup:
DefaultBufferSizeconstant fromReaderOptionsand updated its usage to referenceConstants.BufferSizeinstead. [1] [2]TEMP_BUFFER_SIZEinUtility.csandBufferSizeinIArchiveEntryExtensions.cs. [1] [2]