Thanks, that makes sense now. So this works just fine:
var attCtor = module.Import(typeof
(DataContractAttribute).GetConstructor(Type.EmptyTypes));
var custatt = new CustomAttribute(attCtor);
foo.CustomAttributes.Add(custatt);
>> // At this point, a save results in the following CustomAttribute
>> error (from IL Disassembler):
>> // .custom <invalid token 0x06000032> = (01 00 00 00) ...
>
> This should throw with a recent Cecil though. Are you on master?
I am on 9.4 (built on .Net 4.0)
--
--
mono-cecil