Find Usages of a Symbol
find_usagesLists who uses a C# symbol (direct fan-in) by resolved kind before you change or delete it, replacing grep with semantic, read-only reference results.
Instructions
List who uses a symbol (direct fan-in); impact_of_change adds closure + risk, calls_external external members.
Use it before changing or deleting a symbol, not grep. Listed per resolvedKind: 'type' - the types that reference it (a doc cref too: docCrefOnly), plus markup views; 'method' - its callers, overloads unioned ('overloads'; item 'calls': its own), and the types whose doc cref names it (docCrefOnly); '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, usedBy (capped envelope: items, count, totalFound, truncated; max 100). Item: {name, file, line}, one per user: file is solution-relative, line its declaration's start (not the reference); 'files' [{file, line}] for a multi-file type (holding files, else all); absent if unknown; users sharing a name add 'fullName' (a type), 'project'. Optional: 'note' first (an empty or constructor answer, unresolved core references), 'namesakes' (several types share it, unioned), 'collision' (a same-named other kind, not counted), 'viaContract' + 'viaContractNote' (a qualified method's contract or virtual-base callers), 'selfReferences' (users on the member's own type), 'textuallyInvisibleUsers' (users not naming it), 'nearest' (on 'not_found': a close name), 'resourceKeyNote' (markup keys the type; those views: find_resource_usages).
An empty usedBy on a resolved symbol is not proof of dead code: entry points, DI, reflection, generators and unrecorded markup leave no reference. 'not_found' is not 'undeclared': a delegate type and an unread qualified name answer it; 'note' may say why.
Read-only, case-sensitive. A type takes its simple name; a member 'Type.Member' (one type's) or a bare name: ONE kind, the first in the order above with users, unioned over its same-named members.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>",
"symbol": "<symbol>"
},
"name": "find_usages"
}
}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, a qualified type name ('Ns.Type', 'Outer.Inner') where no type of that simple name lies outside it (a 'note' says so; else not_found says why) - 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. | |
| includeTests | No | Include users declared in test projects (default true). false lists production users only, BEFORE the 100-item cap, and 'testUsersFiltered' says how many were left out; viaContract keeps counting every caller. |