Add interface to SshCommand
Changes:
- Add ISshCommand interface containing all public properties and methods of SshCommand
- Update SshClient methods to return ISshCommand instead of SshCommand
Closes #1507
I am a bit uneasy about this one because of the breaking changes it introduces
what exact breaking change are you referring to? As I understand the only problem might occur if the user had a code like this
SshCommand command = client.CreateCommand("ls");
But this code would be quite rare as the modern preferred coding style is
var command = client.CreateCommand("ls");
Every release there are small breaking changes. This change won't be very big and would be caught during compile time.
We might introduce another interface ISshClient2 which returns ISshCommand instead of SshCommand. But it won't make much sense as we anyway have to replace the main interface ISsshClient with it.
Yes that is the breaking change I am referring to.
But this code would be quite rare as the modern preferred coding style is
It is not my preferred coding style :-)
The breaking changes in each release are considered based on how many people it is going to benefit vs inconvenience. You can see my thoughts on mocking the library here https://github.com/sshnet/SSH.NET/issues/1667#issuecomment-3065200031, but in short, I don't consider it an important feature for which is worth inconveniencing an unknown but possibly large number of people.
If we want to compare the proposed change here against prior changes:
- #812. IMO this was a mistake. Even so, it is less inconvenient than this change due to implicit conversion in foreach loops (so
foreach (SftpFile file in client.ListDirectory(...))still compiles) - #1628. Also a breaking change, but since these interfaces seem to only exist for people to mock, then it is more like "you get what you asked for"