-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Updating the 'System.Runtime.Extensions' contracts to include the new single-precision Math APIs. #12183
Conversation
Unit Tests for the |
Have these APIs only been approved for .net core? |
@terrajobst, could you clarify on which TFMs the new APIs have been approved for? |
Yes, these APIs were approved for .NET Core in #1151. |
We can only add this to |
@mellinoe, the document above is somewhat confusing, as it says any change that is not part of netstandard but that depends directly on a runtime change, then the target framework should be It seems like these changes have an actual dependency on the Is this not the case? |
@weshaggard Could you clarify that point a bit? These are new API's for .NET Core, which rely on new FCALL's. |
Thanks for the feedback on the documentation. I will try and incorporate and update once I can get back to that. As @mellinoe points out though these are definitely in the bucket of netstandard APIs they just aren't part of any standard yet and as such they need to be added as .NET Core specific for now. In the mean time I suggest using #12226 as an example for how to add APIs to .NET Core specifically. |
@tannergooding was the info from @weshaggard helpful? Anything else we can help with here? |
@karelz, yes it was. I have just had my focus elsewhere due to the current schedule. I am going to take some time today to fix up this and the other PR. |
Pretty sure I've updated these all appropriately now.
|
@mellinoe, the CoreCLR side changes have been merged. About how long does it take before a |
Actually, it looks like @dotnet-bot does automated PRs at least once a day. I suppose I will need to wait for the next one (after the current one is merged) to complete. |
Looks like it will be one more PR. The one that just came up (#12756) is a commit before my changes 😄 |
Rebased onto HEAD. Going to start writing the |
I've ported the existing The coverage that exists for |
As a general note, it would be nice to get the test cases factored out into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good overall; I made a few small comments on the tests. Thanks for all of the work you've done on this, I'm looking forward to using it when we get it through 😄
[Fact] | ||
public static void Abs() | ||
{ | ||
AssertEqual(MathF.PI, MathF.Abs(MathF.PI)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this two-parameter AssertEquals
method anywhere. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mistake on my side, the calls that do not have an expected precision (and should be exact values) should still call Assert.Equal
.
// This is essentially equivalent to the Xunit.Assert.Equal(double, double, int) implementation | ||
// available here: https://github.com/xunit/xunit/blob/2.1/src/xunit.assert/Asserts/EqualityAsserts.cs#L46 | ||
|
||
var expectedRounded = MathF.Round(expected, precision); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of a MathF
function here raises a flag for me, since this is a core assertion used by the rest of the tests. It would be nice if the MathF.Round
tests didn't use this, at the very least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the exact behavior that the double tests currently use. But I agree, it is undesirable.
I am going to go ahead and convert this to use the same logic as the PAL tests I wrote, which is:
var delta = MathF.Abs(result - expected);
if (delta > allowedVariance)
{
throw new EqualException(...);
}
Where allowedVariance
is the cross platform machine epsilon (4.76837158e-07f
) multiplied by the a power of 10 to allow for proper rounding (so an expected result of 0.xxxxxxxxx is just machine epsilon
, while x.xxxxxxxx is machine epsilon * 10
, and 0.0xxxxxxxxx is machine epsilon / 10
).
This is at least better in the sense that MathF.Abs
calls to the existing Math.Abs
function, which is known to be good.
@mellinoe, I agree that converting these to use I am going to assign the bug to myself and start on it immediately, but would like to get the initial change completed since it provides parity with the |
Sounds good to me. |
FYI. @mellinoe the bug tracking the additional test work is here: https://github.com/dotnet/corefx/issues/12855 |
The contracts for |
@mellinoe, I must be missing some change that causes Are you aware of what is missing here? |
Looks like what I'm missing is whatever causes the |
Ok, after a lot more digging, it looks like the project ends up running |
I can 'fix' the issue and get tests passing by adding a new source file and manually adding the appropriate type forward. However, I do not believe this is the correct fix. Could someone please confirm what the correct fix is here? |
Ping @mellinoe to answer (or direct to someone for answering) the above question. |
@tannergooding Sorry about not getting back to you. I'll take a look at your branch and see if I can figure out the problem. |
Thanks! |
@tannergooding It looks like there is a limitation in how we are resolving the contract references right now: dotnet/buildtools#1041. We're in a sort of intermediate state right now where we have two different build configurations for the reference assembly, and the one we're choosing right now is not correct for this scenario, as you discovered. Eventually the problem will go away because we will only have one reference assembly, but that is still in the works. Right now, just go ahead and add the manual type-forward file like you mentioned above. If you don't mind, please put a comment in the csproj file (or in the .cs file) mentioning dotnet/buildtools#1041 so that we remember to revert it when that is fixed. |
@mellinoe, Thanks for the confirmation. I have added the manual Slightly separate here, but I noticed the following in the
Specifically, the condition on the second ItemGroup is using Is this |
@mellinoe, everything is looking good here. |
This is probably harmless since nothing seems to be breaking in those configurations. Strictly speaking we should probably fix it, but I was chatting with @ericstj and we thought that we really should only have one of these |
Everything looks good to me. Thanks a lot for all the work you've put into this. It looks like a really high-quality addition, and I know I'm planning on using it in some of my projects. |
Thanks! I will continue working on getting the remaining work (perf tests, expanded unit tests, etc) done in my spare time! |
This updates the
System.Runtime.Extensions
contracts to include the new single-precision Math APIs approved in #1151 and implemented in CoreCLR in dotnet/coreclr#5492.