[PR #1166] Add [Obsolete] attribute to ReaderOptions.DefaultBufferSize for backward compatibility #1608

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

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1166

State: closed
Merged: Yes


PR #1165 removed the public constant ReaderOptions.DefaultBufferSize, causing compilation errors for consumers referencing it. This PR restores the constant with deprecation guidance.

Changes

  • Restored ReaderOptions.DefaultBufferSize with original value (0x10000 = 65536 bytes) and [Obsolete] attribute directing users to Constants.BufferSize
  • Preserved new default behavior where BufferSize property defaults to Constants.BufferSize (81920 bytes, matching .NET's Stream.CopyTo)
  • Added documentation explaining the value difference and backward compatibility preservation

Migration Path

Existing code compiles with warning instead of error:

// Old code - now produces CS0618 warning but still compiles
var bufferSize = ReaderOptions.DefaultBufferSize; // 65536

// New code - use this going forward
var bufferSize = Constants.BufferSize; // 81920

New ReaderOptions instances automatically use the improved 81920-byte default while existing constant references remain functional.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/1166 **State:** closed **Merged:** Yes --- PR #1165 removed the public constant `ReaderOptions.DefaultBufferSize`, causing compilation errors for consumers referencing it. This PR restores the constant with deprecation guidance. ## Changes - **Restored `ReaderOptions.DefaultBufferSize`** with original value (0x10000 = 65536 bytes) and `[Obsolete]` attribute directing users to `Constants.BufferSize` - **Preserved new default behavior** where `BufferSize` property defaults to `Constants.BufferSize` (81920 bytes, matching .NET's Stream.CopyTo) - **Added documentation** explaining the value difference and backward compatibility preservation ## Migration Path Existing code compiles with warning instead of error: ```csharp // Old code - now produces CS0618 warning but still compiles var bufferSize = ReaderOptions.DefaultBufferSize; // 65536 // New code - use this going forward var bufferSize = Constants.BufferSize; // 81920 ``` New `ReaderOptions` instances automatically use the improved 81920-byte default while existing constant references remain functional. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
claunia added the pull-request label 2026-01-29 22:21:22 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1608