Well, I've made some progress:

AssemblyDefinition assembly = method.DeclaringType.Module.Assembly;
MethodReference myAttribCtor = assembly.MainModule.Import(
        typeof(MyAttribAttribute).GetConstructor(Type.EmptyTypes));
CustomAttribute myAttrib = new CustomAttribute(myAttribCtor);

This works - myAttrib is not null and it's the right reference. But
when I do this:

if(param.CustomAttributes.Contains(myAttrib)) ...

It doesn't work - I get a false back, even though I KNOW that
attribute is on that parameter.

I have a plan B where I iterate through the collection, comparing the
full name of the declaring type to the full name of the attribute, but
using Contains() feels cleaner, so I'd to use that approach...if I can
figure out what I'm doing wrong...

Any ideas?

Thanks,
Jason


--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to