Repository navigation
Adding AllBitsSet to IBinaryNumber Interface - #71356
Conversation
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsFixes #69676 Note: there is a trimmer bug that is preventing a DIM of AllBitsSet from being possible. This will be added later once the bug is fixed. I tried to match the style of the files I was adding to, but feel free to nitpick any style choices. Specifically, there are quite a few ways to hard code in an AllBitsSet constant for each of these types, so happy to tweak as needed.
|
| where TSelf : IBinaryNumber<TSelf> | ||
| { | ||
| /// <summary>Gets an instance of the binary type in which all bits are set.</summary> | ||
| static abstract TSelf AllBitsSet { get; } // TODO: add the DIM once https://github.com/dotnet/linker/issues/2865 is fixed |
There was a problem hiding this comment.
Do we have a runtime issue tracking all of the APIs that need to be made DIMs once this bug is fixed? Presumably this is a must-do for .NET 7?
There was a problem hiding this comment.
The other APIs are already DIM where relevant. This is a new scenario specific to properties.
There was a problem hiding this comment.
The other APIs are already DIM where relevant.
Oh. We're not making APIs like IParseable.Parse DIMs? I figured that'd have been implemented in terms of TryParse by default.
There was a problem hiding this comment.
We can't given the current shape because there are multiple possible "failure conditions".
For all the primitive types, we have an internal TryParse method which returns a ParsingStatus that is then used to determine if the issue was overflow or format.
We'd likely need to codify and expose a slightly different shape if we wanted this to be DIM.
There was a problem hiding this comment.
(or agree that we just always throw FormatException and expect users that need to differentiate to always override).
There was a problem hiding this comment.
The fact that I'm the first person to run into this implies this is the first static virtual property somebody has tried to use. This is surprising and suspicious. I wonder if I'm just the first one to realize the DIM isn't being overridden by inheriting classes. Regardless, yes, I think fixing the bug should have relatively high priority.
Edit: for some reason it didn't show me any of Tanner's replies, sorry if some of this was redundant.
Co-authored-by: Tanner Gooding <[email protected]>
dakersnar
left a comment
There was a problem hiding this comment.
More suggestions from code review
…ime.InteropServices.UnitTests/System/Runtime/InteropServices/NFloatTests.GenericMath.cs Co-authored-by: Tanner Gooding <[email protected]>
Fixes #69676
Note: there is a trimmer bug that is preventing a DIM of AllBitsSet from being possible. This will be added later once the bug is fixed.
I tried to match the style of the files I was adding to, but feel free to nitpick any style choices. Specifically, there are quite a few ways to hard code in an AllBitsSet constant for each of these types, so happy to tweak as needed.