public static bool HasReferenceEquality(Type left, Type right)
{
if (left.GetTypeInfo().IsValueType || right.GetTypeInfo().IsValueType)
{
return false;
}
// If we have an interface and a reference type then we can do
// reference equality.
// If we have two reference types and one is assignable to the
// other then we can do reference equality.
return left.GetTypeInfo().IsInterface || right.GetTypeInfo().IsInterface ||
AreReferenceAssignable(left, right) ||
AreReferenceAssignable(right, left);
}