public static bool IsByRef(this ITypeReference type) { // ByReference<T> is a special type understood by runtime to hold a ref T. // ByReference<T> was removed in .NET 7 since support for ref T in C# 11 was introduced. return(type.TypeCode == PrimitiveTypeCode.Reference || type.AreGenericTypeEquivalent(ByReferenceFullName)); }