Description
In src/Servy.Core/Services/ServiceManager.cs, the class injects IWin32ErrorProvider _win32ErrorProvider and uses it consistently in most methods (lines 122, 146, 183, 305). However, two methods bypass the abstraction and call Marshal.GetLastWin32Error() directly:
Line 511 — InstallServiceAsync:
int error = Marshal.GetLastWin32Error();
Line 829 — GetAllServices:
throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to open Service Control Manager.");
This breaks the testability contract — unit tests that mock IWin32ErrorProvider cannot control behavior in these two methods.
Severity
Warning — bypasses the injected abstraction, breaks testability.
Suggested fix
Replace Marshal.GetLastWin32Error() with _win32ErrorProvider.GetLastWin32Error() in both locations.
Description
In
src/Servy.Core/Services/ServiceManager.cs, the class injectsIWin32ErrorProvider _win32ErrorProviderand uses it consistently in most methods (lines 122, 146, 183, 305). However, two methods bypass the abstraction and callMarshal.GetLastWin32Error()directly:Line 511 —
InstallServiceAsync:Line 829 —
GetAllServices:This breaks the testability contract — unit tests that mock
IWin32ErrorProvidercannot control behavior in these two methods.Severity
Warning — bypasses the injected abstraction, breaks testability.
Suggested fix
Replace
Marshal.GetLastWin32Error()with_win32ErrorProvider.GetLastWin32Error()in both locations.