Skip to content

Commit

Permalink
Added better generation of Type for SagaEvents.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmdotnet committed Nov 2, 2024
1 parent d7da7c3 commit 3b4ef5b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Framework/Azure/Cqrs.Azure.ServiceBus/AzureServiceBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,23 @@ BrokeredMessage CreateBrokeredMessage
brokeredMessage.SessionId = messageWithOrderingKey.OrderKey;
}
brokeredMessage.AddUserProperty("CorrelationId", brokeredMessage.CorrelationId);
brokeredMessage.AddUserProperty("Type", messageType.FullName);
Type sagaType = typeof(Cqrs.Events.SagaEvent<int>);
string typeName = null;
if (messageType.Assembly == sagaType.Assembly && messageType.Name == sagaType.Name && messageType.Namespace == sagaType.Namespace)
{
PropertyInfo eventProperty = messageType.GetProperty("Event");
if (eventProperty != null)
{
object @event = eventProperty.GetValue(message);
if (@event != null)
{
typeName = $"{messageType.Namespace}.{messageType.Name}{{{@event.GetType().FullName}}}";
}
}
}
if (string.IsNullOrWhiteSpace(typeName))
typeName = messageType.FullName;
brokeredMessage.AddUserProperty("Type", typeName);
brokeredMessage.AddUserProperty("Source", $"{Logger.LoggerSettings.ModuleName}/{Logger.LoggerSettings.Instance}/{Logger.LoggerSettings.Environment}/{Logger.LoggerSettings.EnvironmentInstance}");
brokeredMessage.AddUserProperty("Framework",
// this compiler directive is intentionally .NET Core and not 4.8
Expand Down

0 comments on commit 3b4ef5b

Please sign in to comment.