-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.CompilerServices
Milestone
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.CompilerServices