Skip to content

Commit a95e1f2

Browse files
authored
Fix implementation of timeout properties (#113)
***NO_CI***
1 parent a1ca575 commit a95e1f2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

System.IO.Ports/SerialPort.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ public string NewLine
383383
/// <exception cref="IOException">The port is in an invalid state. -or- An attempt to set the state of the underlying
384384
/// port failed. For example, the parameters passed from this <see cref="SerialPort"/>
385385
/// object were invalid.</exception>
386-
/// <exception cref="ArgumentOutOfRangeException">The read time-out value is less than zero and not equal to <see cref="Timeout"/>.</exception>
386+
/// <exception cref="ArgumentOutOfRangeException">The read time-out value is less than zero and not equal to <see cref="Timeout.Infinite"/>.</exception>
387387
public int ReadTimeout
388388
{
389389
get => _readTimeout;
390390

391391
set
392392
{
393-
if (value <= 0)
393+
if (value < 0 && value != Timeout.Infinite)
394394
{
395395
throw new ArgumentOutOfRangeException();
396396
}
@@ -406,15 +406,14 @@ public int ReadTimeout
406406
/// <exception cref="IOException">The port is in an invalid state. -or- An attempt to set the state of the underlying
407407
/// port failed. For example, the parameters passed from this <see cref="SerialPort"/>
408408
/// object were invalid.</exception>
409-
/// <exception cref="ArgumentOutOfRangeException">The <see cref="WriteTimeout"/> value is less than zero and not equal
410-
/// to <see cref="Timeout"/>.</exception>
409+
/// <exception cref="ArgumentOutOfRangeException">The read time-out value is less than zero and not equal to <see cref="Timeout.Infinite"/>.</exception>
411410
public int WriteTimeout
412411
{
413412
get => _writeTimeout;
414413

415414
set
416415
{
417-
if ((value < 0) && (value != Timeout.Infinite))
416+
if (value < 0 && value != Timeout.Infinite)
418417
{
419418
throw new ArgumentOutOfRangeException();
420419
}

0 commit comments

Comments
 (0)