using System.Reflection;
using System.Collections;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
#if !FULL_AOT_RUNTIME
using System.Reflection.Emit;
#endif
else if (obj is ParameterInfo)
pseudoAttrs = ((ParameterInfo)obj).GetPseudoCustomAttributes ();
else if (obj is Type)
- pseudoAttrs = ((Type)obj).GetPseudoCustomAttributes ();
+ pseudoAttrs = GetPseudoCustomAttributes (((Type)obj));
if ((attributeType != null) && (pseudoAttrs != null)) {
for (int i = 0; i < pseudoAttrs.Length; ++i)
return pseudoAttrs;
}
+ static object[] GetPseudoCustomAttributes (Type type)
+ {
+ int count = 0;
+ var Attributes = type.Attributes;
+
+ /* IsSerializable returns true for delegates/enums as well */
+ if ((Attributes & TypeAttributes.Serializable) != 0)
+ count ++;
+ if ((Attributes & TypeAttributes.Import) != 0)
+ count ++;
+
+ if (count == 0)
+ return null;
+ object[] attrs = new object [count];
+ count = 0;
+
+ if ((Attributes & TypeAttributes.Serializable) != 0)
+ attrs [count ++] = new SerializableAttribute ();
+ if ((Attributes & TypeAttributes.Import) != 0)
+ attrs [count ++] = new ComImportAttribute ();
+
+ return attrs;
+ }
+
internal static object[] GetCustomAttributesBase (ICustomAttributeProvider obj, Type attributeType, bool inheritedOnly)
{
object[] attrs;