Conversation
…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 <12449837+YunchuWang@users.noreply.github.com>
- 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 <12449837+YunchuWang@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR removes duplicate [Function] attribute generation for class-based Durable Task types (orchestrators, activities, entities) in Azure Functions scenarios. With Azure Functions Durable Extension PR #3229 adding native support for class-based invocations, the generator no longer needs to create function definitions to avoid conflicts with the runtime's built-in registration.
Key changes:
- Generator now produces only extension methods (e.g.,
CallMyActivityAsync) for class-based tasks, not[Function]declarations - Added logic to skip generation entirely when only entities exist in Durable Functions scenarios (since entities don't have extension methods)
- Method-based activity triggers continue generating extension methods as before
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Generators/DurableTaskSourceGenerator.cs | Added ShouldSkipGenerationForDurableFunctions method to skip generation for entity-only scenarios; removed calls to AddOrchestratorFunctionDeclaration, AddActivityFunctionDeclaration, and AddEntityFunctionDeclaration for Durable Functions; added explanatory comments |
| test/Generators.Tests/Utils/TestHelpers.cs | Modified RunTestAsync to accept nullable expectedOutputSource parameter, allowing tests to verify scenarios where no code is generated |
| test/Generators.Tests/AzureFunctionsTests.cs | Updated 17 test methods to expect only extension methods (not [Function] declarations) for class-based tasks; updated test documentation to reference PR #3229; set expectedOutputSource to null for entity-only tests |
Comments suppressed due to low confidence (1)
src/Generators/DurableTaskSourceGenerator.cs:381
- These 'if' statements can be combined.
if (!isDurableFunctions)
{
// ASP.NET Core-specific service registration methods
// Only generate if there are actually tasks to register
if (orchestrators.Count > 0 || activities.Count > 0 || entities.Count > 0)
{
AddRegistrationMethodForAllTasks(
sourceBuilder,
orchestrators,
activities,
entities);
}
}
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot will this be a breaking change for customers whose function apps with outdated azure functions durable extension version and updated source generator? |
You're absolutely right to raise this concern. After investigating, I've added version detection to prevent breaking changes. The change now checks if However, I need clarification: What version of Microsoft.Azure.Functions.Worker.Extensions.DurableTask actually added native class-based invocation support? PR #3229 mentions v3.8.0, but that appears to be for the in-process extension (Microsoft.Azure.WebJobs.Extensions.DurableTask). The isolated worker extension uses different versioning. Could you confirm which version of the isolated worker extension (Microsoft.Azure.Functions.Worker.Extensions.DurableTask) added this native support so I can set the correct version threshold? For now, I've conservatively set it to 1.1.0, but this should be adjusted based on the actual version where the feature was introduced. |
…unctions versions - Check if Microsoft.Azure.Functions.Worker.Extensions.DurableTask is version 1.1.0 or later - Only skip [Function] generation for versions that support native class-based invocation - For older versions, continue generating [Function] definitions for backward compatibility - Add TODO to confirm correct version threshold with Durable Functions team Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
|
@copilot What version of Microsoft.Azure.Functions.Worker.Extensions.DurableTask actually added native class-based invocation support? its 1.11.0 |
…support - Changed version threshold from 1.1.0 to 1.11.0 based on confirmation from Durable Functions team - Version 1.11.0 of Microsoft.Azure.Functions.Worker.Extensions.DurableTask added native class-based invocation support - Removed TODO comment as version has been confirmed Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Updated the version threshold to 1.11.0 in commit 341202f. The generator will now:
This ensures no breaking changes for customers using older versions while taking advantage of native support in v1.11.0+. |
|
@copilot why smoke test ci failed, likely itis the smoke tested apps not registering the orchestrations/activities/entities as per in this pr. check and fix |
- Add explicit registration of orchestrators, activities, and entities in smoke test Program.cs - Register GeneratedOrchestration, ChildGeneratedOrchestration, CountCharactersActivity, and GeneratorCounter - Required for Durable Functions v1.11.0+ which has native class-based invocation support Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Fixed in commit 1cd06bb. The smoke test Program.cs now explicitly registers all class-based orchestrators, activities, and entities (GeneratedOrchestration, ChildGeneratedOrchestration, CountCharactersActivity, GeneratorCounter) as required for Durable Functions v1.11.0+ with native class-based invocation support. |
|
@copilot build ci failed after merging conflict, check and fix |
…vior - Update tests to expect only extension methods (no [Function] definitions) for class-based tasks - Tests were failing because they expected old behavior before v1.11.0 - With v1.11.0+, Durable Functions runtime handles class-based tasks natively - Updated 5 test methods to align with the new generator behavior Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Fixed in commit db10383. The build failure was caused by merge conflict introducing new ProjectTypeConfigurationTests that expected the old behavior (generating [Function] definitions for class-based tasks). Updated 5 test methods to expect the new v1.11.0+ behavior where only extension methods are generated, as the runtime now handles class-based tasks natively. All 53 tests now pass. |


Plan to Refactor Generator for Durable Functions Class-Based Invocation
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.