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

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1000
Author: @Copilot
Created: 10/29/2025
Status: Merged
Merged: 10/29/2025
Merged by: @adamhathcock

Base: adam/async-rar-aiHead: copilot/sub-pr-996


📝 Commits (2)

  • e786e95 Initial plan
  • 88b3a66 Fix Windows test failures in SharpCompressStreamTests

📊 Changes

2 files changed (+13 additions, -13 deletions)

View changed files

📝 src/SharpCompress/packages.lock.json (+3 -3)
📝 tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs (+10 -10)

📄 Description

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.


🔄 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/1000 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 10/29/2025 **Status:** ✅ Merged **Merged:** 10/29/2025 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `adam/async-rar-ai` ← **Head:** `copilot/sub-pr-996` --- ### 📝 Commits (2) - [`e786e95`](https://github.com/adamhathcock/sharpcompress/commit/e786e953585b60d1380eb27d04ba58d788fd83bd) Initial plan - [`88b3a66`](https://github.com/adamhathcock/sharpcompress/commit/88b3a66bf931b021ac80175d635c57bcf0fa0904) Fix Windows test failures in SharpCompressStreamTests ### 📊 Changes **2 files changed** (+13 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/packages.lock.json` (+3 -3) 📝 `tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs` (+10 -10) </details> ### 📄 Description 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). --- <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: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#1419