-
Historically, in code that deals with reflection types, I've often stored the result of Also should extra care be taken to avoid repeated identical calls to I assume that objects from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You should never use compile-time static fields because, as you mentioned, their value depends on the compilation context, and static fields are shared across several compilations. Aspect classes are even serialized in cross-project scenarios (like cross-project inheritance) so you should design aspects as immutable classes. You should not spend additional effort to cache calls to Now if you are asking about caching |
Beta Was this translation helpful? Give feedback.
You should never use compile-time static fields because, as you mentioned, their value depends on the compilation context, and static fields are shared across several compilations. Aspect classes are even serialized in cross-project scenarios (like cross-project inheritance) so you should design aspects as immutable classes.
You should not spend additional effort to cache calls to
TypeFactory.GetType
or similar methods because these are already cached. You should just pay attention to call these methods outside of loops.Now if you are asking about caching
System.Reflection
objects in the run-time code generated by aspects, then yes, it's probably something you should take care of. Unlike…