Replace IsNullOrWhiteSpace extension (#1142)

This commit is contained in:
Rob Hague
2023-06-12 23:21:25 +02:00
committed by GitHub
parent a4dbf7763a
commit 457789947c
4 changed files with 15 additions and 42 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
using System;
using Renci.SshNet.Common;
namespace Renci.SshNet
{
/// <summary>
@@ -34,7 +32,7 @@ namespace Renci.SshNet
/// <exception cref="ArgumentException"><paramref name="username"/> is whitespace or <c>null</c>.</exception>
protected AuthenticationMethod(string username)
{
if (username.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(username))
{
throw new ArgumentException("username");
}
-25
View File
@@ -15,31 +15,6 @@ namespace Renci.SshNet.Common
/// </summary>
internal static partial class Extensions
{
/// <summary>
/// Determines whether the specified value is null or white space.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> is null or white space; otherwise, <c>false</c>.
/// </returns>
public static bool IsNullOrWhiteSpace(this string value)
{
if (string.IsNullOrEmpty(value))
{
return true;
}
for (var i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i]))
{
return false;
}
}
return true;
}
internal static byte[] ToArray(this ServiceName serviceName)
{
switch (serviceName)
+1 -1
View File
@@ -243,7 +243,7 @@ namespace Renci.SshNet
/// <exception cref="SshException">The secure copy execution request was rejected by the server.</exception>
public void Download(string filename, Stream destination)
{
if (filename.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(filename))
{
throw new ArgumentException(Message);
}
+13 -13
View File
@@ -326,7 +326,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException(path);
}
@@ -355,7 +355,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -384,7 +384,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -415,7 +415,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -542,12 +542,12 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
if (linkPath.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(linkPath))
{
throw new ArgumentException("linkPath");
}
@@ -753,7 +753,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -882,7 +882,7 @@ namespace Renci.SshNet
{
CheckDisposed();
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -1109,7 +1109,7 @@ namespace Renci.SshNet
throw new ArgumentNullException(nameof(input));
}
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -2106,7 +2106,7 @@ namespace Renci.SshNet
throw new ArgumentNullException(nameof(sourcePath));
}
if (destinationPath.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(destinationPath))
{
throw new ArgumentException("destinationPath");
}
@@ -2135,7 +2135,7 @@ namespace Renci.SshNet
throw new ArgumentNullException(nameof(sourcePath));
}
if (destinationPath.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(destinationPath))
{
throw new ArgumentException("destDir");
}
@@ -2340,7 +2340,7 @@ namespace Renci.SshNet
throw new ArgumentNullException(nameof(output));
}
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}
@@ -2404,7 +2404,7 @@ namespace Renci.SshNet
throw new ArgumentNullException(nameof(input));
}
if (path.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("path");
}