Closed schlemmge closed 6 years ago
You can overload ISerializer in your IOC.
Example ISerializer
var customSerializer = new RawRabbit.Serialization.JsonSerializer(new Newtonsoft.Json.JsonSerializer
{
PreserveReferencesHandling = PreserveReferencesHandling.None,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
var busClient = RawRabbitFactory.CreateSingleton(new RawRabbitOptions()
{
ClientConfiguration = clientConfig,
DependencyInjection = ioc => {
ioc.AddSingleton<IChannelFactory, ReplacementChannelFactory>((c) => {
return new ReplacementChannelFactory(c.GetService<IConnectionFactory>(), clientConfig, null);
});
ioc.AddSingleton<IClientPropertyProvider>(new ClientPropertyProvider(endpoint.AmqpConfiguration.QueueName));
ioc.AddSingleton<ISerializer>(customSerializer);
}
});
Thank you, @thyams, for documenting this! Customizing the serialization behaviour is what I did in the first place. My statemant is the unexpected nature of the default behaviour. I see that my point has been taken - issue closed.
Refering to version 2.0.0-rc5: We found that the default json serializer / deserializer used by RawRabbit is configured with the resolver CamelCasePropertyNamesContractResolver. This is a bit irritating - doesn't this kind of resolver brake contracts? I expected my [JsonProperty] annotations to be respected, clients in other languagues may have problems with changed casing by default. And json schema is case-sensitive, too.
Yes, we can work around it and realize that it is not easy to change a default, just wanted you to know that we didn't expect this behavior.
https://github.com/pardahlman/RawRabbit/blob/2.0/src/RawRabbit/DependencyInjection/RawRabbitDependencyRegisterExtension.cs