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>
This commit is contained in:
Sipke Schoorstra 2025-07-04 09:34:00 +02:00 committed by GitHub
parent ea9c94de7e
commit 9a82b8b66b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
/// </summary>
public class WorkflowStateMapper
{
/// <summary>
/// [Obsolete] The property key name used to store the workflow instance name.
/// </summary>
[Obsolete("This constant is obsolete and retained only for backward compatibility. Avoid using it in new code.")]
private const string WorkflowInstanceNameKey = "WorkflowInstanceName";
/// <summary>
/// Maps a workflow state to a workflow instance.
/// </summary>
@ -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<string>(WorkflowInstanceNameKey, out var name))
target.Name = name;
}
/// <summary>