-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Elsa workflow expression serialization (#4930)
* Improve Elsa workflow expression serialization Added serialization support for expressions in Elsa workflows, enabling serialization and deserialization to maintain consistent types across sessions. Updated relevant test cases for validation. * Remove PR workflow from GitHub actions The PR workflow has been removed from GitHub actions.
- Loading branch information
1 parent
fa32e00
commit 3bad8a5
Showing
12 changed files
with
149 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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
5 changes: 5 additions & 0 deletions
5
src/modules/Elsa.Expressions/Models/ExpressionSerializationContext.cs
This file contains 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,5 @@ | ||
using System.Text.Json; | ||
|
||
namespace Elsa.Expressions.Models; | ||
|
||
public record ExpressionSerializationContext(JsonElement JsonElement, JsonSerializerOptions Options, Type MemoryBlockType); |
1 change: 1 addition & 0 deletions
1
src/modules/Elsa.Workflows.Core/Expressions/VariableExpressionHandler.cs
This file contains 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 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 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
41 changes: 41 additions & 0 deletions
41
...tegration/Elsa.Workflows.IntegrationTests/Serialization/VariableExpressions/Activities.cs
This file contains 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,41 @@ | ||
using System.Text.Json.Serialization; | ||
using Elsa.Expressions.Models; | ||
using Elsa.Extensions; | ||
using Elsa.Workflows.Memory; | ||
using Elsa.Workflows.Models; | ||
|
||
namespace Elsa.Workflows.IntegrationTests.Serialization.VariableExpressions; | ||
|
||
/// <inheritdoc /> | ||
public class NumberActivity : CodeActivity | ||
{ | ||
/// <inheritdoc /> | ||
[JsonConstructor] | ||
public NumberActivity() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public NumberActivity(Variable<int> variable) | ||
{ | ||
Number = new(variable); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public NumberActivity(Literal<int> literal) | ||
{ | ||
Number = new(literal); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the number. | ||
/// </summary> | ||
public Input<int> Number { get; set; } = default!; | ||
|
||
/// <inheritdoc /> | ||
protected override void Execute(ActivityExecutionContext context) | ||
{ | ||
var number = Number.Get(context); | ||
Console.WriteLine(number.ToString()); | ||
} | ||
} |
This file contains 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 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