-
Notifications
You must be signed in to change notification settings - Fork 36
DSL example #122
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
DSL example #122
Conversation
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.
Looks great, nothing blocking necessarily, just pedantic code structure things
src/Dsl/DslTypes.cs
Outdated
| required public ParallelBranches Parallel { get; init; } | ||
| } | ||
|
|
||
| public record DslInput |
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.
Pedantic, but I think this should be the top-level type (and file name), and it should have a static Parse() and all of these other records should be inner classes of it.
src/Dsl/DslWorkflow.workflow.cs
Outdated
| private Dictionary<string, object> variables = new(); | ||
|
|
||
| [WorkflowRun] | ||
| public async Task<Dictionary<string, object>> RunAsync(DslInput input) | ||
| { | ||
| variables = new Dictionary<string, object>(input.Variables); |
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.
I would recommend using [WorkflowInit] for this. E.g.
private readonly Dictionary<string, object> variables;
[WorkflowInit]
public DslWorkflow(DslInput input) => variables = input.Variables;
src/Dsl/DslWorkflow.workflow.cs
Outdated
| case ActivityStatement activityStmt: | ||
| // Invoke activity loading arguments from variables and optionally storing result as a variable | ||
| var args = activityStmt.Activity.Arguments | ||
| .Select(argName => variables.TryGetValue(argName, out var value) ? value : string.Empty) |
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.
Would be ok using index accessor and letting this just throw on key not found to keep logic simpler
cretz
left a comment
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.
Thanks!
Closes Sample request: DSL #19
How was this tested:
Manually + tests.
Any docs updates needed?
README updated