Skip to content

Commit 7f8e4df

Browse files
committed
fb
1 parent 62d2520 commit 7f8e4df

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

samples/ScheduleWebApp/Orchestrations/CacheClearingOrchestrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public override async Task<string> RunAsync(TaskOrchestrationContext context, st
1515
{
1616
logger.LogInformation("Starting CacheClearingOrchestration for schedule ID: {ScheduleId}", scheduleId);
1717

18-
CallActivityOptions options = new TaskOptions().WithTags(new Dictionary<string, string>
18+
CallActivityOptions options = new CallActivityOptions(tags: new Dictionary<string, string>
1919
{
2020
{ "scheduleId", scheduleId }
2121
});

src/Abstractions/TaskOptions.cs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,27 @@ public TaskOptions(TaskRetryOptions? retry = null)
1919
this.Retry = retry;
2020
}
2121

22+
/// <summary>
23+
/// Initializes a new instance of the <see cref="TaskOptions"/> class.
24+
/// </summary>
25+
/// <param name="retry">The task retry options.</param>
26+
/// <param name="tags">The tags to associate with the task.</param>
27+
public TaskOptions(TaskRetryOptions? retry = null, IDictionary<string, string>? tags = null)
28+
{
29+
this.Retry = retry;
30+
this.Tags = tags;
31+
}
32+
2233
/// <summary>
2334
/// Gets the task retry options.
2435
/// </summary>
2536
public TaskRetryOptions? Retry { get; init; }
2637

38+
/// <summary>
39+
/// Gets the tags to associate with the task.
40+
/// </summary>
41+
public IDictionary<string, string>? Tags { get; init; }
42+
2743
/// <summary>
2844
/// Returns a new <see cref="TaskOptions" /> from the provided <see cref="RetryPolicy" />.
2945
/// </summary>
@@ -52,13 +68,6 @@ public TaskOptions(TaskRetryOptions? retry = null)
5268
/// <param name="instanceId">The instance ID to use.</param>
5369
/// <returns>A new <see cref="SubOrchestrationOptions" />.</returns>
5470
public SubOrchestrationOptions WithInstanceId(string instanceId) => new(this, instanceId);
55-
56-
/// <summary>
57-
/// Returns a new <see cref="CallActivityOptions" /> with the provided tags.
58-
/// </summary>
59-
/// <param name="tags">The tags to associate with the activity.</param>
60-
/// <returns>A new <see cref="CallActivityOptions" />.</returns>
61-
public CallActivityOptions WithTags(IDictionary<string, string> tags) => new(this, tags);
6271
}
6372

6473
/// <summary>
@@ -128,12 +137,8 @@ public record CallActivityOptions : TaskOptions
128137
/// <param name="retry">The task retry options.</param>
129138
/// <param name="tags">The tags to associate with the activity.</param>
130139
public CallActivityOptions(TaskRetryOptions? retry = null, IDictionary<string, string>? tags = null)
131-
: base(retry)
140+
: base(retry, tags)
132141
{
133-
if (tags != null)
134-
{
135-
this.Tags = tags;
136-
}
137142
}
138143

139144
/// <summary>
@@ -142,20 +147,7 @@ public CallActivityOptions(TaskRetryOptions? retry = null, IDictionary<string, s
142147
/// <param name="options">The task options to wrap.</param>
143148
/// <param name="tags">The tags to associate with the activity.</param>
144149
public CallActivityOptions(TaskOptions options, IDictionary<string, string>? tags = null)
145-
: base(options)
150+
: base(options.Retry, tags ?? options.Tags)
146151
{
147-
if (tags != null)
148-
{
149-
this.Tags = tags;
150-
}
151-
else if (options is CallActivityOptions derived)
152-
{
153-
this.Tags = derived.Tags;
154-
}
155152
}
156-
157-
/// <summary>
158-
/// Gets the tags to associate with the activity instance.
159-
/// </summary>
160-
public IDictionary<string, string> Tags { get; init; } = ImmutableDictionary.Create<string, string>();
161153
}

0 commit comments

Comments
 (0)