-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for input parameter array initialization #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
30fab35
Normalize newlines
boma96 259fd3e
Add test case
boma96 5748557
Add test case
boma96 f9bd9fd
Add test case
boma96 ef420d9
Add test case
boma96 c33c0df
Merge branch 'master' into feat/master/add-test-cases
boma96 d8cc137
Move object initialization into separate method
boma96 39ae3db
Rename classes
boma96 885ab73
Fix bug if Members property is null
boma96 f9718ad
Use renamed classes
boma96 d9c8898
Add else case
boma96 dc7b453
Add support for arrays
boma96 1867789
Merge branch 'feat/master/add-test-cases' into feat/master/array-init…
boma96 7701a4d
Add test case
boma96 9a5b4e5
Merge master into feat/master/array-initialization
boma96 fe6039c
Use two tasks
boma96 cc24cf4
Remove unnecessary method
boma96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/ConductorSharp.Engine.Tests/Samples/Tasks/ArrayTask.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace ConductorSharp.Engine.Tests.Samples.Tasks | ||
| { | ||
| public class ArrayTaskInput : IRequest<ArrayTaskOutput> | ||
| { | ||
| public class TestModel | ||
| { | ||
| public string String { get; set; } | ||
| } | ||
|
|
||
| public int[] Integers { get; set; } | ||
| public TestModel[] Models { get; set; } | ||
| public object Objects { get; set; } | ||
| } | ||
|
|
||
| public class ArrayTaskOutput { } | ||
|
|
||
| public class ArrayTask : SimpleTaskModel<ArrayTaskInput, ArrayTaskOutput> { } | ||
| } |
51 changes: 51 additions & 0 deletions
51
test/ConductorSharp.Engine.Tests/Samples/Workflows/Arrays.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace ConductorSharp.Engine.Tests.Samples.Workflows | ||
| { | ||
| public class ArrayInput : WorkflowInput<ArrayOutput> { } | ||
|
|
||
| public class ArrayOutput : WorkflowOutput { } | ||
|
|
||
| public class Arrays : Workflow<ArrayInput, ArrayOutput> | ||
| { | ||
| public ArrayTask ArrayTask1 { get; set; } | ||
| public ArrayTask ArrayTask2 { get; set; } | ||
|
|
||
| public override WorkflowDefinition GetDefinition() | ||
| { | ||
| var builder = new WorkflowDefinitionBuilder<Arrays>(); | ||
|
|
||
| builder.AddTask( | ||
| wf => wf.ArrayTask1, | ||
| wf => | ||
| new() | ||
| { | ||
| Integers = new[] { 1, 2, 3 }, | ||
| Models = new[] | ||
| { | ||
| new ArrayTaskInput.TestModel { String = "Test1" }, | ||
| new ArrayTaskInput.TestModel { String = "Test2" } | ||
| }, | ||
| Objects = new dynamic[] { new { AnonymousObjProp = "Prop" }, new { Test = "Prop" } } | ||
| } | ||
| ); | ||
|
|
||
| builder.AddTask( | ||
| wf => wf.ArrayTask2, | ||
| wf => | ||
| new() | ||
| { | ||
| Integers = new int[] { }, | ||
| Models = new ArrayTaskInput.TestModel[] { }, | ||
| Objects = new dynamic[] { } | ||
| } | ||
| ); | ||
|
|
||
| return builder.Build(opts => opts.Version = 1); | ||
| } | ||
| } | ||
| } |
112 changes: 112 additions & 0 deletions
112
test/ConductorSharp.Engine.Tests/Samples/Workflows/Arrays.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| { | ||
| "ownerApp": null, | ||
| "createTime": 0, | ||
| "updateTime": 0, | ||
| "createdBy": null, | ||
| "updatedBy": null, | ||
| "name": "arrays", | ||
| "description": "{\"description\":null,\"labels\":null}", | ||
| "version": 1, | ||
| "tasks": [ | ||
| { | ||
| "queryExpression": null, | ||
| "name": "array_task", | ||
| "taskReferenceName": "array_task1", | ||
| "description": "{\"description\":null}", | ||
| "inputParameters": { | ||
| "integers": [ | ||
| "1", | ||
| "2", | ||
| "3" | ||
| ], | ||
| "models": [ | ||
| { | ||
| "string": "Test1" | ||
| }, | ||
| { | ||
| "string": "Test2" | ||
| } | ||
| ], | ||
| "objects": [ | ||
| { | ||
| "anonymous_obj_prop": "Prop" | ||
| }, | ||
| { | ||
| "test": "Prop" | ||
| } | ||
| ] | ||
| }, | ||
| "type": "SIMPLE", | ||
| "dynamicTaskNameParam": null, | ||
| "caseValueParam": null, | ||
| "caseExpression": null, | ||
| "expression": null, | ||
| "evaluatorType": null, | ||
| "scriptExpression": null, | ||
| "decisionCases": null, | ||
| "dynamicForkJoinTasksParam": null, | ||
| "dynamicForkTasksParam": null, | ||
| "dynamicForkTasksInputParamName": null, | ||
| "defaultCase": null, | ||
| "forkTasks": null, | ||
| "startDelay": 0, | ||
| "subWorkflowParam": null, | ||
| "joinOn": null, | ||
| "sink": null, | ||
| "optional": false, | ||
| "taskDefinition": null, | ||
| "rateLimited": false, | ||
| "defaultExclusiveJoinTask": null, | ||
| "asyncComplete": false, | ||
| "loopCondition": null, | ||
| "loopOver": null | ||
| }, | ||
| { | ||
| "queryExpression": null, | ||
| "name": "array_task", | ||
| "taskReferenceName": "array_task2", | ||
| "description": "{\"description\":null}", | ||
| "inputParameters": { | ||
| "integers": [], | ||
| "models": [], | ||
| "objects": [] | ||
| }, | ||
| "type": "SIMPLE", | ||
| "dynamicTaskNameParam": null, | ||
| "caseValueParam": null, | ||
| "caseExpression": null, | ||
| "expression": null, | ||
| "evaluatorType": null, | ||
| "scriptExpression": null, | ||
| "decisionCases": null, | ||
| "dynamicForkJoinTasksParam": null, | ||
| "dynamicForkTasksParam": null, | ||
| "dynamicForkTasksInputParamName": null, | ||
| "defaultCase": null, | ||
| "forkTasks": null, | ||
| "startDelay": 0, | ||
| "subWorkflowParam": null, | ||
| "joinOn": null, | ||
| "sink": null, | ||
| "optional": false, | ||
| "taskDefinition": null, | ||
| "rateLimited": false, | ||
| "defaultExclusiveJoinTask": null, | ||
| "asyncComplete": false, | ||
| "loopCondition": null, | ||
| "loopOver": null | ||
| } | ||
| ], | ||
| "inputParameters": [ | ||
| "{}" | ||
| ], | ||
| "outputParameters": null, | ||
| "failureWorkflow": null, | ||
| "schemaVersion": 2, | ||
| "restartable": true, | ||
| "workflowStatusListenerEnabled": true, | ||
| "ownerEmail": null, | ||
| "timeoutPolicy": null, | ||
| "timeoutSeconds": 0, | ||
| "variables": null | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to return [ 1,2,3] as ["1", "2", "3"]. The reason is
@boma96
We can extract the correct type, but this might break something somewhere. However, most frameworks seem to be equipped to handle string to int conversion automatically if it is really convertible. I think we should do this, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will also break our tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing this out, did not notice it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will make separate PR for this