Add Nullable.GetValueRefOrDefaultRef API#64677
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. |
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
|
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsCloses #1534This PR adds the following API: namespace System
{
public static partial class Nullable
{
public static ref readonly T GetValueRefOrDefaultRef<T>(in T? nullable) where T : struct;
}
}
|
|
Note: ideally the unit tests would compare the actual address, but they can't directly access internals from corelib and I'm not sure what the recommended approach is for this other than using a dynamic method, which seems a bit overkill and also potentially problematic for eg. NativeAOT? I'd have loved to use the APIs from #23716 if they had been implemented already 😄 Let me know if the included tests are enough or if any changes are recommended in that area 👍 |
55ec6f5 to
b1f9aab
Compare
Co-Authored-By: Stephen Toub <stoub@microsoft.com>
b1f9aab to
5f9c8e8
Compare
|
Thank you @stephentoub and @tannergooding for helping push this through! 😄 |
Closes #1534
This PR adds the following API: