Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Azure Functions Durable Extension PR #3229 added native support for class-based orchestrators, activities, and entities. The generator now produces duplicate [Function] definitions alongside the runtime's, causing potential conflicts.

Changes

  • Generator: Remove [Function] attribute generation for class-based tasks (TaskOrchestrator<T>, TaskActivity<T>, TaskEntity<T>) when targeting Durable Functions
  • Generator: Retain extension method generation (CallMyActivityAsync, ScheduleNewMyOrchestratorInstanceAsync) for type-safe invocation
  • Generator: Skip generation entirely when only entities exist (no extension methods needed)
  • Tests: Update 17 Azure Functions tests to expect extension methods only, not [Function] definitions
  • Tests: Support null expected output for scenarios with no generated code

Before

// Generator produced both:
[Function(nameof(MyActivity))]
public static async Task<string> MyActivity([ActivityTrigger] int input, string instanceId, FunctionContext ctx) { ... }

public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, int input) { ... }

After

// Generator produces only extension methods:
public static Task<string> CallMyActivityAsync(this TaskOrchestrationContext ctx, int input) { ... }

// Durable Functions runtime handles [Function] registration natively

Method-based activity triggers ([ActivityTrigger] on methods) continue generating extension methods as before.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor Generator to handle updated Durable Functions class-based invocation</issue_title>
<issue_description>With this PR, Durable Functions is enabling class-based invocations. In doing so, the generator could now lead to duplicate function definitions. The generator should be updated to handle this new case.</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 20, 2025 00:45
…based tasks

- Remove generation of [Function] attribute definitions for class-based orchestrators, activities, and entities
- Keep generating extension methods for type-safe invocation
- Add early return when only entities exist in Durable Functions scenarios
- Update tests to reflect new behavior where Durable Functions natively handles class-based invocations

Co-authored-by: YunchuWang <[email protected]>
- Extract entity-only check into ShouldSkipGenerationForDurableFunctions helper method
- Improve comments to clarify what class-based tasks refers to
- Add documentation about GeneratedActivityContext methods being retained but unused in DF scenarios

Co-authored-by: YunchuWang <[email protected]>
Copilot AI changed the title [WIP] Refactor generator to handle class-based invocation in Durable Functions Remove generator-produced [Function] definitions for class-based tasks to avoid duplicates with native DF support Dec 20, 2025
Copilot AI requested a review from YunchuWang December 20, 2025 00:53
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.

Refactor Generator to handle updated Durable Functions class-based invocation

2 participants