<PackageReference Include="SSH.NET" Version="2025.0.0" />

TimeSpanExtensions

static class TimeSpanExtensions
Provides extension methods for TimeSpan.
using System; using System.Runtime.CompilerServices; namespace Renci.SshNet.Common { [NullableContext(2)] [Nullable(0)] internal static class TimeSpanExtensions { public static int AsTimeout(this TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string paramName = null) { double totalMilliseconds = timeSpan.TotalMilliseconds; if ((!(totalMilliseconds < -1) && !(totalMilliseconds > 2147483647)) || 1 == 0) return (int)totalMilliseconds; throw new ArgumentOutOfRangeException(paramName, "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive."); } public static void EnsureValidTimeout(this TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string paramName = null) { timeSpan.AsTimeout(paramName); } } }