Resolve Dependency Injection
resolve_injectionIdentify what Microsoft DI or MEF registers for a service, including lifetime, implementation, and site, so you can confirm how dependencies are wired.
Instructions
Resolve a Microsoft DI or MEF registration: what is registered for a service, with lifetime and site. Not usage (find_usages), implementers (find_implementations), construction (instantiation_sites).
It reads Add{Singleton,Scoped,Transient}, TryAdd*, descriptor adds built at the call, AddHostedService, project-local helpers registering their own type arguments, and a foreach over a static new(typeof(Service), typeof(Impl)) table. A key, and a closing, is a service of its own (IRepo, IRepo); open IRepo<> is read. Not read: a descriptor built elsewhere, AddHttpClient-style helpers, Scrutor, other containers. Umbraco collection builders are listed apart (collectionBuilders).
Returns JSON: registrations (serviceType, implementationType [= service if self/instance], lifetime, note, location, project, declaringMethod, key, targetFrameworks: a multi-targeted project's call is one row; note 'inferred, not read' = from a package helper's call shape AddSingletonAs().As(): lifetime from its name, never ambiguous or a winner) and: multiRegistration / registrationSites; ambiguous (possible conflict: ONE site registers several implementations of one service, receivers not compared, not consumed as a collection); effectiveRegistration (2+ calls: the winner a single-service resolve gets, read in ONE straight-line site; else null + reason); consumedAsCollection; constructorConsumerCount (plain ctor parameters); otherConsumers (GetService outside a registration factory, [Inject], @inject: per form); optionalDependencies (optional ctor parameters: yes/no/unknown).
An empty list says why: resolvedKind 'not_found' plus 'nearest' = no such name; else a 'note' names the forms not read and which the solution holds - empty means 'not statically visible', never 'not registered'.
Test projects count only with includeTests=true; testRegistrationsFiltered counts what that hid. interface is the SERVICE type (a self-registered class too); a closed form (IRepo) lists that closing and IRepo<> (typeArgumentFilter: the rest).
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>",
"interface": "<interface>"
},
"name": "resolve_injection"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | Optional: narrow to registrations whose file path contains this substring. | |
| interface | Yes | The interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'. A simple name lists every type of that name; a qualified one ('App.Settings.IPanel') leaves out same-named types of other namespaces and says how many. A closed generic form ('IHandler<Saved>') lists only the registrations serving that closing; 'IHandler' or 'IHandler<T>' lists every closing. | |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. | |
| includeTests | No | Include registrations declared in test projects (default false - production focus). |