Repository navigation
Add polyfills for BigInteger.ToByteArray overloads and related .NET Core 2.1 members - #152
Merged
Merged
Conversation
…ore21) Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prime #152 +/- ##
==========================================
+ Coverage 88.17% 88.20% +0.03%
==========================================
Files 349 351 +2
Lines 7821 7894 +73
Branches 558 562 +4
==========================================
+ Hits 6896 6963 +67
- Misses 755 759 +4
- Partials 170 172 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No blocking issues were identified in the implementation, compatibility guards, tests, or signature updates.
Review effort: Balanced
Findings: None
What changed in this PR
Adds three BigInteger byte-conversion polyfills for older target frameworks, extending .NET Core 2.1 API compatibility.
Changes:
- Implements byte conversion, byte counting, and span writing with signedness and endianness support.
- Adds tests for conversion options, overflow, and buffer handling.
- Updates the signature catalog.
| File | Description |
|---|---|
| Signatures.md | Lists the three new members and updates totals. |
| PolyShim/NetCore21/BigInteger.cs | Implements the polyfills with framework guards. |
| PolyShim.Tests/NetCore21/BigIntegerTests.cs | Tests conversion behavior and buffer handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tyrrrz
approved these changes
Oct 3, 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.
BigIntegergained a byte-array overload family in .NET Core 2.1 / .NET Standard 2.1 (ToByteArray(bool, bool),GetByteCount(bool),TryWriteBytes(Span<byte>, out int, bool, bool)) that wasn't available as a polyfill for older target frameworks.Polyfill implementation
PolyShim/NetCore21/BigInteger.cswith extension members for:ToByteArray(bool isUnsigned, bool isBigEndian)GetByteCount(bool isUnsigned)TryWriteBytes(Span<byte> destination, out int bytesWritten, bool isUnsigned, bool isBigEndian)ToByteArray(), handling sign-byte trimming for unsigned output, endianness reversal, and throwingOverflowExceptionfor negative values whenisUnsigned: true, matching documented BCL behavior.#ifto exclude frameworks whereBigIntegeritself doesn't exist (net35, netstandard1.0), in addition to the standard upper-bound guard for frameworks that already have these members natively.Not polyfilled
BigInteger(ReadOnlySpan<byte>, bool, bool)constructor overload (also added in .NET Core 2.1) can't be polyfilled — C# extension members can't add constructors to an existing type.Tests & docs
PolyShim.Tests/NetCore21/BigIntegerTests.cscovering signed/unsigned and little/big-endian combinations, zero value, negative overflow, andTryWriteBytessuccess/insufficient-buffer paths.Signatures.md.