-
Notifications
You must be signed in to change notification settings - Fork 53
Fix source generator for void-returning activity functions #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
|
@copilot address my comments |
…semantics Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a source generator bug where activity functions returning void or non-generic Task would produce invalid C# code (Task<void> doesn't compile).
Key Changes
- Added void return type detection in
DurableFunction.csusingSpecialType.System_Voidand non-genericTaskcomparison - Modified generator to emit
Task(notTask<T>) and call non-genericCallActivityAsyncfor void-returning activities - Made
objectparameters nullable to match the API signature ofCallActivityAsync
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Generators/AzureFunctions/DurableFunction.cs | Added ReturnsVoid property and detection logic for void and non-generic Task returns |
| src/Generators/DurableTaskSourceGenerator.cs | Added conditional code generation based on ReturnsVoid flag to emit correct method signatures |
| src/Generators/AzureFunctions/TypedParameter.cs | Made object parameters nullable when not already annotated as nullable |
| test/Generators.Tests/AzureFunctionsTests.cs | Added test coverage for void return and Task (non-generic) return scenarios |
| INamedTypeSymbol? returnSymbol = null; | ||
|
|
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "we'll use object as a placeholder since it won't be used", but this is misleading. The returnSymbol is actually used: it's passed to GetRenderedTypeExpression in the constructor (line 41) to set the ReturnType property, and it's added to the usedTypes list (line 117) to determine required namespaces. Consider revising the comment to more accurately reflect that object is used as a safe default type for namespace resolution, even though the actual return type won't be rendered in the generated code due to the ReturnsVoid flag.
| { | ||
| INamedTypeSymbol? nonGenericTaskSymbol = model.Compilation.GetTypeByMetadataName("System.Threading.Tasks.Task"); |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "we'll use object as a placeholder since it won't be used", but this is misleading. The returnSymbol is actually used: it's passed to GetRenderedTypeExpression in the constructor (line 41) to set the ReturnType property, and it's added to the usedTypes list (line 117) to determine required namespaces. Consider revising the comment to more accurately reflect that object is used as a safe default type for namespace resolution, even though the actual return type won't be rendered in the generated code due to the ReturnsVoid flag.
All comments addressed in c94763f:
All 43 tests passing. |
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
|
@copilot address my comments |
…e nullable Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
|
LGTM |
|
@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md |
SummaryWhat changed?
Why is this change needed?Activity functions returning Issues / work items
Project checklist
AI-assisted code disclosure (required)Was an AI tool used?
If AI was used:
AI verification:
TestingAutomated tests
Manual validation
Notes for reviewers
|
|
@copilot address the comment |
The constructor change is not a breaking change because |


Summary
Fixed source generator to handle void-returning activity functions with improved robustness.
Changes Made
Technical Details
Addressed all review feedback:
GetTypeInfo().Typeinstead of using null-forgiving operatorTypeKind.Errorcheck to gracefully handle compilation errorsINamedTypeSymbolreturnSymbolis now nullable and left asnullfor void returns, only used where it has meaningreturnTypeparameter nullable, eliminating the need for fragile placeholder patternThe generator correctly handles void, Task, and Task return types with robust error handling throughout.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.