Use activity ID as Node ID for workflows created with tool version >= 3

This commit is contained in:
Sipke Schoorstra 2023-07-21 18:43:31 +02:00
parent d473f2354b
commit d746456330
3 changed files with 12 additions and 6 deletions

View file

@ -59,8 +59,8 @@ public abstract class Activity : IActivity, ISignalHandler
/// <summary>
/// A flag indicating if this activity should execute synchronously or asynchronously.
/// By default, activities with an <see cref="Workflows.Core.Models.ActivityKind"/> of <see cref="Action"/>, <see cref="Task"/> or <see cref="Trigger"/>
/// will execute synchronously, while activities of the <see cref="Workflows.Core.Models.ActivityKind.Job"/> kind will execute asynchronously.
/// By default, activities with an <see cref="ActivityKind"/> of <see cref="Action"/>, <see cref="Task"/> or <see cref="Trigger"/>
/// will execute synchronously, while activities of the <see cref="ActivityKind.Job"/> kind will execute asynchronously.
/// </summary>
[JsonIgnore]
public bool RunAsynchronously

View file

@ -38,6 +38,7 @@ public class Workflow : Composite<object>, ICloneable
Outputs = outputs;
Outcomes = outcomes;
WorkflowMetadata = workflowMetadata;
ToolVersion = new Version(1, 0);
Options = options;
Variables = variables;
CustomProperties = customProperties;
@ -48,7 +49,7 @@ public class Workflow : Composite<object>, ICloneable
/// <summary>
/// Constructor.
/// </summary>
public Workflow(IActivity root)
public Workflow(IActivity root) : this()
{
Root = root;
}
@ -58,6 +59,7 @@ public class Workflow : Composite<object>, ICloneable
/// </summary>
public Workflow()
{
ToolVersion = new Version(1, 0);
}
/// <summary>
@ -94,13 +96,16 @@ public class Workflow : Composite<object>, ICloneable
/// Gets or sets options for the workflow.
/// </summary>
public WorkflowOptions Options { get; set; } = new();
/// <summary>
/// Make workflow definition readonly.
/// </summary>
public bool IsReadonly { get; set; }
/// <summary>
/// The version of the tool that created this workflow.
/// </summary>
public Version ToolVersion { get; set; }
/// <summary>
/// Constructs a new <see cref="Workflow"/> from the specified <see cref="IActivity"/>.

View file

@ -98,7 +98,8 @@ public class ActivityExecutionContext : IExecutionContext
/// <summary>
/// Returns the global node ID for the current activity within the graph.
/// </summary>
public string NodeId => ActivityNode.NodeId;
/// <remarks>As of tool version 3.0, all activity Ids are already unique, so there's no need to construct a hierarchical ID</remarks>
public string NodeId => WorkflowExecutionContext.Workflow.ToolVersion >= new Version(3, 0) ? Activity.Id : ActivityNode.NodeId;
/// <summary>
/// A list of bookmarks created by the current activity.