Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

The source generator produced invalid C# code for activity functions returning void or non-generic Task, attempting to generate Task<void> which doesn't compile.

Example of the issue:

[Function(nameof(FlakeyActivity))]
public static void FlakeyActivity([ActivityTrigger] object _)
{
    throw new ApplicationException("Kah-BOOOOM!!!");
}

// Generator produced invalid code:
// public static Task<void> CallFlakeyActivityAsync(...)  // ❌ doesn't compile

Changes

  • DurableFunction.cs: Added ReturnsVoid flag detected via SpecialType.System_Void and non-generic Task comparison using SymbolEqualityComparer
  • DurableTaskSourceGenerator.cs: Generate Task (not Task<T>) for void activities, calling CallActivityAsync without generic type parameter
  • TypedParameter.cs: Make object parameters nullable via SpecialType check while preserving source nullability for other types

Generated code after fix:

// Void return → Task (no generic)
public static Task CallFlakeyActivityAsync(this TaskOrchestrationContext ctx, object? _, TaskOptions? options = null)
{
    return ctx.CallActivityAsync("FlakeyActivity", _, options);
}

// Task<T> return → Task<T> (unchanged)
public static Task<string> CallSayHelloAsync(this TaskOrchestrationContext ctx, string name, TaskOptions? options = null)
{
    return ctx.CallActivityAsync<string>("SayHello", name, options);
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Source generator doesn't handle activity functions that return void</issue_title>
<issue_description>I have the following activity definition:

[Function(nameof(FlakeyActivity))]
public static void FlakeyActivity([ActivityTrigger] object _)
{
    throw new ApplicationException("Kah-BOOOOM!!!");
}

Source-gen tried to produce the following:

public static Task<void> CallFlakeyActivityAsync(this TaskOrchestrationContext ctx, object _, TaskOptions? options = null)
{
    return ctx.CallActivityAsync<void>("FlakeyActivity", _, options);
}

Obviously, this didn't compile. It seems we need to handle this as a special-case.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix source generator to handle activity functions returning void Fix source generator for void-returning activity functions Dec 10, 2025
Copilot AI requested a review from YunchuWang December 10, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Source generator doesn't handle activity functions that return void

2 participants