Find XAML Resource Usages
find_resource_usagesFinds where XAML/AXAML and C# resource string keys are defined and referenced, and audits never-referenced keys, same-file collisions, and keys no markup defines.
Instructions
Resource-key fan-in across the solution's XAML/AXAML markup AND its C# sources - the question the C# symbol graph cannot answer because resources are wired by string key, not by symbol. With a key: where it is DEFINED (x:Key, file:line), every REFERENCE (file:line + kind: 'static'/'dynamic' for the markup extension, since a theme-swapped brush must be dynamic; 'theme' for WinUI's {ThemeResource}; 'code' for a C# string literal equal to the key; 'callerMemberName' for a C# member named like the key that reads it through a [CallerMemberName] resource accessor), and same-file duplicate definitions (in a compiled resource dictionary a duplicate silently shadows a neighboring key; a same-named key in DIFFERENT files is usually a theme pair, so only same-file counts as a collision). themeReferenceCount and callerMemberNameReferenceCount appear only when not zero. Without a key: the audit view - every never-referenced key (deletion candidates; deleting a still-referenced key compiles clean and throws only at runtime) + all same-file collisions + every referenced key no markup defines: misspelledKeyCandidates (one slip from a defined key) and notDefinedInSolutionKeys (most often a theme's or the platform's key - unknown, not broken). Reads the CURRENT .xaml/.axaml/.cs files on disk (bin/obj/.vs excluded) - never stale after an edit, no refresh_session needed, works on recalled sessions. STRING keys only (a structural x:Key="{x:Type ...}" is out of scope); the ResourceKey= long form, the element and a markup extension the solution derives from StaticResourceExtension/DynamicResourceExtension are read. XML-commented markup is ignored. Still invisible: a key assembled at runtime, a non-.cs source, a resource-extension subclass from a referenced library, a library template resolving the key from its own dll - zero references means 'verify before deleting', not proof. Lists capped at 200.
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_resource_usages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | The exact (case-sensitive) resource key, e.g. 'TextPrimaryBrush'. Omit for the audit view (never-referenced keys, same-file collisions, keys no markup defines). | |
| scope | No | 'solution' (default) or a view-path substring (e.g. 'AIContextBuilder.UI/') to narrow which files are reported. In the audit view the scope narrows the DEFINITIONS under audit; references still count solution-wide, so a key referenced outside the scope is not a false orphan. For the keys no markup defines it is the other way round: the scope narrows the REFERENCES under audit, and a definition anywhere in the solution counts. | solution |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. |