You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, SerializerContractResolver is telling Json.NET to cache contracts across all instances of itself. This does not work, because using different options (mainly camel case behavior) gives different behavior. Therefore, whatever options is used the first time serializer is called will be used every time.
Example of a failing test.
Establish context = () =>
{
to_serialize = new Dictionary<string, string>
{
{"Key1", "Value1"},
{"Key2", "Value2"},
};
};
Because of = () =>
{
serialized_version = serializer.ToJson(to_serialize);
serialized_version_camel_case = serializer.ToJson(to_serialize, new SerializationOptions { UseCamelCase = true });
};
It should_serialize_the_dictionary = () =>
serialized_version.ShouldEqual("{\"Key1\":\"Value1\",\"Key2\":\"Value2\"}");
It should_serialize_the_dictionary_in_camel_case = () =>
serialized_version_camel_case.ShouldEqual("{\"key1\":\"Value1\",\"key2\":\"Value2\"}");
(It will not be serialized using camel case the second time.)
…n of managing caching yourself. dolittle#676
(See http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Serialization_DefaultContractResolver__ctor_1.htm)
- Refactor SerializationOptions:
- Move from specific properties (UseCamelCase, IncludeTypeNames) to flag enum (SerializationOptionFlags)
- Make static instances for default configurations
- Refactor out interface (ISerializationOptions) that is accepted by ISerializer and SerializerContractResolver
- Create a specific SagaSerializationOptions for use by sagas
- In Serializer, cache serializers based on different options, so that different behaviors are not getting mixed up by JSON
Currently, SerializerContractResolver is telling Json.NET to cache contracts across all instances of itself. This does not work, because using different options (mainly camel case behavior) gives different behavior. Therefore, whatever options is used the first time serializer is called will be used every time.
Example of a failing test.
(It will not be serialized using camel case the second time.)
Quoting from http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Serialization_DefaultContractResolver__ctor_1.htm.
The text was updated successfully, but these errors were encountered: