Reflection Caching

Topics: Developer Forum
Nov 9, 2006 at 2:15 PM
I looked through your code and I love your style (it matches mine).
One thing I noticed though was that everytime you instantiate a ValidationManager, you run through that type again to grab all the properties. I have written a framework similiar to yours and adopted some of your practices into mine, and have implemented this reflection caching if you are interested.
Basically, the ValidationManager has a private static IDictionary<Type,Validator> member that holds the cached validators so that numerous instantiations don't go through the overhead of getting cached.
Unfortunately, I believe this would be a fundamental change in your library since it is all instance based so...

Just a thought...
Nov 12, 2006 at 11:03 PM
Most people call my coding style "anal" :)

Good point on the caching of attributes. I have raised a work item to have a look into this. I will need to do some analysis of memory usage (of the cache) vrs speed of reading the attributes.
Nov 24, 2006 at 12:13 AM
Well, as far as memory goes, instead of every instance having the same validators instantiated, you would simply have one instance. So, the only memory increase would be if you didn't have any types for the attributes instantiated.

But to implement this, you would need to seperate the validator from the instance, which is a major reworking of your framework.

I had created a framework prior to finding yours and noticed some stuff about yours that I implemented in mine. I wrote an article recently at code project at I encourage you to look at how I handled these problems. I have refactored it a lot since the article to include configuration via an xml file as well.
Nov 24, 2006 at 1:05 PM
Thanks again for the input.
I have done a fair amount of refactoring on the latest Release. Mostly through the use of RuntimeTypeHandle (instead of Type) and using a static cache for keeping track of attributes.
I would appreciate you input on the latest changes.

BTW r u interested in contributing to the project?