Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Generators/DurableTaskSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ static void AddOrchestratorFunctionDeclaration(StringBuilder sourceBuilder, Dura
static void AddOrchestratorCallMethod(StringBuilder sourceBuilder, DurableTaskTypeInfo orchestrator)
{
sourceBuilder.AppendLine($@"
/// <summary>
/// Schedules a new instance of the <see cref=""{orchestrator.TypeName}""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNew{orchestrator.TaskName}InstanceAsync(
this IOrchestrationSubmitter client, {orchestrator.InputParameter}, StartOrchestrationOptions? options = null)
Expand All @@ -336,6 +339,9 @@ static void AddOrchestratorCallMethod(StringBuilder sourceBuilder, DurableTaskTy
static void AddSubOrchestratorCallMethod(StringBuilder sourceBuilder, DurableTaskTypeInfo orchestrator)
{
sourceBuilder.AppendLine($@"
/// <summary>
/// Calls the <see cref=""{orchestrator.TypeName}""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{orchestrator.OutputType}> Call{orchestrator.TaskName}Async(
this TaskOrchestrationContext context, {orchestrator.InputParameter}, TaskOptions? options = null)
Expand All @@ -347,6 +353,10 @@ static void AddSubOrchestratorCallMethod(StringBuilder sourceBuilder, DurableTas
static void AddActivityCallMethod(StringBuilder sourceBuilder, DurableTaskTypeInfo activity)
{
sourceBuilder.AppendLine($@"
/// <summary>
/// Calls the <see cref=""{activity.TypeName}""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{activity.OutputType}> Call{activity.TaskName}Async(this TaskOrchestrationContext ctx, {activity.InputParameter}, TaskOptions? options = null)
{{
return ctx.CallActivityAsync<{activity.OutputType}>(""{activity.TaskName}"", input, options);
Expand All @@ -356,6 +366,10 @@ static void AddActivityCallMethod(StringBuilder sourceBuilder, DurableTaskTypeIn
static void AddActivityCallMethod(StringBuilder sourceBuilder, DurableFunction activity)
{
sourceBuilder.AppendLine($@"
/// <summary>
/// Calls the <see cref=""{activity.FullTypeName}""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{activity.ReturnType}> Call{activity.Name}Async(this TaskOrchestrationContext ctx, {activity.Parameter}, TaskOptions? options = null)
{{
return ctx.CallActivityAsync<{activity.ReturnType}>(""{activity.Name}"", {activity.Parameter.Name}, options);
Expand Down
38 changes: 38 additions & 0 deletions test/Generators.Tests/AzureFunctionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class Calculator
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Calls the <see cref=""Calculator.Identity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<int> CallIdentityAsync(this TaskOrchestrationContext ctx, int input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<int>(""Identity"", input, options);
Expand Down Expand Up @@ -57,6 +61,10 @@ public class Calculator
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Calls the <see cref=""Calculator.IdentityAsync""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<int> CallIdentityAsync(this TaskOrchestrationContext ctx, int input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<int>(""Identity"", input, options);
Expand Down Expand Up @@ -92,6 +100,10 @@ public class Calculator
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Calls the <see cref=""AzureFunctionsTests.Calculator.Identity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<AzureFunctionsTests.Input> CallIdentityAsync(this TaskOrchestrationContext ctx, AzureFunctionsTests.Input input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<AzureFunctionsTests.Input>(""Identity"", input, options);
Expand Down Expand Up @@ -141,6 +153,10 @@ public class MyActivity : TaskActivity<{inputType}, {outputType}>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: $@"
/// <summary>
/// Calls the <see cref=""MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{outputType}> CallMyActivityAsync(this TaskOrchestrationContext ctx, {inputType} input, TaskOptions? options = null)
{{
return ctx.CallActivityAsync<{outputType}>(""MyActivity"", input, options);
Expand Down Expand Up @@ -214,13 +230,19 @@ public class MyOrchestrator : TaskOrchestrator<{inputType}, {outputType}>
.ContinueWith(t => ({outputType})(t.Result ?? default({outputType})!), TaskContinuationOptions.ExecuteSynchronously);
}}

/// <summary>
/// Schedules a new instance of the <see cref=""MyNS.MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, {expectedInputParameter}, StartOrchestrationOptions? options = null)
{{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}}

/// <summary>
/// Calls the <see cref=""MyNS.MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{outputType}> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, {expectedInputParameter}, TaskOptions? options = null)
Expand Down Expand Up @@ -291,13 +313,19 @@ public abstract class MyOrchestratorBase : TaskOrchestrator<{inputType}, {output
.ContinueWith(t => ({outputType})(t.Result ?? default({outputType})!), TaskContinuationOptions.ExecuteSynchronously);
}}

/// <summary>
/// Schedules a new instance of the <see cref=""MyNS.MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, {expectedInputParameter}, StartOrchestrationOptions? options = null)
{{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}}

/// <summary>
/// Calls the <see cref=""MyNS.MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<{outputType}> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, {expectedInputParameter}, TaskOptions? options = null)
Expand Down Expand Up @@ -493,20 +521,30 @@ public static Task<string> MyOrchestrator([OrchestrationTrigger] TaskOrchestrati
.ContinueWith(t => (string)(t.Result ?? default(string)!), TaskContinuationOptions.ExecuteSynchronously);
}}

/// <summary>
/// Schedules a new instance of the <see cref=""MyNS.MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, int input, StartOrchestrationOptions? options = null)
{{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}}

/// <summary>
/// Calls the <see cref=""MyNS.MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, int input, TaskOptions? options = null)
{{
return context.CallSubOrchestratorAsync<string>(""MyOrchestrator"", input, options);
}}

/// <summary>
/// Calls the <see cref=""MyNS.MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, int input, TaskOptions? options = null)
{{
return ctx.CallActivityAsync<string>(""MyActivity"", input, options);
Expand Down
38 changes: 38 additions & 0 deletions test/Generators.Tests/ClassBasedSyntaxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ class MyOrchestrator : TaskOrchestrator<{type}, string>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: $@"
/// <summary>
/// Schedules a new instance of the <see cref=""MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, {input}, StartOrchestrationOptions? options = null)
{{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}}

/// <summary>
/// Calls the <see cref=""MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, {input}, TaskOptions? options = null)
Expand Down Expand Up @@ -80,13 +86,19 @@ abstract class MyOrchestratorBase : TaskOrchestrator<int, string>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Schedules a new instance of the <see cref=""MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, int input, StartOrchestrationOptions? options = null)
{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}

/// <summary>
/// Calls the <see cref=""MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, int input, TaskOptions? options = null)
Expand Down Expand Up @@ -129,6 +141,10 @@ class MyActivity : TaskActivity<{type}, string>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: $@"
/// <summary>
/// Calls the <see cref=""MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, {input}, TaskOptions? options = null)
{{
return ctx.CallActivityAsync<string>(""MyActivity"", input, options);
Expand Down Expand Up @@ -169,6 +185,10 @@ public class MyClass { }
string expectedOutput = TestHelpers.WrapAndFormat(
generatedClassName: "GeneratedDurableTaskExtensions",
methodList: @"
/// <summary>
/// Calls the <see cref=""MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<MyNS.MyClass> CallMyActivityAsync(this TaskOrchestrationContext ctx, MyNS.MyClass input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<MyNS.MyClass>(""MyActivity"", input, options);
Expand Down Expand Up @@ -211,6 +231,10 @@ public class MyClass { }
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Calls the <see cref=""MyNS.MyActivityImpl""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<MyNS.MyClass> CallMyActivityAsync(this TaskOrchestrationContext ctx, MyNS.MyClass input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<MyNS.MyClass>(""MyActivity"", input, options);
Expand Down Expand Up @@ -250,6 +274,10 @@ abstract class MyActivityBase : TaskActivity<int, string>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Calls the <see cref=""MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, int input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<string>(""MyActivity"", input, options);
Expand Down Expand Up @@ -440,20 +468,30 @@ class MyEntity : TaskEntity<int>
string expectedOutput = TestHelpers.WrapAndFormat(
GeneratedClassName,
methodList: @"
/// <summary>
/// Schedules a new instance of the <see cref=""MyOrchestrator""/> orchestrator.
/// </summary>
/// <inheritdoc cref=""IOrchestrationSubmitter.ScheduleNewOrchestrationInstanceAsync""/>
public static Task<string> ScheduleNewMyOrchestratorInstanceAsync(
this IOrchestrationSubmitter client, int input, StartOrchestrationOptions? options = null)
{
return client.ScheduleNewOrchestrationInstanceAsync(""MyOrchestrator"", input, options);
}

/// <summary>
/// Calls the <see cref=""MyOrchestrator""/> sub-orchestrator.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyOrchestratorAsync(
this TaskOrchestrationContext context, int input, TaskOptions? options = null)
{
return context.CallSubOrchestratorAsync<string>(""MyOrchestrator"", input, options);
}

/// <summary>
/// Calls the <see cref=""MyActivity""/> activity.
/// </summary>
/// <inheritdoc cref=""TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)""/>
public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, int input, TaskOptions? options = null)
{
return ctx.CallActivityAsync<string>(""MyActivity"", input, options);
Expand Down
Loading