-
Notifications
You must be signed in to change notification settings - Fork 53
Add Check for Non-accessible Code at Analyzer #556
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
base: main
Are you sure you want to change the base?
Conversation
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 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
GetSyntaxNodesto return empty enumerable for methods without syntax references - Added IsEmpty check in
OrchestrationAnalyzerbefore 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 |
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
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| // 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>(); | ||
| } |
Copilot
AI
Dec 12, 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.
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.
37486b8 to
e05e664
Compare
fix Azure/azure-functions-durable-extension#3173
Analyzer threw
ArgumentExceptionandAD0001warning when encountering extension methods defined in separate projects/assemblies.This PR add checks to skip analyzing methods for non-accessible source code