Unify DI on MS.DI: migrate remaining Lamar consumers
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5
- Forks
- 3
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
Background
Today (2026-04-28) requests 1883432 and 1883433 wedged at status Requesting on DOrc DV 03 because two parallel DI registries got out of sync:
Dorc.PersistentData/PersistentDataRegistry.cs— LamarServiceRegistry, had the newIDaemonObservationPersistentSourceregistration added during the daemons-modernisation work.Dorc.Monitor/Registry/PersistentSourcesRegistry.cs— pure MS.DIIServiceCollection, missed the same registration.
The Monitor is the only project on pure MS.DI. Every deploy (GitHub or otherwise) routed through IPendingRequestProcessor → ... → DaemonsPersistentSource threw InvalidOperationException: Unable to resolve service for type 'IDaemonObservationPersistentSource' while attempting to activate 'DaemonsPersistentSource', and a separate state-machine bug left the rows in Requesting rather than flipping them to Errored. Both immediate bugs are fixed in commit 42e6f354 on feat/649-daemons-modernisation (will land via PR #584). This issue tracks the structural fix.
Scope
Migrate every remaining Lamar consumer to Microsoft.Extensions.DependencyInjection, then remove the Lamar / LamarCodeGeneration / Lamar.Microsoft.DependencyInjection packages.
Projects still on Lamar
Dorc.Api—Program.cs:307builder.Host.UseLamar(...),Services/ApiRegistry.cs : ServiceRegistryDorc.Core—Lamar/CoreRegistry.csDorc.PersistentData—PersistentDataRegistry.cs(the one that was in sync above)Dorc.OpenSearchData—OpenSearchDataRegistry.csDorc.Runner—AppRegistry.csTools.DeployCopyEnvBuildCLI,Tools.PostRestoreEndurCLI,Tools.PropertyValueCreationCLI,Tools.RequestCLI
Dorc.Monitor is already on MS.DI and stays as the reference pattern.
Acceptance criteria
- All projects above use
Microsoft.Extensions.DependencyInjectionexclusively. -
Lamar,LamarCodeGeneration, andLamar.Microsoft.DependencyInjectionpackage references removed from every.csproj. - Persistent-source registration centralised in one place that every host (API, Monitor, Tools) calls — no two registries holding the same registrations.
- Existing test suites pass; ideally add a startup smoke test per host that validates the DI graph (
Dorc.Monitor.IntegrationTestsalready does something similar).
Risks / migration notes
- Lamar quietly auto-wires
Func<T>for any registered concrete; MS.DI does not. Audit allFunc<T>andLazy<T>constructor params; explicitFunc<>registrations may be needed (PR #584 added one of these inApiRegistryforGitHubDeployableBuild— flagged in the same PR). - Lamar
IServiceContext-factory patterns (For<X>().Use(ctx => ...)) need rewriting toIServiceProvider-factory (services.AddTransient<X>(sp => ...)). - Lamar
Scoped()/Singleton()/Transient()map cleanly toAddScoped/AddSingleton/AddTransientbut the default lifetime differs (Lamar: Transient, MS.DI registration must be explicit) — every existing registration needs a deliberate lifetime. - Lamar supports decorator chaining inline; MS.DI doesn't have native decorator support — Scrutor or hand-rolled decorators may be needed in places.
Why this is high priority
A DI registration miss like this morning's silently wedges deploys without erroring fast — the request just sits in Requesting forever and only manual cancel + monitor restart clears it. With one registry in one place, the whole class of bug goes away.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Dorc.Monitor as the MS.DI reference pattern, then inspect Program.cs, the listed registry files, CLI projects, and their .csproj package references. Audit the Lamar registrations, constructor dependencies, lifetimes, factories, and decorators before running the existing suites and Dorc.Monitor.IntegrationTests. Done means all listed hosts use MS.DI, shared persistent-source registration is centralized, Lamar packages are removed, and the DI graphs validate at startup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100