Fix orchestration analyzer to detect non-function orchestrations correctly#572
Conversation
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
…ectly The analyzer was incorrectly requiring all symbols (both Azure Functions and SDK-specific) to be present before analyzing any orchestration type. Now the analyzer registers each type of analysis only when the required symbols for that specific analysis are available. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
|
@copilot |
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
The analyzer logic fix was correct, but the sample project was missing a reference to the Analyzers project. In commit 9fc10cc, I:
To get analyzer diagnostics in your project, add this to your <ProjectReference Include="..\..\src\Analyzers\Analyzers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />Or reference the NuGet package when available. |
|
@copilot no, still not recognizing |
The analyzer is working correctly. When building from command line, If Visual Studio isn't showing the diagnostics, please try:
Note: Your screenshot shows code different from the repository (line 13 has |
…ariable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
|
@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md |
Updated the PR description to follow |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the OrchestrationAnalyzer that prevented it from detecting orchestration code issues in non-Azure Functions projects (SDK-only scenarios using ITaskOrchestrator or AddOrchestratorFunc). The analyzer was incorrectly skipping analysis when ANY required symbol was missing, rather than checking independently for each orchestration type.
Key Changes:
- Fixed the analyzer to check symbol availability independently for each orchestration type (Durable Functions, TaskOrchestrator, FuncOrchestrator) and only register analysis actions when the required symbols are available
- Added comprehensive test infrastructure for SDK-only scenarios without Azure Functions dependencies
- Added analyzer references to non-Azure Functions sample projects for IDE visibility
- Fixed a
DateTime.UtcNowusage issue in theStockPriceOrchestratorsample that was detected by the now-working analyzer
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Analyzers/Orchestration/OrchestrationAnalyzer.cs |
Core fix: Changed from OR condition to independent checks per orchestration type, wrapping each RegisterXxxAction in conditional blocks |
test/Analyzers.Tests/Verifiers/References.cs |
Added SdkOnlyAssemblies reference set excluding Azure Functions packages |
test/Analyzers.Tests/Verifiers/CSharpCodeFixVerifier.Durable.cs |
Added VerifySdkOnlyAnalyzerAsync and VerifySdkOnlyCodeFixAsync helper methods with SDK-only references |
test/Analyzers.Tests/Verifiers/CSharpAnalyzerVerifier.Durable.cs |
Added VerifySdkOnlyAnalyzerAsync helper method with SDK-only references |
test/Analyzers.Tests/Wrapper.cs |
Added WrapTaskOrchestratorSdkOnly and WrapFuncOrchestratorSdkOnly wrappers with UsingsForSdkOnly (excludes Azure Functions usings) |
test/Analyzers.Tests/Orchestration/DateTimeOrchestrationAnalyzerTests.cs |
Added two SDK-only tests verifying analyzer works without Azure Functions dependencies |
samples/ScheduleConsoleApp/ScheduleConsoleApp.csproj |
Added analyzer project reference for IDE diagnostics |
samples/ScheduleWebApp/ScheduleWebApp.csproj |
Added analyzer project reference for IDE diagnostics |
samples/LargePayloadConsoleApp/LargePayloadConsoleApp.csproj |
Added analyzer project reference for IDE diagnostics, removed trailing blank lines |
samples/ExceptionPropertiesSample/ExceptionPropertiesSample.csproj |
Added analyzer project reference for IDE diagnostics, removed trailing blank line |
samples/ConsoleAppMinimal/ConsoleAppMinimal.csproj |
Added analyzer project reference for IDE diagnostics |
samples/ConsoleApp/ConsoleApp.csproj |
Added analyzer project reference for IDE diagnostics |
samples/ScheduleConsoleApp/Orchestrators/StockPriceOrchestrator.cs |
Fixed bug: Changed DateTime.UtcNow to context.CurrentUtcDateTime |
|
@copilot why there is a failing test, seems flaky explain what and why it happens and fix |
The failing test is in
The failure appears after the merge commit ( Suggested action: Re-run the failed workflow to verify this is transient. The integration test flakiness should be addressed in a separate issue. |


Summary
What changed?
OrchestrationAnalyzer.csto correctly detect non-function orchestrations (ITaskOrchestrator,TaskOrchestrator<TInput, TOutput>, andAddOrchestratorFunc)DateTime.UtcNowusage inStockPriceOrchestrator.cssample to usecontext.CurrentUtcDateTimeWhy is this change needed?
TaskOrchestratororAddOrchestratorFunc) were not being analyzed for determinism violationsIssues / work items
Project checklist
TaskOrchestratorSdkOnlyHasDiagtestFuncOrchestratorSdkOnlyWithLambdaHasDiagtestAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
src/Analyzers/Orchestration/OrchestrationAnalyzer.cstest/Analyzers.Tests/Orchestration/DateTimeOrchestrationAnalyzerTests.cstest/Analyzers.Tests/Verifiers/References.cstest/Analyzers.Tests/Verifiers/CSharpAnalyzerVerifier.Durable.cstest/Analyzers.Tests/Verifiers/CSharpCodeFixVerifier.Durable.cstest/Analyzers.Tests/Wrapper.cs.csprojfilesAI verification (required if AI was used):
Testing
Automated tests
Manual validation (only if runtime/behavior changed)
DateTime.UtcNowusage inStockPriceOrchestratorsampleDURABLE0001andDURABLE0003warnings are now displayed for non-function orchestratorsNotes for reviewers
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.