diff --git a/PolyShim.Tests/NetCore30/MathTests.cs b/PolyShim.Tests/NetCore30/MathTests.cs new file mode 100644 index 0000000..eca077f --- /dev/null +++ b/PolyShim.Tests/NetCore30/MathTests.cs @@ -0,0 +1,20 @@ +using System; +using FluentAssertions; +using Xunit; + +namespace PolyShim.Tests.NetCore30; + +public class MathTests +{ + [Fact] + public void Log2_Test() + { + // Act & assert + Math.Log2(8.0).Should().BeApproximately(3.0, 1e-12); + Math.Log2(1.0).Should().Be(0.0); + Math.Log2(0.0).Should().Be(double.NegativeInfinity); + Math.Log2(double.PositiveInfinity).Should().Be(double.PositiveInfinity); + Math.Log2(-1.0).Should().Be(double.NaN); + Math.Log2(double.NaN).Should().Be(double.NaN); + } +} diff --git a/PolyShim/NetCore30/Math.cs b/PolyShim/NetCore30/Math.cs new file mode 100644 index 0000000..4c71cec --- /dev/null +++ b/PolyShim/NetCore30/Math.cs @@ -0,0 +1,19 @@ +#if (NETCOREAPP && !NETCOREAPP3_0_OR_GREATER) || (NETFRAMEWORK) || (NETSTANDARD) +#nullable enable +#pragma warning disable CS0436 + +using System; +using System.Diagnostics.CodeAnalysis; + +#if !POLYSHIM_INCLUDE_COVERAGE +[ExcludeFromCodeCoverage] +#endif +internal static class MemberPolyfills_NetCore30_Math +{ + extension(Math) + { + // https://learn.microsoft.com/dotnet/api/system.math.log2 + public static double Log2(double x) => Math.Log(x, 2); + } +} +#endif diff --git a/Signatures.md b/Signatures.md index 81190e2..77cb70b 100644 --- a/Signatures.md +++ b/Signatures.md @@ -1,8 +1,8 @@ # Signatures -- **Total:** 620 +- **Total:** 621 - **Types:** 114 -- **Members:** 506 +- **Members:** 507 ___ @@ -396,6 +396,7 @@ ___ - [`IEnumerator GetEnumerator()`](https://learn.microsoft.com/dotnet/api/system.text.regularexpressions.matchcollection.system-collections-generic-ienumerable-system-text-regularexpressions-match--getenumerator) .NET Core 2.0 - [`Match[] ToArray()`](https://learn.microsoft.com/dotnet/api/system.text.regularexpressions.matchcollection.system-collections-generic-ienumerable-system-text-regularexpressions-match--getenumerator) .NET Core 2.0 - `Math` + - [`static double Log2(double)`](https://learn.microsoft.com/dotnet/api/system.math.log2) .NET Core 3.0 - [`static IntPtr Clamp(IntPtr, IntPtr, IntPtr)`](https://learn.microsoft.com/dotnet/api/system.math.clamp#system-math-clamp(system-intptr-system-intptr-system-intptr)) .NET 6.0 - [`static T Clamp(T, T, T) where T : IComparable`](https://learn.microsoft.com/dotnet/api/system.math.clamp) .NET Core 2.0 - `MaybeNullAttribute`