Uh oh!
There was an error while loading. Please reload this page.
Avoid rounding issues when checking Timeout values (#1700) - #1712
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a rounding issue in the AsTimeout extension method that was causing incorrect timeout validation failures. The issue occurred when checking Timeout.InfiniteTimeSpan values due to floating-point precision problems that were compiler/optimization dependent.
- Changed timeout calculation from
doubletolongto avoid floating-point rounding issues - Updated the range check to use integer comparison instead of floating-point comparison
- Enhanced the exception message to include the actual timeout value for better debugging
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
nikolamilekic
commented
Oct 7, 2025
It can be argued that the range check is completely unnecessary when called from the SshCommand ctor (as it is always called with |
AsTimeout is called from the SshCommand constructor with Timeout.InfiniteTimeSpan. In this scenario the range check should never fail, but unfortunately it does in certain scenarios, due to a runtime or compiler bug (as soon as optimizations are turned off the issue miraculously disappears). Closessshnet#1700
Rob-Hague
commented
Oct 8, 2025
I had half-fixed the tests that were asserting too strictly against the original commit, so I finished that and reverted to the original. Making the comparison on Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
AsTimeout is called from the SshCommand constructor with Timeout.InfiniteTimeSpan. In this scenario the range check should never fail, but unfortunately it does in certain scenarios, due to a runtime or compiler bug (as soon as optimizations are turned off the issue miraculously disappears).
Closes#1700