In addition to what Reid said above, MemberInfo.GetCustomAttributes API allows you to specify the type of filter that affects the type of array returned. Ie, when you specify typeof (MyAttribute) , the result will actually be MyAttribute[] (discarded to object[] ).
Now, when you specify the IMyAttribute interface IMyAttribute , the array is of the IMyAttribute[] . Although IMyAttribute[] can be dropped to object[] , it cannot be dropped to Attribute[] . Thus, in essence, this was the result of Attribute[] , filtering based on interfaces did not work.
(BTW, the new Attribute.GetCustomAttributes APIs that capture inheritance resolution for properties and events have Attribute[] as their return type. This makes filtering based on interfaces impossible, you get an ArgumentException when trying to pass an interface type for filtering.)
Fabian schmied
source share