#if NET_2_0
[ComVisible (true)]
+ [ComDefaultInterface (typeof (_Attribute))]
#endif
#if NET_1_1
return GetCustomAttributes (element, attributeType, true);
}
- public static Attribute[] GetCustomAttributes (MemberInfo element, Type attributeType)
+ public static Attribute[] GetCustomAttributes (MemberInfo element, Type type)
{
- return GetCustomAttributes (element, attributeType, true);
+ return GetCustomAttributes (element, type, true);
}
public static Attribute[] GetCustomAttributes (Assembly element, Type attributeType, bool inherit)
return (Attribute []) element.GetCustomAttributes (attributeType, inherit);
}
- public static Attribute[] GetCustomAttributes (MemberInfo element, Type attributeType, bool inherit)
+ public static Attribute[] GetCustomAttributes (MemberInfo element, Type type, bool inherit)
{
// element parameter is not allowed to be null
- CheckParameters (element, attributeType);
+ CheckParameters (element, type);
- return (Attribute []) element.GetCustomAttributes (attributeType, inherit);
+ // MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
+ // implementation, but not in the Attributes, so directly get the attributes
+ // from MonoCustomAttrs instead of going throught the PropertyInfo's
+ // ICustomAttributeProvider
+ MemberTypes mtype = element.MemberType;
+ if (mtype == MemberTypes.Property)
+ return (Attribute []) MonoCustomAttrs.GetCustomAttributes (element, type, inherit);
+ return (Attribute []) element.GetCustomAttributes (type, inherit);
}
public static Attribute[] GetCustomAttributes (Module element, bool inherit)
// element parameter is not allowed to be null
CheckParameters (element, typeof (Attribute));
- return (Attribute []) element.GetCustomAttributes (inherit);
+ // MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
+ // implementation, but not in the Attributes, so directly get the attributes
+ // from MonoCustomAttrs instead of going throught the PropertyInfo's
+ // ICustomAttributeProvider
+ MemberTypes mtype = element.MemberType;
+ if (mtype == MemberTypes.Property)
+ return (Attribute []) MonoCustomAttrs.GetCustomAttributes (element, inherit);
+ return (Attribute []) element.GetCustomAttributes (typeof (Attribute), inherit);
}
public static Attribute[] GetCustomAttributes (ParameterInfo element, bool inherit)
mtype != MemberTypes.NestedType)
throw new NotSupportedException (Locale.GetText (
"Element is not a constructor, method, property, event, type or field."));
-
+#if NET_2_0
+ // MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
+ // implementation, but not in the Attributes, so directly get the attributes
+ // from MonoCustomAttrs instead of going throught the PropertyInfo's
+ // ICustomAttributeProvider
+ if (mtype == MemberTypes.Property)
+ return MonoCustomAttrs.IsDefined (element, attributeType, inherit);
+#endif
return ((MemberInfo) element).IsDefined (attributeType, inherit);
}