Find Usages of a Symbol
find_usagesLists direct callers and references for a C# symbol before you change or delete it, replacing name-based grep with semantic usage results.
Instructions
List who uses a symbol: its direct fan-in. impact_of_change adds the closure and risk; calls_external covers external members.
Use it before changing or deleting a symbol, instead of grepping a C# name. What is listed depends on resolvedKind: 'type' - the types that reference it (a doc cref too, unmarked), plus markup views; 'method' - its callers, overloads unioned; 'property' or 'field' - its readers and writers; 'event' - its raisers and (un)subscribers; 'enum_member' - its references; 'operator' ('op_Equality') - its uses, casts too; 'constructor' ('Type.Type') - the type's construction and injection sites. Test users included.
Returns symbol, resolvedKind and usedBy, a capped envelope (items, count, totalFound, truncated; at most 100). An item is {name, file, line}, one per user: file is solution-relative, line where its declaration starts (not the reference); 'files' [{file, line}] for a type declared in several; absent if unknown; users sharing a name add 'fullName' (a type), 'project'. Optional members qualify it: 'note' ahead of the list (an empty answer, a constructor answer, or unresolved core references), 'namesakes' (several types share the name; usedBy unions them), 'collision' (a bare name: a same-named symbol of another kind, not counted), 'viaContract' + 'viaContractNote' (a qualified method: its contracts' callers), 'selfReferences' (users of a member on its own type), 'textuallyInvisibleUsers' (users whose source never names it), 'nearest' (on 'not_found': a close declared name).
An empty usedBy on a resolved symbol is not proof of dead code: an entry point, DI, reflection, a source generator and unrecorded markup forms leave no reference. 'not_found' is not 'undeclared': a delegate type and a qualified or nested type name answer it too; 'note' may say why.
Read-only. symbol is case-sensitive. A type takes its simple name. A member takes 'Type.Member' for one type's, or a bare name: that answers for ONE kind, the first in the order above with users, unioned over its same-named members.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | The exact (case-sensitive) type, method, property, field, event, enum-member or operator (metadata) name - the qualified Type.Member form for a member - or 'Type.Type' for a type's CONSTRUCTOR (see the tool description: the answer is the type's construction/injection sites, overloads unioned). | |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. |