Fix DURABLE2003 false positive when activities are in referenced assemblies#582
Fix DURABLE2003 false positive when activities are in referenced assemblies#582YunchuWang with Copilot wants to merge 10 commits into
Conversation
Modified FunctionNotFoundAnalyzer to scan referenced assemblies for activity and orchestrator definitions. Added ScanReferencedAssemblies and ScanNamespaceForFunctions methods to detect functions defined in other assemblies. Added three new tests to verify cross-assembly detection works correctly. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Add assembly filtering to skip system assemblies for performance. Update test comments to accurately describe that they simulate cross-assembly scenarios using separate source files in the same compilation. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Extract helper methods IsActivityMethod, IsOrchestratorMethod, and ImplementsInterface to reduce code duplication. Move system assembly names to static readonly collections. Optimize LINQ chain in ScanReferencedAssemblies to use simple foreach loop. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
|
@copilot it will scan all assemblies including transitive dependencies? we should only scan assemblies that relevant meaning the ones customers have defined activity or (sub) orchestration. |
Add ShouldScanAssembly method that checks if an assembly references Durable Task types (Microsoft.DurableTask.Abstractions, Microsoft.DurableTask.Worker, or Microsoft.Azure.Functions.Worker.Extensions.DurableTask) before scanning. This prevents scanning of transitive dependencies that don't contain activities or orchestrators, improving performance and reducing false positives. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Fixed in b1009a6. Added |
|
@copilot why scan for Microsoft.DurableTask.Abstractions reference? |
Microsoft.DurableTask.Abstractions is a transitive dependency that users never directly reference. Users reference either Microsoft.DurableTask.Worker (for non-function scenarios) or Microsoft.Azure.Functions.Worker.Extensions.DurableTask (for Azure Functions), both of which transitively bring in the abstractions package. Updated ShouldScanAssembly to only check for packages users actually reference. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Removed in 7d44132. |
|
@copilot scanning assemblies references this way is too fragile, the scanning logic should be to if IsSystemAssembly(assembly) if ContainsDurableSymbols(assembly) // semantic lookup else |
Replace fragile assembly reference checking with semantic lookup using ContainsDurableSymbols. This checks if an assembly contains any Durable Task types (TaskActivity, ITaskOrchestrator, ActivityTriggerAttribute, OrchestrationTriggerAttribute) by examining the symbol tree, which is more robust and maintainable than checking package references. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
... Implemented in e94bcd5. Replaced assembly reference checking with semantic lookup via |
|
@copilot ScanNamespaceForFunctions( |
Removed ShouldScanAssembly and ContainsDurableSymbols methods that caused the namespace tree to be traversed twice (once to check if assembly has Durable symbols, then again to collect function names). Now directly calls ScanNamespaceForFunctions which does all the work in a single pass. IsSystemAssembly already filters out the vast majority of irrelevant assemblies. Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Fixed in 9f8c8ed. Removed the duplicate traversal - previously |
|
this is too fragile to check referenced assemlibes |
|
closing |
Plan to Fix DURABLE2003 False Positives for Cross-Assembly Activities
Original prompt
💡 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.