public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target)
{
if (target == null)
throw new ArgumentNullException("target");
IList<CustomAttributeData> cad = GetCustomAttributes(target.Module, target.MetadataToken);
int pcaCount = 0;
Attribute[] a = null;
if (target is RuntimeType)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeType)target, typeof(object), false, out pcaCount);
else if (target is RuntimeMethodInfo)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeMethodInfo)target, typeof(object), false, out pcaCount);
else if (target is RuntimeFieldInfo)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeFieldInfo)target, typeof(object), out pcaCount);
if (pcaCount == 0)
return cad;
CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
cad.CopyTo(pca, pcaCount);
for (int i = 0; i < pcaCount; i++)
{
if (PseudoCustomAttribute.IsSecurityAttribute(a[i].GetType()))
continue;
pca[i] = new CustomAttributeData(a[i]);
}
return Array.AsReadOnly(pca);
}