Repository navigation
fix(trace-path): store C# call targets with the receiver's declared type - #126
Merged
Merged
Conversation
C# calls were stored with the bare method name, so `_toolService.PublishInstance()` matched every class with a PublishInstance method. In a layout that injects concrete classes (no interfaces), trace_path listed ToolsController and ToolService as callers of AssistantService.PublishInstance, and the signature-based DI check could not help: the stored signature is only the first line of the constructor. The extractor now resolves a simple receiver (`x` or `this.x`) to its declared type from the nearest scope: method parameters, locals (`var x = new T()` included), foreach variables, then fields, properties, and primary-constructor parameters of the enclosing type. The call is stored as `Type.Method`. Unknown receivers keep the bare name. Readers of CALLS targets handle typed targets: - trace_path maps an interface method to its only implementation. - The topology graph matches a typed target by full symbol first. - find_references callers also match `%.Name` for a short name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#123 did not fix
trace_pathon a real repository. Calls are stored with the bare method name (_toolService.PublishInstance()→PublishInstance), and this layout injects concrete classes into fields:The callers of
AssistantService.PublishInstancestill includedToolsController.PublishInstanceandToolService.PublishInstance. The DI check from #123 compares constructor signatures, but the stored signature is only the first line (public ToolsController(), and there are no interfaces to match.Fix
app/services/chunking/csharp_receiver_types.py. Forreceiver.Method(...)with a simple receiver (xorthis.x), it finds the declared type in the nearest scope: method parameters, locals (var x = new T()included),foreachvariables, then fields, properties, and primary-constructor parameters of the enclosing type. Generic arguments, namespaces, and?are removed. Built-in types,varwithoutnew, static calls, and unknown names keep the bare name.symbol_extractor.pystores C# CALLS targets asType.Methodwhen the type is known.graph_traversal.py: the existing caller filter already drops a qualified target of another class. New: a resolved interface method maps to its only implementation (IOrderRepository.SaveAsync→SqlOrderRepository.SaveAsync).topology/graph_builder.py: a typed target matches the full symbol first, then the method name.diagnostics.py(find_references callers): a short name also matches%.Name.Existing indexes get the typed targets when C# files are indexed again.
Tests
tests/test_csharp_typed_call_targets.py: receiver types from fields,this.fields, parameters,newlocals, primary-constructor parameters, properties, andforeach; a parameter hides a field; unknown receivers stay bare. End to end throughprocess_file_content: controller → service → repository with concrete injection, eachPublishInstancegets only its real caller, and callees follow the field type.test_csharp_primary_ctors_records_mapgroup_routes_and_di_call_tracing) passes locally with the C# grammar.PublishInstancecall sites resolve to the correct class.🤖 Generated with Claude Code