Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does adding [DataContract] and [DataMember] to all classes impact performance

Lets say we got a code generating tool that creates thousands of C# classes, and we sometimes need to add those attributes to them.

We are considering whether it is better to put [DataContract] and [DataMember] on all appropriate classes or we need to create a special strategy that will determine whether to do so in order to save up some possible? performance lost in AtribbuteAll approach.

In the end the question is whether adding attributes can somehow affect performance?

I am thinking that adding an attribute on a class will simply stay with its type information and should not affect any performance but would like to be 100% certain here

like image 880
Valentin Kuzub Avatar asked Oct 10 '22 21:10

Valentin Kuzub


1 Answers

Adding attributes would impact in performance if these are inspected in some part of the code, if not, classes would have more metadata, but this doesn't impact performance.

like image 115
Matías Fidemraizer Avatar answered Oct 18 '22 21:10

Matías Fidemraizer