1.. Is there any performance overhead caused by the usage of attributes? Think for a class like:
public class MyClass
{
int Count {get;set;}
}
where it has 10 attibutes (attributes being classes, where the attribute classes themselves are way larger than MyClass itself like:
public class FirstAttribute : Attribute
{
int A,B,C,D,E,F,G,H,I,J ... {get;set;}
}
2.. Would 10 of these attributes be a memory overhead everytime MyClass
is instantiated? (FirstAttribute
being 10 times the size of MyClass
which will be decorated with 10 of these, so making the actual object itself so small compared to the total size of the attributes that are decorated on it.) Is this a concern?
3.. Would this scenario be any different for structs (Structs being value types and attributes being reference types)?
4.. Where are attibutes stored in memory in relation to the object that they are attached? How are they hooked together?
5.. Are attributes initialized as soon as MyClass
is initialized or when you use reflection to retrieve them?