Address DI registration review findings#5
Merged
Conversation
- IZ21CommandStation now extends IProgrammingControl, IFeedbackControl and IFastClockControl, the remaining capabilities the station already implements, so all capabilities are reachable through the resolved station instead of only via a cast on the concrete type. - Make Z21CommandStation.Dispose idempotent. The MS.DI ICommandStation registration forwards to the IZ21CommandStation singleton via a factory, so the same instance is captured for disposal twice; the guard keeps a second Dispose a no-op and protects future non-idempotent cleanup. - Add an Autofac end-to-end inbound-dispatch test (spy transport -> received bytes -> capability event) mirroring the existing MS.DI test, plus capability-exposure tests in both DI suites, so the two containers stay behaviour-equivalent. - Update CLAUDE.md: the dispatcher is a plain singleton and a constructor dependency of the station (no eager auto-activation).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups from a review of the Autofac and Microsoft.Extensions.DependencyInjection registration code. Registration was already correct and behaviour-equivalent; these address the smaller findings.
Changes
IZ21CommandStationnow also extendsIProgrammingControl,IFeedbackControlandIFastClockControl(the station already implemented them). Previously these three were reachable only by casting the concrete instance, while the other four capabilities were part of the interface. No DI registration change needed — the station is already registered.ICommandStationregistration forwards to theIZ21CommandStationsingleton via a factory, so MS.DI captures the same instance for disposal twice and callsDispose()twice on provider teardown. Harmless today (it only disposes aTimer), butZ21CommandStation.Disposeis now guarded so it stays safe if cleanup grows.CLAUDE.mdcorrected: the dispatcher is a plain singleton and a constructor dependency of the station (resolving the station wires inbound handling); there is no eager auto-activation.Verification
Full solution test run is green: Z21.Client 656, Z21.DependencyInjection 7, Z21.Autofac 8, CommandStation.Transport.Udp 14. The new
IZ21CommandStationContractTestwas written test-first (red before the interface change, green after).