Find Event Subscriptions
find_by_event_subscriptionFind C# types subscribing to an event via '+=' to identify listeners, handler wiring, and unreleased subscriptions for leak detection.
Instructions
Find the TYPES that subscribe to a C# event: a '+=' whose left side resolves to an event, anywhere in the type; external events too ('Button.Click'). find_usages on a solution-declared event lists its (un)subscribing and raising METHODS.
Use it for 'who listens to this event?', where handlers are wired, and as a leak hint. A '+=' on a number, string or delegate field is no subscription and is skipped. XAML-wired handlers (Click="OnClick") are 'markupWires' (handler, viewCount, views), owe no '-=', are never 'unreleased'; no event is recorded with them, so eventName cannot match them.
Returns scope, event, typesScanned, subscriptionSitesChecked, subscriptionSitesUnresolved, matches (at most 200 types: name, namespace, events, unreleased, markupWires; sorted by namespace, name) and when they apply 'note', availableEvents, testMatchesFiltered. A partial type is one row ('files' when spread over several); 'fullName' marks namesakes, 'project' linked-file twins. A hit lists ALL event keys ('DeclaringType.EventName') the type subscribes to.
'unreleased' lists each subscription no '-=' of the type removes ('Event <- Handler'). A '-=' counts for the same event AND the same handler on ANY receiver, so an old/new swap reads released; a lambda never matches, so a lambda subscription is always listed; a subscription to an object the type owns is listed although it cannot outlive it. [] means each has a matching '-='; no list means not measured (see the note). A place to look, not a proven leak.
Reading an empty answer: availableEvents lists the events subscribed in scope; read testMatchesFiltered first if present. An EMPTY availableEvents means none was RECORDED - recognition needs a resolved left side. The site counts settle it: '0 of 0' is nothing to see, '0 of 7, 0 unresolved' a real absence, '0 of 7, 7 unresolved' an unmeasured scope.
Read-only; works on a recalled session. eventName matches exactly, never as a substring; omit it for every subscribing type. Test-project types are excluded unless includeTests=true.
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>"
},
"name": "find_by_event_subscription"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | 'solution' (default) or a namespace prefix (e.g. 'MyApp.UI') to narrow scope. | solution |
| eventName | No | Filter to types subscribing to this event - the event name ('Click') or the qualified 'DeclaringType.EventName' key ('Button.Click'), case-insensitive. Omit to list every type with any subscription. | |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. | |
| includeTests | No | Include test-project types (default false - production focus; test setup that wires events would drown the signal). |