refactor: extract IPowerShellRunner seam for DNS/network/winget services#823
Merged
Merged
Conversation
Introduces IPowerShellRunner over the concrete PowerShellRunner so the system-mutating services route through a substitutable seam (Gate-ARCH: 'external process/PowerShell calls route through the single runner seam'). - New IPowerShellRunner exposing RunAsync, RunScriptViaPwshAsync, RunProcessAsync, and the LineReceived/ProgressChanged events. - PowerShellRunner now implements IPowerShellRunner (members unchanged). - DnsService, NetworkRepairService, BulkInstallerService constructors take IPowerShellRunner instead of the concrete type. - DI registers IPowerShellRunner -> PowerShellRunner (Transient) alongside the existing concrete registration kept for the remaining consumers. Behavior is identical: only the dependency type the three services accept changes. The static PowerShellRunner.OemEncoding stays on the concrete class. Unblocks the install/repair/DNS-script unit tests in the next PR.
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.
What
Audit Round 4 / PR2 — Gate-ARCH seam extraction (covers test findings #7, #8, #9). Introduces
IPowerShellRunnerover the concretePowerShellRunner:IPowerShellRunnerexposingRunAsync,RunScriptViaPwshAsync,RunProcessAsync, and theLineReceived/ProgressChangedevents.PowerShellRunner : IPowerShellRunner(members unchanged).DnsService,NetworkRepairService,BulkInstallerServiceconstructors now takeIPowerShellRunner.IPowerShellRunner -> PowerShellRunner(Transient) alongside the existing concrete registration, kept for the remaining consumers that still resolve the concrete type.Why
These three services mutate live state (DNS servers, Winsock/TCP-IP, winget install) but depend on the concrete
sealed PowerShellRunner, so NSubstitute can't substitute them — every test was forced tonew XxxService(new PowerShellRunner())and avoid the Apply paths entirely. This seam is the precondition for the install/repair/DNS-script unit tests in the next PR.Behavior guarantee (Protocol Q)
Behavior is byte-for-byte identical — only the dependency type the three services accept changes. No logic touched. The static
PowerShellRunner.OemEncodingstays on the concrete class and is still referenced asPowerShellRunner.OemEncodingeverywhere.Verification
newthese services (MainWindowViewModel + 2 test helpers) still compile unchanged (PowerShellRunnerISIPowerShellRunner). No half-migration.Notes
refactor:— no version bump, no release, no CHANGELOG entry required.