Using unmanaged code, how can I find a type that has a given custom attribute assigned to it?
- by Andrew
I had thought I could enumerate the types using IMetaDataImport.EnumTypeDefs and
for each of the tokens returned, call IMetaDataImport.EnumCustomAttributes.
This works, in so much as I get an array of mdCustomAttribute tokens. Using these tokens I can get a metadata token representing the Type of the returned custom attribute, by calling IMetaDataImport.GetCustomAttributeProps.
Comparing my results against ILDASM, I can see that this matches the "CustomAttribute Type" that ILDASM reports. However, I cannot work out how to determine the "CustomAttributeName" that ILDASM reports. This is what I really want!
While I would be interested in knowing how to get the CustomAttributeName, I would settle for an alternate approach to solving the problem.