Skip to content

Commit b7fd333

Browse files
committed
Code cleanup as requested by review sshnet#2
1 parent 6fb5be2 commit b7fd333

13 files changed

+110
-276
lines changed

.vs/ProjectSettings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vs/VSWorkspaceState.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.vs/slnx.sqlite

-88 KB
Binary file not shown.

src/Renci.SshNet/Abstractions/DnsAbstraction.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#if FEATURE_DNS_SYNC
1010
#elif FEATURE_DNS_APM
1111
using Renci.SshNet.Common;
12+
#elif FEATURE_DNS_TAP
1213
#elif FEATURE_DEVICEINFORMATION_APM
1314
using System.Collections.Generic;
1415
using System.Linq;
@@ -45,6 +46,8 @@ public static IPAddress[] GetHostAddresses(string hostNameOrAddress)
4546
if (!asyncResult.AsyncWaitHandle.WaitOne(Session.InfiniteTimeSpan))
4647
throw new SshOperationTimeoutException("Timeout resolving host name.");
4748
return Dns.EndGetHostAddresses(asyncResult);
49+
#elif FEATURE_DNS_TAP
50+
return Dns.GetHostAddressesAsync(hostNameOrAddress).GetAwaiter().GetResult();
4851
#else
4952
IPAddress address;
5053
if (IPAddress.TryParse(hostNameOrAddress, out address))

src/Renci.SshNet/Abstractions/SocketAbstraction.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSp
7474
#if FEATURE_SOCKET_EAP
7575
var connectCompleted = new ManualResetEvent(false);
7676
var args = new SocketAsyncEventArgs
77-
{
78-
UserToken = connectCompleted,
79-
RemoteEndPoint = remoteEndpoint
80-
};
77+
{
78+
UserToken = connectCompleted,
79+
RemoteEndPoint = remoteEndpoint
80+
};
8181
args.Completed += ConnectCompleted;
8282

8383
if (socket.ConnectAsync(args))
@@ -107,7 +107,7 @@ private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSp
107107

108108
if (args.SocketError != SocketError.Success)
109109
{
110-
var socketError = (int)args.SocketError;
110+
var socketError = (int) args.SocketError;
111111

112112
if (ownsSocket)
113113
{
@@ -134,7 +134,7 @@ private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSp
134134
throw new SshOperationTimeoutException(string.Format(CultureInfo.InvariantCulture,
135135
"Connection failed to establish within {0:F0} milliseconds.", connectTimeout.TotalMilliseconds));
136136
#else
137-
#error Connecting to a remote endpoint is not implemented.
137+
#error Connecting to a remote endpoint is not implemented.
138138
#endif
139139
}
140140

@@ -154,7 +154,7 @@ public static void ClearReadBuffer(Socket socket)
154154
public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size, TimeSpan timeout)
155155
{
156156
#if FEATURE_SOCKET_SYNC
157-
socket.ReceiveTimeout = (int)timeout.TotalMilliseconds;
157+
socket.ReceiveTimeout = (int) timeout.TotalMilliseconds;
158158

159159
try
160160
{
@@ -207,7 +207,7 @@ public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size
207207
receiveCompleted.Dispose();
208208
}
209209
#else
210-
#error Receiving data from a Socket is not implemented.
210+
#error Receiving data from a Socket is not implemented.
211211
#endif
212212
}
213213

@@ -269,7 +269,7 @@ public static void ReadContinuous(Socket socket, byte[] buffer, int offset, int
269269
if (readToken.Exception != null)
270270
throw readToken.Exception;
271271
#else
272-
#error Receiving data from a Socket is not implemented.
272+
#error Receiving data from a Socket is not implemented.
273273
#endif
274274
}
275275

@@ -300,7 +300,7 @@ public static int ReadByte(Socket socket, TimeSpan timeout)
300300
/// <exception cref="SocketException">The write failed.</exception>
301301
public static void SendByte(Socket socket, byte value)
302302
{
303-
var buffer = new[] { value };
303+
var buffer = new[] {value};
304304
Send(socket, buffer, 0, 1);
305305
}
306306

@@ -505,7 +505,7 @@ public static void Send(Socket socket, byte[] data, int offset, int size)
505505
sendCompleted.Dispose();
506506
}
507507
#else
508-
#error Sending data to a Socket is not implemented.
508+
#error Sending data to a Socket is not implemented.
509509
#endif
510510
}
511511

