Particular / NServiceBus

Build, version, and monitor better microservices with the most powerful service platform for .NET
https://particular.net/nservicebus/
Other
2.07k stars 650 forks source link

`IMessageSerializer` is not registered in DI and cannot be injected when replacing `SerializeMessageConnector` #7076

Open ramonsmits opened 3 weeks ago

ramonsmits commented 3 weeks ago

Describe the suggested improvement

Is your improvement related to a problem? Please describe.

When a user would want to override SerializeMessageConnector the currently configured serialized cannot be injected via IMessageSerializer.

Describe the suggested solution

Register IMessageSerializer during serializer feature setup.

Describe alternatives you've considered

There is a hack to obtain it, but is will not be the same instance and require knowledge of the private string key "MainSerializer":

var settings = context.Settings;
var mainSerializer = settings.Get<Tuple<SerializationDefinition, SettingsHolder>>("MainSerializer");
var serializerFactory = mainSerializer.Item1.Configure(settings);
var serializer = serializerFactory(new MessageMapper());          

Additional Context

No response