Serialize properties in derived classes (#1732)

System.Text.Json serializes based on static type of value parameter. Polymorphic serialization requires type information
This commit is contained in:
Michael Gregson 2021-09-15 10:46:26 +01:00 committed by GitHub
parent e57a97d515
commit 8807359057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@
public void Publish(IntegrationEvent @event)
{
var eventName = @event.GetType().Name.Replace(INTEGRATION_EVENT_SUFFIX, "");
var jsonMessage = JsonSerializer.Serialize(@event);
var jsonMessage = JsonSerializer.Serialize(@event, @event.GetType());
var body = Encoding.UTF8.GetBytes(jsonMessage);
var message = new Message