static bool IsNestedTypeWithNamespace(Type type) { if (!type.IsNested) { return false; } if (type.IsConstructedGenericType) { type = type.GetGenericTypeDefinition(); } return type.__Namespace != null; }