-
-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit TimeSpan timeouts to Int32 MaxValue #1321
Limit TimeSpan timeouts to Int32 MaxValue #1321
Conversation
34e4285
to
ead7bd0
Compare
…n Int32 in milliseconds.
ead7bd0
to
3ad2451
Compare
@WojciechNagorski @Rob-Hague Ready for review and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing what problem this solves. If an underlying API doesn't accept a certain range of TimeSpan, aren't we going to get an error either way? Isn't it better to let the API decide?
I'm not sure what you mean by "the API". But basically, the issue boils down to the fact that the timeouts are injested by SSH.NET's public methods as TimeSpans but then used internally for timeouts that int based. The goal is to bring validation to the outer edge of the public methods of SSH.NET to avoid OutOfRange exceptions that could come from the internals of SSH.NET. |
How to reproduce the error or how does it manifest itself? I don't know what's improved here either? Can you add a test that didn't work before but now works? |
@Rob-Hague @WojciechNagorski The latest version that's in develop gives me a ton of IDE0005 build errors: |
I'll take care of it. |
I meant, if we're forwarding the TimeSpan to a method on e.g. I guess I felt like I was missing some context or motivation for this change. But I think it's OK in principal
That sounds like VS weirdness. It's OK for me (although sometimes it feels like the IDE doesn't know what to do with so many analyzers) |
Generally speaking, it is considered good design that libraries validate and throw early in public API methods. As an example of this, you can take analyzer rule CA1062 for null checks. The original reason I looked into this was because of #14, which although at the surface may seem superfluous, is actually valid. |
I'm using Rider and dotnet build with SDK 8.0.200. So I don't think this has anything to do with VS. |
…n Int32 in milliseconds.
…onInfoTimeout # Conflicts: # src/Renci.SshNet/Abstractions/SocketAbstraction.cs # src/Renci.SshNet/BaseClient.cs # src/Renci.SshNet/Common/TimeSpanExtensions.cs # src/Renci.SshNet/ConnectionInfo.cs # src/Renci.SshNet/ForwardedPort.cs # src/Renci.SshNet/ForwardedPortDynamic.cs # src/Renci.SshNet/ForwardedPortLocal.cs # src/Renci.SshNet/ForwardedPortRemote.cs # src/Renci.SshNet/NetConfClient.cs # src/Renci.SshNet/ScpClient.cs # src/Renci.SshNet/Sftp/SftpFileStream.cs # src/Renci.SshNet/SftpClient.cs # src/Renci.SshNet/SshCommand.cs
I added |
@WojciechNagorski @Rob-Hague Ready for final review and merge. |
@WojciechNagorski I fixed the reference you mentioned. I must have been really tired, that slipped right past me. |
|
||
# IDE0005: Remove unnecessary using directives | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005 | ||
dotnet_diagnostic.IDE0005.severity = suggestion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this? I think after restarting VS (or restarting your computer) everything should work.
This is the last message and then I will be able to merge this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing this locally as well, the errors look real. I think it could be related to upgrading the SDK but I have no idea why we haven't seen it before.
I am trying to fix it with dotnet format
but not having much luck :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong, I don't know what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Added guard clauses to various timeouts to ensure they don't exceed an Int32 in milliseconds.
Resolves #14.