Add polyfill for Math.Log2(double) - #136
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #136 +/- ##
=======================================
Coverage 99.17% 99.17%
=======================================
Files 149 150 +1
Lines 3998 4005 +7
Branches 88 88
=======================================
+ Hits 3965 3972 +7
Misses 13 13
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request adds a PolyShim polyfill for System.Math.Log2(double) for targets that predate .NET Core 3.0 / .NET Standard 2.1, along with tests and signature documentation updates.
Changes:
- Added a NetCore30 polyfill for
Math.Log2(double)implemented via an extension member. - Added NetCore30 tests covering standard and edge-case inputs for
Log2. - Regenerated
Signatures.mdto include the new member and updated totals.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Signatures.md | Updates signature inventory totals and lists Math.Log2(double) as a .NET Core 3.0 member. |
| PolyShim/NetCore30/Math.cs | Introduces the Math.Log2(double) polyfill under appropriate target guards. |
| PolyShim.Tests/NetCore30/MathTests.cs | Adds test coverage for Math.Log2(double) including edge cases. |
Suppressed comments (1)
PolyShim.Tests/NetCore30/MathTests.cs:18
- Asserting
Be(double.NaN)can be brittle becauseNaN != NaNunder==semantics. To make intent unambiguous and avoid assertion-library edge cases, assert withdouble.IsNaN(...).
Math.Log2(-1.0).Should().Be(double.NaN);
Math.Log2(double.NaN).Should().Be(double.NaN);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot this method was added only in .NET Core 3.0. It's not available in .NET Standard. |
Fixed in commit |
Math.Log2(double)
Math.Log2(double)was introduced in .NET Core 3.0 / .NET Standard 2.1 and had no polyfill for earlier targets.Polyfill
PolyShim/NetCore30/Math.cswith a static extension implementingMath.Log2(double)asMath.Log(x, 2), guarded to only apply on .NET Framework, pre-.NET Core 3.0, and pre-netstandard2.1 targets.Tests
PolyShim.Tests/NetCore30/MathTests.cscovering typical values and edge cases (0,+Infinity, negative input,NaN).Docs
Signatures.mdto include the new member.