Closed
Description
Background and motivation
Currently we cannot test whether a ref readonly is null ref or not because Unsafe.IsNullRef() takes a ref parameter instead of ref readonly parameter.
Given that Unsafe.IsNullRef doesn’t need mutability, the signature should be changed from IsNullRef(ref) to IsNullRef(ref readonly).
API Proposal
namespace System.Runtime.CompilerServices;
public static class Unsafe
{
- public bool IsNullRef(ref value);
+ public bool IsNullRef(ref readonly value); // or in value
}
API Usage
ref readonly int Foo() {…}
ref readonly int x = ref Foo();
Unsafe.IsNullRef(in x);
Alternative Designs
No response
Risks
No response