Custom Contract Resolver performance overhead

Feb 25, 2014 at 3:26 PM
I am using CustomContractResolver which inherits from DefaultContractResolver, because I need to change properties' names (of types that cannot be modified i.e. by adding attributes) while serializing them to json. I achieved needed functionality, but I have noticed huge performance overhead. I am assuming that it is caused by reflection, but I am not sure why (because my CustomContractResolver inherits startight from the default one, I only overrides one method: ResolvePropertyName). Is there way to avoid it?
The overhead seems to be really huge. I have run simple test: serialize simple object 10000 times in a loop, using both methods. Serialization using default resolver took about 150ms, and using the custom one took about 15s.