Find Event Subscriptions
find_by_event_subscriptionFind which C# types subscribe to an event via '+=' anywhere in the type, including external events like Button.Click. Answers 'who listens to this event?'.
Instructions
Find the TYPES that subscribe to a C# event: a '+=' whose left side resolves to an event, anywhere in the type (constructor, method, accessor, lambda). find_usages on an event the solution declares lists the subscribing, unsubscribing and raising METHODS; this tool works at type level and also sees external events ('Button.Click').
Use it for 'who listens to this event?' and to find where handlers are wired. Only subscriptions ('+=') are read, not '-='; a '+=' on a number, a string or a delegate field is not a subscription and is skipped.
Returns scope, event, typesScanned, subscriptionSitesChecked, subscriptionSitesUnresolved, matches - a capped envelope of at most 200 types (name, namespace, events), sorted by namespace and name - and when they apply 'note', availableEvents and testMatchesFiltered. A hit lists ALL event keys the type subscribes to ('DeclaringType.EventName'), not only the one filtered on.
Reading an empty answer: on zero matches availableEvents lists the events subscribed in scope. When testMatchesFiltered is present, read it first - the name was right and only its subscribers were tests. An EMPTY availableEvents means no subscription was RECORDED, which is not the same as none being present: recognition needs a resolved left side, so in a project whose types do not resolve every subscription is missing. The two site counts settle it: subscriptionSitesChecked is every '+=' the rule was applied to, subscriptionSitesUnresolved those whose left side could not be resolved. '0 of 0' is nothing to see, '0 of 7, 0 unresolved' a real absence, '0 of 7, 7 unresolved' an unmeasured scope - and that one carries a note.
Read-only; works on a recalled session. eventName is matched exactly, never as a substring; omit it to list every subscribing type. Test-project types are excluded by default (includeTests=true includes them).
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). |