[Intrinsic]
public static T CompareExchange<T> (ref T location1, T value, T comparand) where T : class?
{
+ unsafe {
+ if (Unsafe.AsPointer (ref location1) == null)
+ throw new NullReferenceException ();
+ }
// Besides avoiding coop handles for efficiency,
// and correctness, this also appears needed to
// avoid an assertion failure in the runtime, related to
[Intrinsic]
public static T Exchange<T> (ref T location1, T value) where T : class?
{
+ unsafe {
+ if (Unsafe.AsPointer (ref location1) == null)
+ throw new NullReferenceException ();
+ }
// See CompareExchange(T) for comments.
//
// This is not entirely convincing due to lack of volatile.