Skip to content

Commit 4577899

Browse files
authored
Replace IsNullOrWhiteSpace extension (#1142)
1 parent a4dbf77 commit 4577899

File tree

4 files changed

+15
-42
lines changed

4 files changed

+15
-42
lines changed

src/Renci.SshNet/AuthenticationMethod.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22

3-
using Renci.SshNet.Common;
4-
53
namespace Renci.SshNet
64
{
75
/// <summary>
@@ -34,7 +32,7 @@ public abstract class AuthenticationMethod : IAuthenticationMethod
3432
/// <exception cref="ArgumentException"><paramref name="username"/> is whitespace or <c>null</c>.</exception>
3533
protected AuthenticationMethod(string username)
3634
{
37-
if (username.IsNullOrWhiteSpace())
35+
if (string.IsNullOrWhiteSpace(username))
3836
{
3937
throw new ArgumentException("username");
4038
}

src/Renci.SshNet/Common/Extensions.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,6 @@ namespace Renci.SshNet.Common
1515
/// </summary>
1616
internal static partial class Extensions
1717
{
18-
/// <summary>
19-
/// Determines whether the specified value is null or white space.
20-
/// </summary>
21-
/// <param name="value">The value.</param>
22-
/// <returns>
23-
/// <c>true</c> if <paramref name="value"/> is null or white space; otherwise, <c>false</c>.
24-
/// </returns>
25-
public static bool IsNullOrWhiteSpace(this string value)
26-
{
27-
if (string.IsNullOrEmpty(value))
28-
{
29-
return true;
30-
}
31-
32-
for (var i = 0; i < value.Length; i++)
33-
{
34-
if (!char.IsWhiteSpace(value[i]))
35-
{
36-
return false;
37-
}
38-
}
39-
40-
return true;
41-
}
42-
4318
internal static byte[] ToArray(this ServiceName serviceName)
4419
{
4520
switch (serviceName)

src/Renci.SshNet/ScpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void Upload(Stream source, string path)
243243
/// <exception cref="SshException">The secure copy execution request was rejected by the server.</exception>
244244
public void Download(string filename, Stream destination)
245245
{
246-
if (filename.IsNullOrWhiteSpace())
246+
if (string.IsNullOrWhiteSpace(filename))
247247
{
248248
throw new ArgumentException(Message);
249249
}

src/Renci.SshNet/SftpClient.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public void CreateDirectory(string path)
326326
{
327327
CheckDisposed();
328328

329-
if (path.IsNullOrWhiteSpace())
329+
if (string.IsNullOrWhiteSpace(path))
330330
{
331331
throw new ArgumentException(path);
332332
}
@@ -355,7 +355,7 @@ public void DeleteDirectory(string path)
355355
{
356356
CheckDisposed();
357357

358-
if (path.IsNullOrWhiteSpace())
358+
if (string.IsNullOrWhiteSpace(path))
359359
{
360360
throw new ArgumentException("path");
361361
}
@@ -384,7 +384,7 @@ public void DeleteFile(string path)
384384
{
385385
CheckDisposed();
386386

387-
if (path.IsNullOrWhiteSpace())
387+
if (string.IsNullOrWhiteSpace(path))
388388
{
389389
throw new ArgumentException("path");
390390
}
@@ -415,7 +415,7 @@ public async Task DeleteFileAsync(string path, CancellationToken cancellationTok
415415
{
416416
CheckDisposed();
417417

418-
if (path.IsNullOrWhiteSpace())
418+
if (string.IsNullOrWhiteSpace(path))
419419
{
420420
throw new ArgumentException("path");
421421
}
@@ -542,12 +542,12 @@ public void SymbolicLink(string path, string linkPath)
542542
{
543543
CheckDisposed();
544544

545-
if (path.IsNullOrWhiteSpace())
545+
if (string.IsNullOrWhiteSpace(path))
546546
{
547547
throw new ArgumentException("path");
548548
}
549549

550-
if (linkPath.IsNullOrWhiteSpace())
550+
if (string.IsNullOrWhiteSpace(linkPath))
551551
{
552552
throw new ArgumentException("linkPath");
553553
}
@@ -753,7 +753,7 @@ public bool Exists(string path)
753753
{
754754
CheckDisposed();
755755

756-
if (path.IsNullOrWhiteSpace())
756+
if (string.IsNullOrWhiteSpace(path))
757757
{
758758
throw new ArgumentException("path");
759759
}
@@ -882,7 +882,7 @@ public IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback
882882
{
883883
CheckDisposed();
884884

885-
if (path.IsNullOrWhiteSpace())
885+
if (string.IsNullOrWhiteSpace(path))
886886
{
887887
throw new ArgumentException("path");
888888
}
@@ -1109,7 +1109,7 @@ public IAsyncResult BeginUploadFile(Stream input, string path, bool canOverride,
11091109
throw new ArgumentNullException(nameof(input));
11101110
}
11111111

1112-
if (path.IsNullOrWhiteSpace())
1112+
if (string.IsNullOrWhiteSpace(path))
11131113
{
11141114
throw new ArgumentException("path");
11151115
}
@@ -2106,7 +2106,7 @@ public IEnumerable<FileInfo> SynchronizeDirectories(string sourcePath, string de
21062106
throw new ArgumentNullException(nameof(sourcePath));
21072107
}
21082108

2109-
if (destinationPath.IsNullOrWhiteSpace())
2109+
if (string.IsNullOrWhiteSpace(destinationPath))
21102110
{
21112111
throw new ArgumentException("destinationPath");
21122112
}
@@ -2135,7 +2135,7 @@ public IAsyncResult BeginSynchronizeDirectories(string sourcePath, string destin
21352135
throw new ArgumentNullException(nameof(sourcePath));
21362136
}
21372137

2138-
if (destinationPath.IsNullOrWhiteSpace())
2138+
if (string.IsNullOrWhiteSpace(destinationPath))
21392139
{
21402140
throw new ArgumentException("destDir");
21412141
}
@@ -2340,7 +2340,7 @@ private void InternalDownloadFile(string path, Stream output, SftpDownloadAsyncR
23402340
throw new ArgumentNullException(nameof(output));
23412341
}
23422342

2343-
if (path.IsNullOrWhiteSpace())
2343+
if (string.IsNullOrWhiteSpace(path))
23442344
{
23452345
throw new ArgumentException("path");
23462346
}
@@ -2404,7 +2404,7 @@ private void InternalUploadFile(Stream input, string path, Flags flags, SftpUplo
24042404
throw new ArgumentNullException(nameof(input));
24052405
}
24062406

2407-
if (path.IsNullOrWhiteSpace())
2407+
if (string.IsNullOrWhiteSpace(path))
24082408
{
24092409
throw new ArgumentException("path");
24102410
}

0 commit comments

Comments
 (0)