Skip to content

Conversation

@nytian
Copy link
Contributor

@nytian nytian commented Dec 11, 2025

fix Azure/azure-functions-durable-extension#3173

Analyzer threw ArgumentException and AD0001 warning when encountering extension methods defined in separate projects/assemblies.

This PR add checks to skip analyzing methods for non-accessible source code

Copilot AI review requested due to automatic review settings December 11, 2025 03:39
Copy link
Contributor

Copilot AI left a 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 bug where the analyzer throws ArgumentException and generates AD0001 warnings when encountering extension methods or other types defined in external assemblies without available source code. The fix adds defensive checks to verify that syntax references are available before attempting to access them.

Key Changes:

  • Added IsEmpty check in GetSyntaxNodes to return empty enumerable for methods without syntax references
  • Added IsEmpty check in OrchestrationAnalyzer before accessing method syntax for Func orchestrators

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Analyzers/RoslynExtensions.cs Added defensive check in GetSyntaxNodes to return empty when no syntax references exist
src/Analyzers/Orchestration/OrchestrationAnalyzer.cs Added check before accessing syntax references for method reference operations in Func orchestrators

Copilot AI review requested due to automatic review settings December 12, 2025 04:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +118 to +123
// If the method has no syntax references (e.g., extension methods from external assemblies),
// return empty to skip analysis rather than throwing ArgumentException.
if (methodSymbol.DeclaringSyntaxReferences.IsEmpty)
{
return Enumerable.Empty<MethodDeclarationSyntax>();
}
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix prevents ArgumentException when analyzing extension methods from external assemblies, but there doesn't appear to be test coverage for this scenario. Consider adding a test case that includes an orchestration calling an extension method defined in a separate assembly to ensure this fix works as expected and to prevent regression.

Copilot uses AI. Check for mistakes.
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.

DURABLE000* analyzers produce ArgumentException in Visual Studio

2 participants