We should use ref or out modifiers to avoid pointers in more places. We don't do it today where the argument is optional, because C# disallows null for ref or out parameters.
However, callers can use Unsafe.NullRef<T>. We could even add this tip to the API docs so folks can discover it.
And the helper function can use Unsafe's SkipInit and IsNullRef methods to detect when this has occurred, if this were ever necessary.
We should use
reforoutmodifiers to avoid pointers in more places. We don't do it today where the argument is optional, because C# disallowsnullforreforoutparameters.However, callers can use
Unsafe.NullRef<T>. We could even add this tip to the API docs so folks can discover it.And the helper function can use
Unsafe'sSkipInitandIsNullRefmethods to detect when this has occurred, if this were ever necessary.