Find Event Subscriptions
find_by_event_subscriptionFind which C# types subscribe to an event by locating '+=' handlers, including external events, to see who listens, where handlers are wired, and spot possible leaks.
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 skipped (no subscription). XAML-wired handlers (Click="OnClick") are 'markupWires' (handler, viewCount, views), owe no '-=', are never 'unreleased' and, recording no event, never match eventName.
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 (the build 'Name(tfm)' where only it declares the type; 'projects' where several do). 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.
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. 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, matched exactly (never as a substring). A qualified solution type in front ('Ns.Type.Event', 'Outer.Inner.Event') reads as that key where no type of that simple name lies outside it (a 'note' says so). 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). |