[PR #1165] [MERGED] (Release) Buffer size consolidation #1602

Open
opened 2026-01-29 22:21:21 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1165
Author: @adamhathcock
Created: 1/27/2026
Status: Merged
Merged: 1/27/2026
Merged by: @adamhathcock

Base: releaseHead: adam/buffer-size-consolidation


📝 Commits (10+)

  • 0a50386 Using Constants class differently
  • d52facd Remove change
  • 014bbc3 Initial plan
  • a114155 Initial plan
  • 6c86632 Fix grammatical errors in ArcFactory comments
  • 53f12d7 Add [Obsolete] attribute to ReaderOptions.DefaultBufferSize
  • 010a38b Add clarifying comment about buffer size value difference
  • d11f6ae Merge pull request #1166 from adamhathcock/copilot/sub-pr-1165
  • 3c88c7f Merge pull request #1167 from adamhathcock/copilot/sub-pr-1165-again
  • d6156f0 release branch builds increment patch versions and master builds increment minor versions

📊 Changes

25 files changed (+112 additions, -134 deletions)

View changed files

📝 build/Program.cs (+39 -3)
📝 src/SharpCompress/Archives/ArchiveFactory.cs (+3 -11)
📝 src/SharpCompress/Archives/AutoArchiveFactory.cs (+2 -5)
📝 src/SharpCompress/Archives/IArchiveEntryExtensions.cs (+2 -4)
📝 src/SharpCompress/Archives/Tar/TarArchive.cs (+1 -1)
📝 src/SharpCompress/Archives/Zip/ZipArchive.cs (+10 -25)
src/SharpCompress/Common/Constants.cs (+10 -0)
📝 src/SharpCompress/Factories/AceFactory.cs (+1 -5)
📝 src/SharpCompress/Factories/ArcFactory.cs (+1 -5)
📝 src/SharpCompress/Factories/ArjFactory.cs (+1 -5)
📝 src/SharpCompress/Factories/Factory.cs (+2 -6)
📝 src/SharpCompress/Factories/GZipFactory.cs (+2 -5)
📝 src/SharpCompress/Factories/IFactory.cs (+1 -5)
📝 src/SharpCompress/Factories/RarFactory.cs (+2 -5)
📝 src/SharpCompress/Factories/SevenZipFactory.cs (+2 -5)
📝 src/SharpCompress/Factories/TarFactory.cs (+2 -5)
📝 src/SharpCompress/Factories/ZStandardFactory.cs (+2 -5)
📝 src/SharpCompress/Factories/ZipFactory.cs (+4 -8)
📝 src/SharpCompress/Readers/AbstractReader.cs (+7 -3)
📝 src/SharpCompress/Readers/ReaderOptions.cs (+9 -1)

...and 5 more files

📄 Description

This pull request standardizes and centralizes the default buffer size used for stream operations across the codebase by introducing a new Constants.BufferSize value. It also simplifies method signatures for archive detection by removing the bufferSize parameter 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:

  • Introduced Constants.BufferSize (default 81920 bytes) in src/SharpCompress/Common/Constants.cs, replacing scattered magic numbers and previous constants for buffer sizes throughout the codebase.
  • Updated all stream copying operations (e.g., in IArchiveEntryExtensions.cs, TarArchive.cs, AbstractReader.cs) to use Constants.BufferSize instead of hardcoded values or previous constants. [1] [2] [3] [4]

API Simplification and Consistency:

  • Removed the bufferSize parameter from IsArchive and 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]
  • Updated all usages of IsArchive, IsZipFile, and similar methods to match the new signatures, removing the buffer size argument and ensuring consistent use of Constants.BufferSize internally. [1] [2] [3] [4]

