workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

Support for Specifying Input Data Type for Assignee in Workflow Serialization

Open nurlanmikayilov opened this issue 8 months ago • 2 comments

In the current implementation, the Assignee in the workflow below cannot be directly converted into a C# class. While this feature may already exist, there is no clear mechanism for specifying the input data type explicitly.

To enhance flexibility and ensure correct deserialization, I propose adding support for specifying the input data type using a property such as:

"DataType": "Workflow.Domain.Data, Workflow.Domain"

This enhancement would allow the deserializer to recognize the intended type and deserialize the object accordingly.

Proposed Solution: • Introduce a mechanism for specifying the input data type within the workflow definition. • Modify the deserializer to interpret the DataType field and convert the data into the corresponding C# class.

Potential Benefits: • Improved type safety in workflow processing. • Enhanced extensibility for handling complex workflow objects. • More robust and maintainable serialization/deserialization.

Please let me know if this feature is already available or if it can be considered for implementation. Thank you!

C# class public class AssigneeInfo { public int Id { get; set; } public string? Name { get; set; } public int MemberType { get; set; } }

Flow Definition: { "Id" : "ce54eaf9-eab1-4ce0-a9c8-3a426bb7569a", "Version" : 1, "DataType" : "Workflow.Domain.Data, Workflow.Domain", "Steps" : [ { "Id" : "6fe991a3-1066-4707-97eb-4d54d398f1e3", "StepType" : "Workflow.Domain.Steps.AssignTaskWait, Workflow.Domain", "Inputs" : { "Assignee" : { "id" : 1, "name" : "User Admin", "memberType" : 1 }, "Reason" : "3" } } ] }

nurlanmikayilov avatar Mar 26 '25 12:03 nurlanmikayilov

What happens if you just use the AssigneeInfo class on the property of the Step implementation?

danielgerlag avatar Mar 26 '25 22:03 danielgerlag

What happens if you just use the AssigneeInfo class on the property of the Step implementation?

WorkflowCore.Services.WorkflowExecutor[0] Workflow 659f2614-ed7f-4b7e-8846-6479e22235ed raised error on step 0 Message: Object of type 'Newtonsoft.Json.Linq.JObject' cannot be converted to type 'Workflow.Domain.Steps.AssignTaskWait+AssigneeInfo'. System.ArgumentException: Object of type 'Newtonsoft.Json.Linq.JObject' cannot be converted to type 'Workflow.Domain.Steps.AssignTaskWait+AssigneeInfo'. at System.RuntimeType.CheckValue(Object& value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) at WorkflowCore.Services.DefinitionStorage.DefinitionLoader.<>c__DisplayClass13_0.<BuildObjectInputAction>g__acn|0(IStepBody pStep, Object pData, IStepExecutionContext pContext) at WorkflowCore.Models.ActionParameter2.Assign(Object data, IStepBody step, IStepExecutionContext context) at WorkflowCore.Models.ActionParameter2.AssignInput(Object data, IStepBody body, IStepExecutionContext context) at WorkflowCore.Services.WorkflowExecutor.ExecuteStep(WorkflowInstance workflow, WorkflowStep step, ExecutionPointer pointer, WorkflowExecutorResult wfResult, WorkflowDefinition def, CancellationToken cancellationToken) at WorkflowCore.Services.WorkflowExecutor.Execute(WorkflowInstance workflow, CancellationToken cancellationToken)

nurlanmikayilov avatar Mar 27 '25 01:03 nurlanmikayilov