Add BinaryReader/BinaryWriter span polyfills (NetCore21) - #131
Merged
Conversation
Copilot created this pull request from a session on behalf of
Tyrrrz
July 11, 2026 19:19
View session
Tyrrrz
marked this pull request as ready for review
July 11, 2026 19:19
Contributor
There was a problem hiding this comment.
Pull request overview
Adds .NET Core 2.1 span-based BinaryReader/BinaryWriter API polyfills so older targets (e.g., netstandard2.0, netframework, pre-2.1 netcoreapp) can use the newer span overloads while delegating to the existing array-based methods.
Changes:
- Add
BinaryReader.Read(Span<byte>)andBinaryReader.Read(Span<char>)polyfills (delegate to array overloads and copy back only what was read). - Add
BinaryWriter.Write(ReadOnlySpan<byte>)andBinaryWriter.Write(ReadOnlySpan<char>)polyfills (delegate to array overloads). - Add unit tests for the new polyfills and update
Signatures.mdto list the new APIs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Signatures.md | Adds the BinaryReader/BinaryWriter span-based members to the signature index and updates totals. |
| PolyShim/NetCore21/BinaryWriter.cs | Introduces BinaryWriter.Write(ReadOnlySpan<byte/char>) member polyfills for pre-.NET Core 2.1 targets. |
| PolyShim/NetCore21/BinaryReader.cs | Introduces BinaryReader.Read(Span<byte/char>) member polyfills for pre-.NET Core 2.1 targets. |
| PolyShim.Tests/NetCore21/BinaryWriterTests.cs | Adds tests for the new BinaryWriter span overload polyfills. |
| PolyShim.Tests/NetCore21/BinaryReaderTests.cs | Adds tests for the new BinaryReader span overload polyfills. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Tyrrrz
approved these changes
Jul 11, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #131 +/- ##
==========================================
+ Coverage 99.15% 99.16% +0.01%
==========================================
Files 145 147 +2
Lines 3798 3846 +48
Branches 87 87
==========================================
+ Hits 3766 3814 +48
Misses 13 13
Partials 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds polyfills for the four span-based
BinaryReader/BinaryWriterAPIs introduced in .NET Core 2.1, enabling their use onnetstandard2.0,netframework, and oldernetcoreapptargets.New polyfills
BinaryReader.Read(Span<byte>)— delegates toRead(byte[], int, int), copies only bytes actually readBinaryReader.Read(Span<char>)— delegates toRead(char[], int, int), copies only chars actually readBinaryWriter.Write(ReadOnlySpan<byte>)— delegates toWrite(byte[], int, int)BinaryWriter.Write(ReadOnlySpan<char>)— delegates toWrite(char[], int, int)