@@ -525,7 +525,7 @@ public static bool IsErrorResumable(SocketError socketError)
525525
#if FEATURE_SOCKET_EAP
526526
private static void ConnectCompleted(object sender, SocketAsyncEventArgs e)
527527
{
528-
var eventWaitHandle = (ManualResetEvent)e.UserToken;
528+
var eventWaitHandle = (ManualResetEvent) e.UserToken;
529529
if (eventWaitHandle != null)
530530
eventWaitHandle.Set();
531531
}

src/Renci.SshNet/ISftpClient.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -526,24 +526,6 @@ public interface ISftpClient
526526
/// </remarks>
527527
void DownloadFile(string path, Stream output, Action<ulong> downloadCallback = null);
528528

529-
#if FEATURE_TAP
530-
/// <summary>
531-
/// Asynchronously downloads remote file specified by the path into the stream.
532-
/// </summary>
533-
/// <param name="path">File to download.</param>
534-
/// <param name="output">Stream to write the file into.</param>
535-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
536-
/// <returns>A <see cref="Task"/> that represents the asynchronous download operation.</returns>
537-
/// <exception cref="ArgumentNullException"><paramref name="output" /> is <b>null</b>.</exception>
538-
/// <exception cref="ArgumentException"><paramref name="path" /> is <b>null</b> or contains only whitespace characters.</exception>
539-
/// <exception cref="SshConnectionException">Client is not connected.</exception>
540-
/// <exception cref="SftpPermissionDeniedException">Permission to perform the operation was denied by the remote host. <para>-or-</para> A SSH command was denied by the server.</exception>
541-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>///
542-
/// <exception cref="SshException">A SSH error where <see cref="Exception.Message" /> is the message from the remote host.</exception>
543-
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
544-
Task DownloadFileAsync(string path, Stream output, CancellationToken cancellationToken);
545-
#endif
546-
547529
/// <summary>
548530
/// Ends an asynchronous file downloading into the stream.
549531
/// </summary>
@@ -1024,27 +1006,6 @@ public interface ISftpClient
10241006
/// </remarks>
10251007
void UploadFile(Stream input, string path, bool canOverride, Action<ulong> uploadCallback = null);
10261008

1027-
#if FEATURE_TAP
1028-
/// <summary>
1029-
/// Asynchronously uploads stream into remote file.
1030-
/// </summary>
1031-
/// <param name="input">Data input stream.</param>
1032-
/// <param name="path">Remote file path.</param>
1033-
/// <param name="createMode">Specifies how the file should be created.</param>
1034-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
1035-
/// <returns>A <see cref="Task"/> that represents the asynchronous upload operation.</returns>
1036-
/// <exception cref="ArgumentNullException"><paramref name="input" /> is <b>null</b>.</exception>
1037-
/// <exception cref="ArgumentException"><paramref name="path" /> is <b>null</b> or contains only whitespace characters.</exception>
1038-
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1039-
/// <exception cref="SftpPermissionDeniedException">Permission to upload the file was denied by the remote host. <para>-or-</para> A SSH command was denied by the server.</exception>
1040-
/// <exception cref="SshException">A SSH error where <see cref="Exception.Message" /> is the message from the remote host.</exception>
1041-
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
1042-
/// <remarks>
1043-
/// Method calls made by this method to <paramref name="input" />, may under certain conditions result in exceptions thrown by the stream.
1044-
/// </remarks>
1045-
Task UploadFileAsync(Stream input, string path, UploadMode createMode, CancellationToken cancellationToken);
1046-
#endif
1047-
10481009
/// <summary>
10491010
/// Writes the specified byte array to the specified file, and closes the file.
10501011
/// </summary>

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
66
<AssemblyName>Renci.SshNet</AssemblyName>
77
<AssemblyOriginatorKeyFile>../Renci.SshNet.snk</AssemblyOriginatorKeyFile>
8-
<LangVersion>5</LangVersion>
8+
<LangVersion>6</LangVersion>
99
<SignAssembly>true</SignAssembly>
10-
<TargetFrameworks>net35;net40;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
10+
<TargetFrameworks>net35;net40;net472;netstandard1.3;netstandard2.0</TargetFrameworks>
1111
</PropertyGroup>
1212

1313
<!--
@@ -38,7 +38,7 @@
3838
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
3939
<DefineConstants>FEATURE_STRINGBUILDER_CLEAR;FEATURE_HASHALGORITHM_DISPOSE;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA</DefineConstants>
4040
</PropertyGroup>
41-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
41+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net472' ">
4242
<DefineConstants>FEATURE_STRINGBUILDER_CLEAR;FEATURE_HASHALGORITHM_DISPOSE;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA;FEATURE_TAP</DefineConstants>
4343
</PropertyGroup>
4444
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">

0 commit comments

Comments
 (0)