I have a custom ContracteResolver and I am getting unpredictable results.
Using the debugger, I see that when I serialize the CreateProperty method of the resolver is called for every property. However, if I make 2 calls back to back the CreateProperty method is not called on the second call. My breakpoint in CreateProperty is never hit on the second pass, it is hit on the first.
Here is my setup:
IContractResolver contractResolver = new ShouldSerializeContractResolver(fieldsToSerialize, this.Data);
var settings = new JsonSerializerSettings()
{
ContractResolver = contractResolver
};
_payload = JsonConvert.SerializeObject(this.Data, Formatting.None, settings);
My source value (this.Data) is different for both calls. The results (_payload) is also different for both call. I don't think anything is being cached.
I saw a similar question that was caused by a custom ContentNegotiator, but I don't use that.
Why would CreateProperty not be hit on the second pass?