I have a certain collection of built-in attributes (like System.Runtime.Serialization.SerializableAttribute) that I want to apply to a certain collection of classes
Is it possible to unite those attributes into one? I don't want to apply all of them to all of my classes explicitly (the attibute collection might change during the development process)
What I want is one attribute, e.g.
public class MyClassAttribute: System.Attribute { ... }
which I could apply easily to my classes
[MyClass]
public class SampleClass { ... }
and that would cause SampleClass to have Serializable attribute and others. Thanks
No, it is not, basically. Actually, [Serializable]
is particularly note-worthy because that has different treatment in the compiler - it is not written as an attribute, but as a raw flag (the runtime simply lies if you ask "does it have the [Serializable]
attribute" - it checks the flag against the type, and returns what you expect to see, even though that isn't the truth).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With