Skip to content

Comments

Add Roslyn Analyzer to detect calls to non-existent functions (name mismatch)#530

Merged
torosent merged 8 commits intomainfrom
copilot/add-roslyn-analyzer-function-check
Dec 10, 2025
Merged

Add Roslyn Analyzer to detect calls to non-existent functions (name mismatch)#530
torosent merged 8 commits intomainfrom
copilot/add-roslyn-analyzer-function-check

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

  • Understand the issue requirements (detect calling non-existent functions due to name mismatch)
  • Explore existing analyzer infrastructure
  • Run existing tests to verify baseline
  • Create a new analyzer FunctionNotFoundAnalyzer that detects:
    • Calls to activities via CallActivityAsync with non-existent function names
    • Calls to sub-orchestrations via CallSubOrchestratorAsync with non-existent function names
  • Add corresponding test cases for the new analyzer (17 tests)
  • Update resource strings for the diagnostic messages
  • Update AnalyzerReleases.Unshipped.md to track new rules
  • Run tests to validate the implementation (all 90 tests pass)
  • Run code review and address feedback
    • Added null check for SemanticModel
    • Changed FindOverridingMethod to ClassOverridesMethod returning bool
    • Changed mutable struct to immutable readonly struct with primary constructor
    • Removed unused System.Diagnostics import
  • Address code quality suggestions:
    • Use .Where(...) LINQ filter in foreach loops for diagnostics
    • Use .Any(...) in ClassOverridesMethod instead of explicit foreach loop
    • Combine nested if statements for TaskActivity derived classes check
  • Security: CodeQL checker timed out but no new security-sensitive code patterns introduced
Original prompt

This section details on the original issue you should resolve

<issue_title>Roslyn Analyzer should detect calling non-existent functions (due to name mismatch)</issue_title>
<issue_description>Originally reported by #253 </issue_description>

<agent_instructions>inspect and implement correctly and robustly, add corresponding testcases to validate</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…es and sub-orchestrations

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
…eadonly struct, remove unused import

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Roslyn Analyzer to detect calling non-existent functions Add Roslyn Analyzer to detect calls to non-existent functions (name mismatch) Dec 5, 2025
Copilot AI requested a review from YunchuWang December 5, 2025 01:26
@YunchuWang
Copy link
Member

@copilot check and address the comments

…nested if statements

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 5, 2025

@copilot check and address the comments

Addressed the code quality suggestions in commit 7b66c06:

  • Used .Where(...) LINQ filter in foreach loops instead of inner if statements
  • Used .Any(...) in ClassOverridesMethod instead of explicit foreach loop with early return
  • Combined nested if statements for the TaskActivity derived classes check

@YunchuWang YunchuWang marked this pull request as ready for review December 9, 2025 23:43
Copilot AI review requested due to automatic review settings December 9, 2025 23:43
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 introduces a new Roslyn analyzer (FunctionNotFoundAnalyzer) to detect compile-time mismatches when calling activities or sub-orchestrations with names that don't match any defined functions in the compilation. This helps prevent runtime errors caused by typos or incorrect function names.

Key Changes:

  • New analyzer detects non-existent activity and sub-orchestration references
  • Comprehensive test coverage with 17 test cases covering various scenarios
  • Support for multiple registration patterns (Azure Functions attributes, class-based syntax, lambda/func registrations)

Reviewed changes

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

File Description
src/Analyzers/Activities/FunctionNotFoundAnalyzer.cs Core analyzer implementation that tracks function invocations and definitions across the compilation, reporting diagnostics for mismatches
test/Analyzers.Tests/Activities/FunctionNotFoundAnalyzerTests.cs Comprehensive test suite covering activity and sub-orchestration scenarios including Durable Functions, class-based, and lambda registrations
src/Analyzers/Resources.resx Resource strings for diagnostic messages with clear, actionable guidance
src/Analyzers/AnalyzerReleases.Unshipped.md Documentation for new diagnostic rules DURABLE2003 and DURABLE2004

@YunchuWang
Copy link
Member

image verified all cases of analyzer work as intended, signing off

@torosent torosent merged commit 4c04e29 into main Dec 10, 2025
13 checks passed
@torosent torosent deleted the copilot/add-roslyn-analyzer-function-check branch December 10, 2025 15:56
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.

Roslyn Analyzer should detect calling non-existent functions (due to name mismatch)

3 participants