[PR #1000] Fix Windows test failures due to ArrayPool buffer sizing #1422

Closed
opened 2026-01-29 22:20:28 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


Windows tests failed because ArrayPool<byte>.Shared.Rent() returns buffers larger than requested on Windows but not on Linux. Tests used test.Length (actual rented size) instead of the requested size for reads and comparisons.

Changes

  • SharpCompressStreamTest.cs: Changed Read() calls to use explicit size 0x1000 instead of test.Length
  • Array comparisons: Use .Take(0x1000) to compare only the requested portion of rented buffers
// Before (fails on Windows when ArrayPool returns larger buffer)
scs.Read(test, 0, test.Length);
Assert.True(data.Skip(0x1000).Take(test.Length).SequenceEqual(test));

// After (works regardless of actual buffer size)
scs.Read(test, 0, 0x1000);
Assert.True(data.Skip(0x1000).Take(0x1000).SequenceEqual(test.Take(0x1000)));

This aligns with ArrayPool contract: rented buffers may be larger than requested and only the specified portion should be used.


💬 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/1000 **State:** closed **Merged:** Yes --- Windows tests failed because `ArrayPool<byte>.Shared.Rent()` returns buffers larger than requested on Windows but not on Linux. Tests used `test.Length` (actual rented size) instead of the requested size for reads and comparisons. ## Changes - **SharpCompressStreamTest.cs**: Changed `Read()` calls to use explicit size `0x1000` instead of `test.Length` - **Array comparisons**: Use `.Take(0x1000)` to compare only the requested portion of rented buffers ```csharp // Before (fails on Windows when ArrayPool returns larger buffer) scs.Read(test, 0, test.Length); Assert.True(data.Skip(0x1000).Take(test.Length).SequenceEqual(test)); // After (works regardless of actual buffer size) scs.Read(test, 0, 0x1000); Assert.True(data.Skip(0x1000).Take(0x1000).SequenceEqual(test.Take(0x1000))); ``` This aligns with `ArrayPool` contract: rented buffers may be larger than requested and only the specified portion should be used. <!-- 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:20:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1422