public static bool IsUnmanagedType (TypeSpec t)
{
var ds = t.MemberDefinition as DeclSpace;
if (ds != null)
return ds.IsUnmanagedType ();
// some builtins that are not unmanaged types
if (t == TypeManager.object_type || t == TypeManager.string_type)
return false;
if (IsBuiltinOrEnum (t))
return true;
// Someone did the work of checking if the ElementType of t is unmanaged. Let's not repeat it.
if (t.IsPointer)
return IsUnmanagedType (GetElementType (t));
if (!IsValueType (t))
return false;
if (t.IsNested && t.DeclaringType.IsGenericOrParentIsGeneric)
return false;
return true;
}