File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4+ using System ;
5+
46namespace Microsoft . DurableTask ;
57
68/// <summary>
@@ -25,7 +27,31 @@ public TaskName(string name)
2527 else
2628 {
2729 this . Name = name ;
28- this . Version = string . Empty ; // expose setting Version only when we actually consume it.
30+ this . Version = string . Empty ;
31+ }
32+ }
33+
34+ /// <summary>
35+ /// Initializes a new instance of the <see cref="TaskName"/> struct.
36+ /// </summary>
37+ /// <remarks>
38+ /// This <c>TaskName</c> is explicitly versioned, as compared to the default value.
39+ /// </remarks>
40+ /// <param name="name">The name of the task. Providing <c>null</c> will yield the default struct, ignoring the version.</param>
41+ /// <param name="version">Optional. The version of the task. Providing <c>null</c> will yield the default value.</param>
42+ public TaskName ( string name , string version )
43+ {
44+ if ( name is null )
45+ {
46+ // Force the default struct when null is passed in.
47+ this . Name = null ! ;
48+ this . Version = null ! ;
49+ }
50+ else
51+ {
52+ this . IsVersioned = true ;
53+ this . Name = name ;
54+ this . Version = version == null ? null ! : version ;
2955 }
3056 }
3157
@@ -46,6 +72,14 @@ public TaskName(string name)
4672 /// </remarks>
4773 public string Version { get ; }
4874
75+ /// <summary>
76+ /// Gets the flag denoting if this TaskName is versioned.
77+ /// </summary>
78+ /// <remarks>
79+ /// This flag is used to distinguish between the default (empty version) and a Task with an explicit empty version.
80+ /// </remarks>
81+ public bool IsVersioned { get ; } = false ;
82+
4983 /// <summary>
5084 /// Implicitly converts a <see cref="TaskName"/> into a <see cref="string"/> of the <see cref="Name"/> property value.
5185 /// </summary>
Original file line number Diff line number Diff line change @@ -61,9 +61,9 @@ public abstract class TaskOrchestrationContext
6161 public abstract bool IsReplaying { get ; }
6262
6363 /// <summary>
64- /// Gets the version of the current orchestration instance, which was set when the instance was created.
64+ /// Gets or sets the version of the current orchestration instance, which was set when the instance was created.
6565 /// </summary>
66- public virtual string Version => string . Empty ;
66+ public virtual string Version { get ; protected internal set ; } = string . Empty ;
6767
6868 /// <summary>
6969 /// Gets the entity feature, for interacting with entities.
You can’t perform that action at this time.
0 commit comments