diff --git a/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj b/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj index e48fa21f3..3da8ad6f1 100644 --- a/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj +++ b/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj @@ -77,6 +77,7 @@ + diff --git a/src/modules/Elsa.Workflows.Core/Abstractions/WorkflowBase.cs b/src/modules/Elsa.Workflows.Core/Abstractions/WorkflowBase.cs index 303cbcfc6..3e581b44e 100644 --- a/src/modules/Elsa.Workflows.Core/Abstractions/WorkflowBase.cs +++ b/src/modules/Elsa.Workflows.Core/Abstractions/WorkflowBase.cs @@ -52,7 +52,7 @@ public abstract class WorkflowBase : WorkflowBase /// protected WorkflowBase() { - Result = new Variable(); + Result = new("Result", default!); } /// diff --git a/src/modules/Elsa.Workflows.Core/Activities/ParallelForEach.cs b/src/modules/Elsa.Workflows.Core/Activities/ParallelForEach.cs index ea8765948..c8fed303a 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/ParallelForEach.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/ParallelForEach.cs @@ -10,7 +10,7 @@ namespace Elsa.Workflows.Activities; public class ParallelForEach : ParallelForEach { /// - public ParallelForEach([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) + public ParallelForEach([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) { } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Activities/ParallelForEachT.cs b/src/modules/Elsa.Workflows.Core/Activities/ParallelForEachT.cs index 5960d9a89..274141172 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/ParallelForEachT.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/ParallelForEachT.cs @@ -20,7 +20,7 @@ public class ParallelForEach : Activity private const string CompletedTagsProperty = nameof(CompletedTagsProperty); /// - public ParallelForEach([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) + public ParallelForEach([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) { } @@ -34,7 +34,7 @@ public class ParallelForEach : Activity /// The to execute each iteration. /// [Port] - public IActivity Body { get; set; } = default!; + public IActivity Body { get; set; } = null!; /// protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) diff --git a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs index c813ada31..fb48a93b8 100644 --- a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs +++ b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs @@ -72,9 +72,10 @@ public class WorkflowBuilder(IActivityVisitor activityVisitor, IIdentityGraphSer } /// + [Obsolete("Use the overload that takes a name instead. This overload will be removed in a future version.")] public Variable WithVariable() { - var variable = new Variable(); + var variable = new Variable(null!, default!); Variables.Add(variable); variable.WithWorkflowStorage(); variable.Id = null!; // This ensures that a deterministic ID is assigned by the builder. @@ -84,13 +85,13 @@ public class WorkflowBuilder(IActivityVisitor activityVisitor, IIdentityGraphSer /// public Variable WithVariable(string name, T value) { - var variable = WithVariable(); - variable.Name = name; - variable.Value = value; + var variable = new Variable(name, value); + Variables.Add(variable); return variable; } /// + [Obsolete("Use the overload that takes a name instead. This overload will be removed in a future version.")] public Variable WithVariable(T value) { var variable = WithVariable(); diff --git a/src/modules/Elsa.Workflows.Core/Memory/Variable.cs b/src/modules/Elsa.Workflows.Core/Memory/Variable.cs index d3ed28f2f..47a33dd29 100644 --- a/src/modules/Elsa.Workflows.Core/Memory/Variable.cs +++ b/src/modules/Elsa.Workflows.Core/Memory/Variable.cs @@ -1,5 +1,7 @@ +using System.Text.Json.Serialization; using Elsa.Expressions.Helpers; using Elsa.Expressions.Models; +using Humanizer; namespace Elsa.Workflows.Memory; @@ -11,19 +13,23 @@ public class Variable : MemoryBlockReference /// public Variable() { - Id = Guid.NewGuid().ToString("N"); } /// - public Variable(string name) : this() + public Variable(string name) { + Id = GetIdFromName(name); Name = name; } /// - public Variable(string name, object? value = null) : this() + public Variable(string name, object? value = null) : this(name) + { + Value = value; + } + + public Variable(string name, object? value = null, string? id = null) : this(name, value) { - Name = name; Value = value; } @@ -45,6 +51,8 @@ public class Variable : MemoryBlockReference /// public override MemoryBlock Declare() => new(Value, new VariableBlockMetadata(this, StorageDriverType, false)); + + private string GetIdFromName(string? name) => $"{name?.Camelize() ?? "Unnamed"}{nameof(Variable)}"; } /// @@ -59,16 +67,19 @@ public class Variable : Variable } /// + [Obsolete("Use the constructor that takes a name parameter instead.", true)] public Variable(T value) { Value = value; } /// - public Variable(string name, T value) + public Variable(string name, T value) : base(name, value) + { + } + + public Variable(string name, T value, string? id = null) : base(name, value, id) { - Name = name; - Value = value; } /// @@ -95,6 +106,18 @@ public class Variable : Variable Id = id; return this; } + + public Variable WithName(string name) + { + Name = name; + return this; + } + + public Variable WithValue(T value) + { + Value = value; + return this; + } } /// diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow1.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow1.cs index ea7ebdc89..530fa8736 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow1.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow1.cs @@ -11,6 +11,6 @@ public class JavaScriptVariablesWorkflow1 : WorkflowBase { builder.WithDefinitionId(DefinitionId); builder.WithVariable("MagicNumber", 3).WithWorkflowStorage(); - builder.Root = new RunJavaScript("setMagicNumber(42)", default, default); + builder.Root = new RunJavaScript("setMagicNumber(42)", null, null); } } \ No newline at end of file diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow2.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow2.cs index d6684b401..23a2e00ce 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow2.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow2.cs @@ -11,6 +11,6 @@ public class JavaScriptVariablesWorkflow2 : WorkflowBase { builder.WithDefinitionId(DefinitionId); builder.WithVariable("MagicNumber", 3).WithWorkflowStorage(); - builder.Root = new RunJavaScript("variables.MagicNumber = 42", default, default); + builder.Root = new RunJavaScript("variables.MagicNumber = 42", null, null); } } \ No newline at end of file diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow3.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow3.cs index 34486085e..b62061c67 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow3.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflow3.cs @@ -11,6 +11,6 @@ public class JavaScriptVariablesWorkflow3 : WorkflowBase { builder.WithDefinitionId(DefinitionId); builder.WithVariable("MagicNumber", 3).WithWorkflowStorage(); - builder.Root = new RunJavaScript("setVariable('MagicNumber', 42)", default, default); + builder.Root = new RunJavaScript("setVariable('MagicNumber', 42)", null, null); } } \ No newline at end of file diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflowTests.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflowTests.cs index c2876f599..a119f743d 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflowTests.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/JavaScriptVariables/JavaScriptVariablesWorkflowTests.cs @@ -30,7 +30,7 @@ public class JavaScriptVariablesWorkflowTests(App app) : AppComponentTest(app) var workflowState = workflowInstance!.WorkflowState; var rootWorkflowActivityExecutionContext = workflowState.ActivityExecutionContexts.Single(x => x.ParentContextId == null); var variables = GetVariablesDictionary(rootWorkflowActivityExecutionContext); - var magicNumber = variables["Workflow1:variable-1"].ConvertTo(); + var magicNumber = variables["magicNumberVariable"].ConvertTo(); Assert.Equal(42, magicNumber); } diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/CountdownWorkflowTests.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/CountdownWorkflowTests.cs index a09a46863..031242e4f 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/CountdownWorkflowTests.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/CountdownWorkflowTests.cs @@ -1,3 +1,4 @@ +using Elsa.Common.Models; using Elsa.Expressions.Helpers; using Elsa.Extensions; using Elsa.Workflows.ComponentTests.Abstractions; @@ -25,7 +26,7 @@ public class CountdownWorkflowTests(App app) : AppComponentTest(app) var bookmarkStore = Scope.ServiceProvider.GetRequiredService(); var runAndCreateRequest = new CreateAndRunWorkflowInstanceRequest { - WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionId(CountdownWorkflow.DefinitionId), + WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionId(CountdownWorkflow.DefinitionId, VersionOptions.Latest), }; var runResponse = await workflowClient.CreateAndRunInstanceAsync(runAndCreateRequest); var workflowInstanceId = runResponse.WorkflowInstanceId; @@ -42,7 +43,7 @@ public class CountdownWorkflowTests(App app) : AppComponentTest(app) var workflowState = workflowInstance!.WorkflowState; var rootWorkflowActivityExecutionContext = workflowState.ActivityExecutionContexts.Single(x => x.ParentContextId == null); var variables = GetVariablesDictionary(rootWorkflowActivityExecutionContext); - var actualCounter = variables["Workflow1:variable-1"].ConvertTo(); + var actualCounter = variables["counterVariable"].ConvertTo(); Assert.Equal(--expectedCounter, actualCounter); var bookmark = bookmarks.Pop(); diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/Workflows/CountdownWorkflow.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/Workflows/CountdownWorkflow.cs index 696ccd5f0..b71a70291 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/Workflows/CountdownWorkflow.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Variables/Workflows/CountdownWorkflow.cs @@ -6,29 +6,29 @@ namespace Elsa.Workflows.ComponentTests.Scenarios.Variables.Workflows; public class CountdownWorkflow : WorkflowBase { - public static readonly string DefinitionId = Guid.NewGuid().ToString(); + public static readonly string DefinitionId = "Guid.NewGuid().ToString()"; protected override void Build(IWorkflowBuilder builder) { builder.WithDefinitionId(DefinitionId); - var counter = builder.WithVariable("Counter", 3).WithWorkflowStorage(); - - builder.Root = new Sequence - { - Activities = - { - new While(context => counter.Get(context) > 0) - { - Body = new Sequence - { - Activities = - { - new WriteLine(context => $"Counter: {counter.Get(context)}"), - new CountdownStep() - } - } - } - } - }; + // var counter = builder.WithVariable("Counter", 3).WithWorkflowStorage(); + // + // builder.Root = new Sequence + // { + // Activities = + // { + // new While(context => counter.Get(context) > 0) + // { + // Body = new Sequence + // { + // Activities = + // { + // new WriteLine(context => $"Counter: {counter.Get(context)}"), + // new CountdownStep() + // } + // } + // } + // } + // }; } } \ No newline at end of file diff --git a/test/integration/Elsa.JavaScript.IntegrationTests/JsonElementConverterTests.cs b/test/integration/Elsa.JavaScript.IntegrationTests/JsonElementConverterTests.cs index b7203e554..c2c57695f 100644 --- a/test/integration/Elsa.JavaScript.IntegrationTests/JsonElementConverterTests.cs +++ b/test/integration/Elsa.JavaScript.IntegrationTests/JsonElementConverterTests.cs @@ -17,12 +17,8 @@ public class JsonElementConverterTests(ITestOutputHelper testOutputHelper) public async Task TestJsonObjectPassedAsJsonElement() { var javaScriptEvaluator = _serviceProvider.GetRequiredService(); - var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); - var jsonVariable = new Variable - { - Name = "JsonVariable" - }; - + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + var jsonVariable = new Variable("JsonVariable", ""); var jsonString = "{\"name\": \"John\", \"age\": 30}"; var jsonElement = JsonSerializer.Deserialize(jsonString); @@ -36,12 +32,8 @@ public class JsonElementConverterTests(ITestOutputHelper testOutputHelper) public async Task TestJsonArrayPassedAsJsonElement() { var javaScriptEvaluator = _serviceProvider.GetRequiredService(); - var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); - var jsonVariable = new Variable - { - Name = "JsonVariable" - }; - + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + var jsonVariable = new Variable("JsonVariable", ""); var jsonString = "[1, 2, 3, 4, 5, 6]"; var jsonElement = JsonSerializer.Deserialize(jsonString); @@ -55,12 +47,8 @@ public class JsonElementConverterTests(ITestOutputHelper testOutputHelper) public async Task TestStringPassedAsJsonElement() { var javaScriptEvaluator = _serviceProvider.GetRequiredService(); - var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); - var jsonVariable = new Variable - { - Name = "JsonVariable" - }; - + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + var jsonVariable = new Variable("JsonVariable", ""); var jsonString = "\"I'm just a string\""; var jsonElement = JsonSerializer.Deserialize(jsonString); @@ -74,12 +62,8 @@ public class JsonElementConverterTests(ITestOutputHelper testOutputHelper) public async Task TestBooleanPassedAsJsonElement() { var javaScriptEvaluator = _serviceProvider.GetRequiredService(); - var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); - var jsonVariable = new Variable - { - Name = "JsonVariable" - }; - + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + var jsonVariable = new Variable("JsonVariable", ""); var jsonString = "false"; var jsonElement = JsonSerializer.Deserialize(jsonString); @@ -93,11 +77,8 @@ public class JsonElementConverterTests(ITestOutputHelper testOutputHelper) public async Task TestNestedJsonPassedAsJsonElement() { var javaScriptEvaluator = _serviceProvider.GetRequiredService(); - var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); - var jsonVariable = new Variable - { - Name = "JsonVariable" - }; + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + var jsonVariable = new Variable("JsonVariable", ""); var jsonString = @" { diff --git a/test/integration/Elsa.JavaScript.IntegrationTests/ToJsonTests.cs b/test/integration/Elsa.JavaScript.IntegrationTests/ToJsonTests.cs index 4a0b11fd8..2e1caced0 100644 --- a/test/integration/Elsa.JavaScript.IntegrationTests/ToJsonTests.cs +++ b/test/integration/Elsa.JavaScript.IntegrationTests/ToJsonTests.cs @@ -31,10 +31,7 @@ public class ToJsonTests(ITestOutputHelper testOutputHelper) var javaScriptEvaluator = _serviceProvider.GetRequiredService(); var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new MemoryRegister()); var unicodeString = UnicodeRangeGenerator.GenerateUnicodeString(); - var payloadVariable = new Variable - { - Name = "Payload" - }; + var payloadVariable = new Variable("Payload", null!); var payload = new { Text = unicodeString diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForEachWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForEachWorkflow.cs index 0c1613818..1a00cc3f3 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForEachWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForEachWorkflow.cs @@ -1,6 +1,5 @@ using Elsa.Workflows.Activities; using Elsa.Workflows.Memory; -using Elsa.Workflows.Models; namespace Elsa.Workflows.IntegrationTests.Activities.Workflows; @@ -9,7 +8,7 @@ class BreakForEachWorkflow : WorkflowBase protected override void Build(IWorkflowBuilder workflow) { var items = new[] { "C#", "Rust", "Go" }; - var currentItem = new Variable(); + var currentItem = new Variable("CurrentItem", ""); workflow.Root = new Sequence { @@ -18,7 +17,7 @@ class BreakForEachWorkflow : WorkflowBase new WriteLine("Start"), new ForEach { - Items = new Input>(items), + Items = new(items), CurrentValue = new (currentItem), Body = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForWorkflow.cs index afbed58ae..6766297f6 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakForWorkflow.cs @@ -7,7 +7,7 @@ class BreakForWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable(); + var currentValue = new Variable("CurrentValue", null); workflow.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileForkWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileForkWorkflow.cs index f83747741..8574327b9 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileForkWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileForkWorkflow.cs @@ -8,11 +8,7 @@ public class BreakWhileForkWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable - { - Name = "CurrentValue", - Value = 0 - }; + var currentValue = new Variable("CurrentValue", 0); workflow.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileWorkflow.cs index e475973d0..999a418cf 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/Workflows/BreakWhileWorkflow.cs @@ -7,7 +7,7 @@ public class BreakWhileWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable(0); + var currentValue = new Variable("CurrentValue", 0); workflow.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/ForEachWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/ForEachWorkflow.cs index 3a57ce375..7c979ba77 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/ForEachWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/ForEachWorkflow.cs @@ -1,6 +1,5 @@ using Elsa.Workflows.Activities; using Elsa.Workflows.Memory; -using Elsa.Workflows.Models; namespace Elsa.Workflows.IntegrationTests.Activities; @@ -15,10 +14,7 @@ class ForEachWorkflow : WorkflowBase protected override void Build(IWorkflowBuilder workflow) { - var currentItem = new Variable - { - Name = "CurrentItem" - }; + var currentItem = new Variable("CurrentItem", ""); workflow.Root = new Sequence { @@ -27,8 +23,8 @@ class ForEachWorkflow : WorkflowBase { new ForEach { - Items = new Input>(_items), - CurrentValue = new Output(currentItem), + Items = new(_items), + CurrentValue = new(currentItem), Body = new WriteLine(currentItem) }, } diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/NestedForEachWithBreakWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/NestedForEachWithBreakWorkflow.cs index 9e477bb55..38b718be0 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/NestedForEachWithBreakWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Activities/ForEach/NestedForEachWithBreakWorkflow.cs @@ -9,8 +9,8 @@ class NestedForEachWithBreakWorkflow : WorkflowBase { var outerItems = new[] { "C#", "Rust", "Go" }; var innerItems = new[] { "Classes", "Functions", "Modules" }; - var currentOuterItem = new Variable(); - var currentInnerItem = new Variable(); + var currentOuterItem = new Variable("CurrentOuterItem", ""); + var currentInnerItem = new Variable("CurrentInnerItem", ""); workflow.Root = new ForEach(outerItems) { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ActivityOutputs/SumWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ActivityOutputs/SumWorkflow.cs index 9881b9996..db46e57ca 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ActivityOutputs/SumWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ActivityOutputs/SumWorkflow.cs @@ -8,8 +8,8 @@ public class SumWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var a = new Variable(); - var b = new Variable(); + var a = new Variable("A", 0); + var b = new Variable("B", 0); var sumActivity = new SumActivity(a, b); diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/BreakWhileFromForkWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/BreakWhileFromForkWorkflow.cs index e642d7fda..80c77f707 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/BreakWhileFromForkWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/BreakWhileFromForkWorkflow.cs @@ -8,7 +8,7 @@ public class BreakWhileFromForkWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable(0); + var currentValue = new Variable("CurrentValue", 0); workflow.WithVariable(currentValue); diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAllForkWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAllForkWorkflow.cs index 0a4a6e274..a569ee982 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAllForkWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAllForkWorkflow.cs @@ -8,7 +8,7 @@ public class WaitAllForkWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable(0); + var currentValue = new Variable("CurrentValue", 0); workflow.WithVariable(currentValue); diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAnyForkWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAnyForkWorkflow.cs index 014dd9da6..8aef393df 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAnyForkWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/BlockingAndBreaking/Workflows/WaitAnyForkWorkflow.cs @@ -8,7 +8,7 @@ public class WaitAnyForkWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var currentValue = new Variable(0); + var currentValue = new Variable("CurrentValue", 0); workflow.WithVariable(currentValue); diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/Composites/Workflows.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/Composites/Workflows.cs index a998cae72..e70ea8733 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/Composites/Workflows.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/Composites/Workflows.cs @@ -13,12 +13,12 @@ public class Sum : Composite { private readonly RunJavaScript _runJavaScript; - public Input A { get; set; } = default!; - public Input B { get; set; } = default!; + public Input A { get; set; } = null!; + public Input B { get; set; } = null!; public Sum() { - _runJavaScript = new RunJavaScript + _runJavaScript = new() { Script = new("getA() + getB();"), }; @@ -42,7 +42,7 @@ public class Sum : Composite // If the call site set a result variable, assign it to the JavaScript activity's result. if (Result != null) - _runJavaScript.Result = new Output(Result.MemoryBlockReference)!; + _runJavaScript.Result = new(Result.MemoryBlockReference)!; } } @@ -53,11 +53,10 @@ public class SumWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var sum = new Variable(); + var sum = workflow.WithVariable("Sum", 0); workflow.Root = new Sequence { - Variables = { sum }, Activities = { new Sum diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/HttpRequestWithLiquid/JavascriptAndLiquidWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/HttpRequestWithLiquid/JavascriptAndLiquidWorkflow.cs index 88bf7021a..c0e95dd3f 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/HttpRequestWithLiquid/JavascriptAndLiquidWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/HttpRequestWithLiquid/JavascriptAndLiquidWorkflow.cs @@ -12,8 +12,8 @@ public class JavascriptAndLiquidWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder builder) { - var products = new Variable { Name = "Products", StorageDriverType = typeof(WorkflowInstanceStorageDriver) }; - var product = new Variable { Name = "Product", StorageDriverType = typeof(WorkflowInstanceStorageDriver) }; + var products = new Variable("Products", null!).WithStorageDriver(); + var product = new Variable("Product", null!).WithStorageDriver(); builder.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ImplicitJoins/ParallelJoinCompletesTests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ImplicitJoins/ParallelJoinCompletesTests.cs index c59d36291..cefc1f76b 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ImplicitJoins/ParallelJoinCompletesTests.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/ImplicitJoins/ParallelJoinCompletesTests.cs @@ -24,13 +24,13 @@ public class ParallelJoinCompletesTests await _services.PopulateRegistriesAsync(); // Import workflow. - var workflowDefinition = await _services.ImportWorkflowDefinitionAsync($"Scenarios/ImplicitJoins/Workflows/parallel-join.json"); + var workflowDefinition = await _services.ImportWorkflowDefinitionAsync("Scenarios/ImplicitJoins/Workflows/parallel-join.json"); // Execute. var state = await _services.RunWorkflowUntilEndAsync(workflowDefinition.DefinitionId); // Assert. - var journal = await _services.GetRequiredService().FindManyAsync(new WorkflowExecutionLogRecordFilter + var journal = await _services.GetRequiredService().FindManyAsync(new() { WorkflowInstanceId = state.Id, ActivityId = "70fc1183cd5800f2", diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariables/Workflows.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariables/Workflows.cs index 367a7674a..9f03feef1 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariables/Workflows.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariables/Workflows.cs @@ -8,7 +8,7 @@ class SetGetVariableWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var variable1 = new Variable(); + var variable1 = new Variable("Variable1", ""); workflow.Root = new Sequence { @@ -30,8 +30,8 @@ class SetGetVariablesWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var variable1 = new Variable(); - var variable2 = new Variable(); + var variable1 = new Variable("Variable1", ""); + var variable2 = new Variable("Variable2", ""); workflow.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariablesFromActivities/Workflows/SampleWorkflow.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariablesFromActivities/Workflows/SampleWorkflow.cs index 77c312170..bd343f872 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariablesFromActivities/Workflows/SampleWorkflow.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/SetGetVariablesFromActivities/Workflows/SampleWorkflow.cs @@ -8,7 +8,7 @@ class SampleWorkflow : WorkflowBase { protected override void Build(IWorkflowBuilder workflow) { - var variable1 = new Variable(); + var variable1 = new Variable("Variable1", ""); workflow.Root = new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowResults/Tests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowResults/Tests.cs index 99c594657..95f71259c 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowResults/Tests.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowResults/Tests.cs @@ -23,7 +23,7 @@ public class Tests { await _services.PopulateRegistriesAsync(); var expectedValue = "Some value"; - var variable1 = new Variable(); + var variable1 = new Variable("Variable1"); var workflow = Workflow.FromActivity(new Sequence { @@ -46,7 +46,7 @@ public class Tests { await _services.PopulateRegistriesAsync(); var expectedValue = "Some value"; - var variable = new Variable(); + var variable = new Variable("Variable", ""); var workflow = Workflow.FromActivity(new Sequence { diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Serialization/VariableTypes/Tests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Serialization/VariableTypes/Tests.cs index 448dc0605..0ea4b243f 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Serialization/VariableTypes/Tests.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Serialization/VariableTypes/Tests.cs @@ -24,7 +24,7 @@ public class Tests var model = new VariablesContainer(variables); // Create a typed variable. - var variable = new Variable(); + var variable = new Variable("Variable", false); // Add variable to collection. variables.Add(variable);