I made a generator class that build a proxy class based on interface which implement the interface.
See my post on Build a Proxy class based on Interface without implementing it.
I'm familiar with CustomAttributeData.GetCustomAttributes(MemberInfo target)
, I used it when I read the Interface's members and succeed to import them to the proxy.
I want to inject additional attributes to generated class in run-time. I'm asking for attributes instances to inject them into the proxy.
For example:
A developer can pass this as a value: new ObsoleteAttribute("Demo", true)
, (it has an empty constructor, but properties are read only), and I want to convert it to:
return new CustomAttributeBuilder(
attribute.GetType().GetConstructor(Type[] {typeof (string), typeof (bool)}),
new object[] {"Demo", true},
new FieldInfo[0],
new object[0]);
Remember, I can't tell what is given.
Type
) or a class you're currently building (TypeBuilder
)? – UnformedCustomAttributeBuilder
constructor overloads? I would have expected them to be self-explanatory. – Formally