Legacy Constant Cleanup:

  • Removed the obsolete DefaultBufferSize constant from ReaderOptions and updated its usage to reference Constants.BufferSize instead. [1] [2]
  • Removed other redundant buffer size constants and magic numbers, such as TEMP_BUFFER_SIZE in Utility.cs and BufferSize in IArchiveEntryExtensions.cs. [1] [2]

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1165 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 1/27/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `release` ← **Head:** `adam/buffer-size-consolidation` --- ### 📝 Commits (10+) - [`0a50386`](https://github.com/adamhathcock/sharpcompress/commit/0a50386ada4833b37a05e259e628795cc27893aa) Using Constants class differently - [`d52facd`](https://github.com/adamhathcock/sharpcompress/commit/d52facd4ab139b0b9de8eb95e54b9facf2284ac8) Remove change - [`014bbc3`](https://github.com/adamhathcock/sharpcompress/commit/014bbc3ea480e7cdcf07b0842c398ca42b49952e) Initial plan - [`a114155`](https://github.com/adamhathcock/sharpcompress/commit/a11415518911db25c5a7810dbd2e9599a933c4ba) Initial plan - [`6c86632`](https://github.com/adamhathcock/sharpcompress/commit/6c866324b2d1d61c2aed78e189adb479e6a8d3a0) Fix grammatical errors in ArcFactory comments - [`53f12d7`](https://github.com/adamhathcock/sharpcompress/commit/53f12d75db91be1d1c38773cea93a516c18e916b) Add [Obsolete] attribute to ReaderOptions.DefaultBufferSize - [`010a38b`](https://github.com/adamhathcock/sharpcompress/commit/010a38bb7369ccb646479dd638262a2082522575) Add clarifying comment about buffer size value difference - [`d11f6ae`](https://github.com/adamhathcock/sharpcompress/commit/d11f6aefb041ce3fb0f6baa77676503cd626c72f) Merge pull request #1166 from adamhathcock/copilot/sub-pr-1165 - [`3c88c7f`](https://github.com/adamhathcock/sharpcompress/commit/3c88c7fdd509f5c0cff7d0e66bdb2ce31380c447) Merge pull request #1167 from adamhathcock/copilot/sub-pr-1165-again - [`d6156f0`](https://github.com/adamhathcock/sharpcompress/commit/d6156f0f1e617ef1757629aa3f2e1b0669b87d83) release branch builds increment patch versions and master builds increment minor versions ### 📊 Changes **25 files changed** (+112 additions, -134 deletions) <details> <summary>View changed files</summary> 📝 `build/Program.cs` (+39 -3) 📝 `src/SharpCompress/Archives/ArchiveFactory.cs` (+3 -11) 📝 `src/SharpCompress/Archives/AutoArchiveFactory.cs` (+2 -5) 📝 `src/SharpCompress/Archives/IArchiveEntryExtensions.cs` (+2 -4) 📝 `src/SharpCompress/Archives/Tar/TarArchive.cs` (+1 -1) 📝 `src/SharpCompress/Archives/Zip/ZipArchive.cs` (+10 -25) ➕ `src/SharpCompress/Common/Constants.cs` (+10 -0) 📝 `src/SharpCompress/Factories/AceFactory.cs` (+1 -5) 📝 `src/SharpCompress/Factories/ArcFactory.cs` (+1 -5) 📝 `src/SharpCompress/Factories/ArjFactory.cs` (+1 -5) 📝 `src/SharpCompress/Factories/Factory.cs` (+2 -6) 📝 `src/SharpCompress/Factories/GZipFactory.cs` (+2 -5) 📝 `src/SharpCompress/Factories/IFactory.cs` (+1 -5) 📝 `src/SharpCompress/Factories/RarFactory.cs` (+2 -5) 📝 `src/SharpCompress/Factories/SevenZipFactory.cs` (+2 -5) 📝 `src/SharpCompress/Factories/TarFactory.cs` (+2 -5) 📝 `src/SharpCompress/Factories/ZStandardFactory.cs` (+2 -5) 📝 `src/SharpCompress/Factories/ZipFactory.cs` (+4 -8) 📝 `src/SharpCompress/Readers/AbstractReader.cs` (+7 -3) 📝 `src/SharpCompress/Readers/ReaderOptions.cs` (+9 -1) _...and 5 more files_ </details> ### 📄 Description This pull request standardizes and centralizes the default buffer size used for stream operations across the codebase by introducing a new `Constants.BufferSize` value. It also simplifies method signatures for archive detection by removing the `bufferSize` parameter 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:** * Introduced `Constants.BufferSize` (default 81920 bytes) in `src/SharpCompress/Common/Constants.cs`, replacing scattered magic numbers and previous constants for buffer sizes throughout the codebase. * Updated all stream copying operations (e.g., in `IArchiveEntryExtensions.cs`, `TarArchive.cs`, `AbstractReader.cs`) to use `Constants.BufferSize` instead of hardcoded values or previous constants. [[1]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cL31-R29) [[2]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cL54-R52) [[3]](diffhunk://#diff-7f2eb9160ad6da95a3247f13cfb74c5556ae75ba12daaf9eeeab0edd8cd965d0L183-R183) [[4]](diffhunk://#diff-083fd66e1dab6e8c43abba168d79aad52ea814263e77dcca1eb34f7ce342842fL265-R281) **API Simplification and Consistency:** * Removed the `bufferSize` parameter from `IsArchive` and related methods in interfaces and factories (e.g., `IFactory`, `Factory`, and all concrete factory classes), simplifying their signatures and usage. [[1]](diffhunk://#diff-905353d54177b657dfcdff05cd3ea03755ea96228aef3e5107c3467dd58be18dL39-R39) [[2]](diffhunk://#diff-8bd4092c86ee37af196973dc7e57607eec5d3d1b0508b811d996977de62c3518L54-R54) [[3]](diffhunk://#diff-8bd4092c86ee37af196973dc7e57607eec5d3d1b0508b811d996977de62c3518L85-R81) [[4]](diffhunk://#diff-ed73ecc9390f716d464db47b9348155cd299e896469da34e16fdfa2ecd1aa47bL25-R25) [[5]](diffhunk://#diff-800f1b0c584eba50b849faa713b1d38c49e98276a9c84787069a948f58d85606L26-R33) [[6]](diffhunk://#diff-5f18bdabcff95ce9d36a774973a6f0e1e1fb01a70823556881455e9f9507c4abL25-R25) [[7]](diffhunk://#diff-411c372728302efc6962fc0fe053b1ad2225eba6de5bf86edfc53d123e25bcedL43-R44) [[8]](diffhunk://#diff-26f9a8c602e82b9ca394ff349d386f64d45d58a99d653b746abd3f8afeffe388L32-R33) [[9]](diffhunk://#diff-cd42deea8cb3c5956d1525a00343b0bee9ad46aa4d9dd62909ba9f5f5fe493cdL31-R32) [[10]](diffhunk://#diff-427819bd6e62926e10f46ac47acd569eab506b83e9d46bb3d729779a931238a6L56-R57) [[11]](diffhunk://#diff-43c2d53c213abc9b498cac18c871fb4200879d569f3e64964fbb752e6ba0b9eaL23-R24) [[12]](diffhunk://#diff-5dcd6c58655a0efb67027c2f36dfbf0bc885cf015998f07a658aaea87944a0d4L42-R53) [[13]](diffhunk://#diff-5dcd6c58655a0efb67027c2f36dfbf0bc885cf015998f07a658aaea87944a0d4L72-R68) [[14]](diffhunk://#diff-14afa030115e58257f705ec89e4ff1f3f81c9faa64fc5c1ae6f4ec1671f6c0f6L17-R18) * Updated all usages of `IsArchive`, `IsZipFile`, and similar methods to match the new signatures, removing the buffer size argument and ensuring consistent use of `Constants.BufferSize` internally. [[1]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18L169-R176) [[2]](diffhunk://#diff-fdeace22df51f39be3461b03ffceb3ae6b63a006fa2f3428c3a4df6728354dc8L127-R147) [[3]](diffhunk://#diff-fdeace22df51f39be3461b03ffceb3ae6b63a006fa2f3428c3a4df6728354dc8L180-R176) [[4]](diffhunk://#diff-fdeace22df51f39be3461b03ffceb3ae6b63a006fa2f3428c3a4df6728354dc8L232-R217) **Legacy Constant Cleanup:** * Removed the obsolete `DefaultBufferSize` constant from `ReaderOptions` and updated its usage to reference `Constants.BufferSize` instead. [[1]](diffhunk://#diff-13748160e4b6d80308b56fe7dd47fd436e1f6bcc739123932ed596228b9b1188L8-L9) [[2]](diffhunk://#diff-13748160e4b6d80308b56fe7dd47fd436e1f6bcc739123932ed596228b9b1188L19-R17) * Removed other redundant buffer size constants and magic numbers, such as `TEMP_BUFFER_SIZE` in `Utility.cs` and `BufferSize` in `IArchiveEntryExtensions.cs`. [[1]](diffhunk://#diff-10a4a0ed7b02894cae94a77846c2bdd1a83e6a58898ccdf9d9053669170d378bL14-L15) [[2]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cL12-L13) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:21:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1602