Related to previous post about the pdb files that cannot be read the
second time ( which i understand is not a cecil issue but an issue of
a microsoft library) I came up with the idea of tagging the assembly
with a special attribute in order to distinguish if it was tampered
with cecil or not.

I decided to create the attribute in the assembly itself in order not
not add another dependency...
Seems simple but i am stack with 2 problems:


 /// I create a type that derives from Attribute:

            var attributeType =
assembly.MainModule.Import(typeof(Attribute));
            TypeDefinition td = new
TypeDefinition("CecilGeneratedAttribute", "Mono.Cecil",
TypeAttributes.Public, attributeType);

 ////  PROBLEM 1: WHAT SHOULD I PASS TO CustomAttribute constructor,
what MethodReference? I cannot /////  pass null because i get an
exception!

             assembly.CustomAttributes.Add(new
CustomAttribute( ??? ) );

I  think it might be a constructor but i need your help here:

PROBLEM 2: If it is a constructor, I can't get a grip on one,
Attribute has a default constructor and i cannot get it with
Reflection:

            var constructors =
typeof(Attribute).GetConstructors(BindingFlags.NonPublic |
BindingFlags.Public);

BUT constructors is empty!!!!
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to