Find Dead Code
find_dead_codeIdentify suspected dead code in C#/.NET solutions by listing private methods with no measured callers and types with no incoming references, with scope and test filtering.
Instructions
List dead-code suspects on two axes. kinds='type': types with no incoming reference find_usages sees. kinds='method' (the default): PRIVATE methods with an empty recorded caller list (private nested types' too, not overrides or interface implementations). kinds='all': both.
The method axis skips a method a framework may call ([RelayCommand] or other framework attributes, partial methods, markup or designer event handlers, static Main, record PrintMembers, ShouldSerialize/Reset) or whose callers were not measured (unresolved references, explicit interface implementations). A nameof in an attribute (CanExecute) or a reflection lookup (GetMethod) counts as a use. *.Designer.cs and *.g.cs are read for references, never judged.
Returns scope, a 'note' first if any, methodsScanned, deadMethods and - when the type axis ran - typesScanned and deadTypes: max 200 each (methods: name, declaringType, namespace; types: name, kind, accessibility, namespace, publicApi:true on a library's public type (publicApiNote); alike rows add declaringTypeFullName, signature, fullName or project). Counters, omitted at zero: methodsIneligible and typesIneligible, split by reason (methodsIneligibleNotPrivate, -FrameworkInvoked, -UnanalyzedCallers; typesIneligibleStructural, -TestScaffolding, -FrameworkActivated, -MarkupReferenced), methodsJudged/typesJudged (scanned minus ineligible; per type and project, not per row), typesUnexamined (what the type axis would have judged), testMethodsFiltered and testTypesFiltered (removed by the test filter).
A listed candidate is a suspect (the note: what zero fan-in does not prove, how to check). The type axis exempts types it cannot see in use: interfaces, static classes, *Extensions types, test scaffolding, framework- or reflection-activated and markup-referenced types. An empty answer without a note: an axis judged an eligible population and found nothing.
Read-only; works on a recalled session.
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_dead_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kinds | No | 'method' (default): private methods with a measured, empty caller list - see the description for what that axis does not judge; 'type': types with no incoming reference; 'all': both; any other non-blank value runs both axes. | method |
| scope | No | 'solution' (default) or a namespace prefix (e.g. 'MyApp.Core') to narrow scope. | solution |
| 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 methods/types (default false - production dead-code; a private test-helper without callers is not production dead code). |