I can use TypeDescriptor.AddAttributes to add an attribute to a type in runtime. How do I do the same for a method and parameter? (maybe 2 separate questions…)
I can use TypeDescriptor.AddAttributes to add an attribute to a type in runtime. How
Share
TypeDescriptor.AddAttributesonly affects a very specific use-case; i.e. from withinSystem.ComponentModel. For the rest of reflection, it knows nothing about the extra attribute. And indeed,System.ComponentModeldoesn’t really apply to methods or parameters.So in short; you can’t. You will need to store this information somewhere else (bespoke), or add it at compile-time.