From 9a82b8b66b79ea35eec7c5c0ab9e0cfb43923e5f Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 4 Jul 2025 09:34:00 +0200 Subject: [PATCH] Add backward compatibility for `WorkflowInstance.Name` mapping in `WorkflowStateMapper` (#6767) * Add backward compatibility for `WorkflowInstance.Name` mapping in `WorkflowStateMapper` - Introduced constant `WorkflowInstanceNameKey` to handle legacy workflow instance name properties. - Updated `MapWorkflowStateToWorkflowInstance` method to set `Name` property for older instances. * Remove unused `Elsa.Workflows.Activities` import from `WorkflowStateMapper` * Update src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Mappers/WorkflowStateMapper.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs index cea8e3a2a..deccb8170 100644 --- a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs +++ b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowStateMapper.cs @@ -1,3 +1,4 @@ +using Elsa.Extensions; using Elsa.Workflows.Management.Entities; using Elsa.Workflows.State; @@ -8,6 +9,12 @@ namespace Elsa.Workflows.Management.Mappers; /// public class WorkflowStateMapper { + /// + /// [Obsolete] The property key name used to store the workflow instance name. + /// + [Obsolete("This constant is obsolete and retained only for backward compatibility. Avoid using it in new code.")] + private const string WorkflowInstanceNameKey = "WorkflowInstanceName"; + /// /// Maps a workflow state to a workflow instance. /// @@ -43,6 +50,10 @@ public class WorkflowStateMapper target.UpdatedAt = source.UpdatedAt; target.FinishedAt = source.FinishedAt; target.WorkflowState = source; + + // Keep for backward compatibility with workflow instances created before the introduction of the Name property. + if (source.Properties.TryGetValue(WorkflowInstanceNameKey, out var name)) + target.Name = name; } ///