diff --git a/src/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs b/src/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
index a75d407d3..da7739694 100644
--- a/src/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
+++ b/src/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
@@ -5,9 +5,6 @@
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
-#if !FEATURE_SOCKET_DISPOSE
-using Renci.SshNet.Common;
-#endif // !FEATURE_SOCKET_DISPOSE
using Renci.SshNet.Channels;
using Renci.SshNet.Messages.Connection;
using Renci.SshNet.Tests.Common;
diff --git a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs
index 6954beb14..6ab52acef 100644
--- a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs
+++ b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs
@@ -2,9 +2,6 @@
using System.Diagnostics;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#if !FEATURE_THREAD_COUNTDOWNEVENT
-using CountdownEvent = Renci.SshNet.Common.CountdownEvent;
-#endif
namespace Renci.SshNet.Tests.Classes.Common
{
diff --git a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_NotSet.cs b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_NotSet.cs
index 3d5a5d17d..a2badf97e 100644
--- a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_NotSet.cs
+++ b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_NotSet.cs
@@ -1,10 +1,6 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#if !FEATURE_THREAD_COUNTDOWNEVENT
-using CountdownEvent = Renci.SshNet.Common.CountdownEvent;
-#else
using System.Threading;
-#endif
namespace Renci.SshNet.Tests.Classes.Common
{
diff --git a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_Set.cs b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_Set.cs
index 60f13c302..df5f5b979 100644
--- a/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_Set.cs
+++ b/src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest_Dispose_Set.cs
@@ -1,10 +1,6 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-#if !FEATURE_THREAD_COUNTDOWNEVENT
-using CountdownEvent = Renci.SshNet.Common.CountdownEvent;
-#else
using System.Threading;
-#endif
namespace Renci.SshNet.Tests.Classes.Common
{
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamAsyncTestBase.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamAsyncTestBase.cs
index b8b7b4ae9..110a20bed 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamAsyncTestBase.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamAsyncTestBase.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
@@ -66,4 +65,3 @@ protected byte[] GenerateRandom(uint length, Random random)
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileAccessInvalid.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileAccessInvalid.cs
index fab12dad6..4febea075 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileAccessInvalid.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileAccessInvalid.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -54,4 +53,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessRead.cs
index 0ffeaeb6c..14a2338b0 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -55,4 +54,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessReadWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessReadWrite.cs
index 2ed8cd14f..c58f33873 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessReadWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessReadWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -55,4 +54,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessWrite.cs
index 8d9bc960b..a95be4233 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeAppend_FileAccessWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -152,4 +151,3 @@ public void RequestFStatOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessRead.cs
index eb83af777..a697a3c53 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -55,4 +54,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessReadWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessReadWrite.cs
index 5c2318086..c1b271dd3 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessReadWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessReadWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessWrite.cs
index 7671fe300..b6c6487df 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreateNew_FileAccessWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessRead.cs
index 2c6d28a6e..460081fca 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -55,4 +54,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileDoesNotExist.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileDoesNotExist.cs
index 5fe519f17..9563b9fcd 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileDoesNotExist.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileDoesNotExist.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileExists.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileExists.cs
index a313afb96..e2d5d061c 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileExists.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessReadWrite_FileExists.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileDoesNotExist.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileDoesNotExist.cs
index c1d7fc960..aa29b7397 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileDoesNotExist.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileDoesNotExist.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -132,5 +131,4 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnceWithTruncateAndOnceWithCr
SftpSessionMock.Verify(p => p.RequestOpenAsync(_path, Flags.Write | Flags.CreateNewOrOpen | Flags.Truncate, _cancellationToken), Times.Once);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileExists.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileExists.cs
index 834299706..ed001ab2a 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileExists.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeCreate_FileAccessWrite_FileExists.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -132,5 +131,4 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
SftpSessionMock.Verify(p => p.RequestOpenAsync(_path, Flags.Write | Flags.CreateNewOrOpen | Flags.Truncate, _cancellationToken), Times.Once);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeInvalid.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeInvalid.cs
index 9cfc4a37f..075967ac2 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeInvalid.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeInvalid.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -54,4 +53,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessRead.cs
index f9360c40c..15a40915a 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -137,5 +136,4 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
SftpSessionMock.Verify(p => p.RequestOpenAsync(_path, Flags.Read | Flags.CreateNewOrOpen, _cancellationToken), Times.Once);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessReadWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessReadWrite.cs
index 7e5e4d867..c7cd5d4a4 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessReadWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessReadWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessWrite.cs
index edccf9b99..0b69f581e 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpenOrCreate_FileAccessWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessRead.cs
index 1d4f686fa..76387888f 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -139,4 +138,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessReadWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessReadWrite.cs
index 8ee641337..56589f668 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessReadWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessReadWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessWrite.cs
index 4be281731..db61a2a6e 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeOpen_FileAccessWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessRead.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessRead.cs
index 9883a5a76..9247274e8 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessRead.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessRead.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -56,4 +55,3 @@ public void CtorShouldHaveThrownArgumentException()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessReadWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessReadWrite.cs
index 2d0efd24f..ecde02148 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessReadWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessReadWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -133,4 +132,3 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessWrite.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessWrite.cs
index 5f61e1984..0c06eba6a 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessWrite.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_OpenAsync_FileModeTruncate_FileAccessWrite.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -132,5 +131,4 @@ public void RequestOpenOnSftpSessionShouldBeInvokedOnce()
SftpSessionMock.Verify(p => p.RequestOpenAsync(_path, Flags.Write | Flags.Truncate, _cancellationToken), Times.Once);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndEqualToBufferSize.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndEqualToBufferSize.cs
index 13f3e1255..d3b5983be 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndEqualToBufferSize.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndEqualToBufferSize.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -155,5 +154,4 @@ public async Task ReadShouldReturnAllRemaningBytesFromReadBufferAndReadAgainWhen
SftpSessionMock.Verify(p => p.RequestReadAsync(_handle, (ulong)(_serverData1Length + _serverData2Length), _readBufferSize, default));
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndLessThanBufferSize.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndLessThanBufferSize.cs
index 2da0a4385..29121639c 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndLessThanBufferSize.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadLessBytesFromServerThanCountAndLessThanBufferSize.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -149,4 +148,3 @@ public async Task SubsequentReadShouldReadAgainFromCurrentPositionFromServerAndN
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadMoreBytesFromServerThanCount.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadMoreBytesFromServerThanCount.cs
index 80895217e..d95ffd0a0 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadMoreBytesFromServerThanCount.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_ReadAsync_ReadMode_NoDataInReaderBufferAndReadMoreBytesFromServerThanCount.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
@@ -140,4 +139,3 @@ public async Task SubsequentReadShouldReturnAllRemaningBytesFromReadBufferAndRea
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_WriteAsync_SessionOpen_CountGreatherThanTwoTimesTheWriteBufferSize.cs b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_WriteAsync_SessionOpen_CountGreatherThanTwoTimesTheWriteBufferSize.cs
index dcbfedf63..a9f4587b0 100644
--- a/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_WriteAsync_SessionOpen_CountGreatherThanTwoTimesTheWriteBufferSize.cs
+++ b/src/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest_WriteAsync_SessionOpen_CountGreatherThanTwoTimesTheWriteBufferSize.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.Globalization;
using System.IO;
using System.Threading;
@@ -140,4 +139,3 @@ public async Task FlushShouldFlushBuffer()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs b/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs
index 75602ea2c..df7a8f0b6 100644
--- a/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs
+++ b/src/Renci.SshNet.Tests/Classes/SftpClientTest.ConnectAsync.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.Net.Sockets;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -44,5 +43,4 @@ public async Task ConnectAsync_ProxyHostNameInvalid_ShouldThrowSocketExceptionWi
}
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs b/src/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs
index 20e68e812..9d8464377 100644
--- a/src/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs
+++ b/src/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Tests.Properties;
using System;
using System.Threading.Tasks;
@@ -23,5 +22,4 @@ public async Task Test_Sftp_DeleteFileAsync_Null()
}
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Classes/SftpClientTest.RenameFileAsync.cs b/src/Renci.SshNet.Tests/Classes/SftpClientTest.RenameFileAsync.cs
index 38d651f97..a24ec0942 100644
--- a/src/Renci.SshNet.Tests/Classes/SftpClientTest.RenameFileAsync.cs
+++ b/src/Renci.SshNet.Tests/Classes/SftpClientTest.RenameFileAsync.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Tests.Properties;
using System;
using System.IO;
@@ -63,4 +62,3 @@ public async Task Test_Sftp_RenameFileAsync_Null()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs b/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
index 8fa81a301..78319f76f 100644
--- a/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
+++ b/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
@@ -3,9 +3,6 @@
using System.Net;
using System.Net.Sockets;
using System.Threading;
-#if !FEATURE_SOCKET_DISPOSE
-using Renci.SshNet.Common;
-#endif // !FEATURE_SOCKET_DISPOSE
namespace Renci.SshNet.Tests.Common
{
diff --git a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
index b577179e2..80c36aa70 100644
--- a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
+++ b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
@@ -7,7 +7,7 @@
- FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_TPL;FEATURE_TAP
+ FEATURE_TPL
diff --git a/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs b/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs
index ff9e50a52..2c7d38b0c 100644
--- a/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs
@@ -5,9 +5,7 @@ namespace Renci.SshNet.Abstractions
{
internal static class CryptoAbstraction
{
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
private static readonly System.Security.Cryptography.RandomNumberGenerator Randomizer = CreateRandomNumberGenerator();
-#endif
///
/// Generates a array of the specified length, and fills it with a
@@ -31,105 +29,38 @@ public static byte[] GenerateRandom(int length)
///
public static void GenerateRandom(byte[] data)
{
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
Randomizer.GetBytes(data);
-#else
- if(data == null)
- throw new ArgumentNullException("data");
-
- var buffer = Windows.Security.Cryptography.CryptographicBuffer.GenerateRandom((uint) data.Length);
- System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyTo(buffer, data);
-#endif
}
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
public static System.Security.Cryptography.RandomNumberGenerator CreateRandomNumberGenerator()
{
-#if FEATURE_RNG_CREATE
return System.Security.Cryptography.RandomNumberGenerator.Create();
-#elif FEATURE_RNG_CSP
- return new System.Security.Cryptography.RNGCryptoServiceProvider();
-#else
-#error Creation of RandomNumberGenerator is not implemented.
-#endif
}
-#endif // FEATURE_RNG_CREATE || FEATURE_RNG_CSP
-#if FEATURE_HASH_MD5
public static System.Security.Cryptography.MD5 CreateMD5()
{
return System.Security.Cryptography.MD5.Create();
}
-#else
- public static global::SshNet.Security.Cryptography.MD5 CreateMD5()
- {
- return new global::SshNet.Security.Cryptography.MD5();
- }
-#endif // FEATURE_HASH_MD5
-#if FEATURE_HASH_SHA1_CREATE || FEATURE_HASH_SHA1_MANAGED
public static System.Security.Cryptography.SHA1 CreateSHA1()
{
-#if FEATURE_HASH_SHA1_CREATE
return System.Security.Cryptography.SHA1.Create();
-#elif FEATURE_HASH_SHA1_MANAGED
- return new System.Security.Cryptography.SHA1Managed();
-#endif
}
-#else
- public static global::SshNet.Security.Cryptography.SHA1 CreateSHA1()
- {
- return new global::SshNet.Security.Cryptography.SHA1();
- }
-#endif
-#if FEATURE_HASH_SHA256_CREATE || FEATURE_HASH_SHA256_MANAGED
public static System.Security.Cryptography.SHA256 CreateSHA256()
{
-#if FEATURE_HASH_SHA256_CREATE
return System.Security.Cryptography.SHA256.Create();
-#elif FEATURE_HASH_SHA256_MANAGED
- return new System.Security.Cryptography.SHA256Managed();
-#endif
}
-#else
- public static global::SshNet.Security.Cryptography.SHA256 CreateSHA256()
- {
- return new global::SshNet.Security.Cryptography.SHA256();
- }
-#endif
-#if FEATURE_HASH_SHA384_CREATE || FEATURE_HASH_SHA384_MANAGED
public static System.Security.Cryptography.SHA384 CreateSHA384()
{
-#if FEATURE_HASH_SHA384_CREATE
return System.Security.Cryptography.SHA384.Create();
-#elif FEATURE_HASH_SHA384_MANAGED
- return new System.Security.Cryptography.SHA384Managed();
-#endif
- }
-#else
- public static global::SshNet.Security.Cryptography.SHA384 CreateSHA384()
- {
- return new global::SshNet.Security.Cryptography.SHA384();
}
-#endif
-#if FEATURE_HASH_SHA512_CREATE || FEATURE_HASH_SHA512_MANAGED
public static System.Security.Cryptography.SHA512 CreateSHA512()
{
-#if FEATURE_HASH_SHA512_CREATE
return System.Security.Cryptography.SHA512.Create();
-#elif FEATURE_HASH_SHA512_MANAGED
- return new System.Security.Cryptography.SHA512Managed();
-#endif
}
-#else
- public static global::SshNet.Security.Cryptography.SHA512 CreateSHA512()
- {
- return new global::SshNet.Security.Cryptography.SHA512();
- }
-#endif
#if FEATURE_HASH_RIPEMD160_CREATE || FEATURE_HASH_RIPEMD160_MANAGED
public static System.Security.Cryptography.RIPEMD160 CreateRIPEMD160()
@@ -147,7 +78,6 @@ public static System.Security.Cryptography.RIPEMD160 CreateRIPEMD160()
}
#endif // FEATURE_HASH_RIPEMD160
-#if FEATURE_HMAC_MD5
public static System.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key)
{
return new System.Security.Cryptography.HMACMD5(key);
@@ -157,19 +87,7 @@ public static HMACMD5 CreateHMACMD5(byte[] key, int hashSize)
{
return new HMACMD5(key, hashSize);
}
-#else
- public static global::SshNet.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key)
- {
- return new global::SshNet.Security.Cryptography.HMACMD5(key);
- }
-
- public static global::SshNet.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key, int hashSize)
- {
- return new global::SshNet.Security.Cryptography.HMACMD5(key, hashSize);
- }
-#endif // FEATURE_HMAC_MD5
-#if FEATURE_HMAC_SHA1
public static System.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key)
{
return new System.Security.Cryptography.HMACSHA1(key);
@@ -179,19 +97,7 @@ public static HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize)
{
return new HMACSHA1(key, hashSize);
}
-#else
- public static global::SshNet.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA1(key);
- }
- public static global::SshNet.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA1(key, hashSize);
- }
-#endif // FEATURE_HMAC_SHA1
-
-#if FEATURE_HMAC_SHA256
public static System.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key)
{
return new System.Security.Cryptography.HMACSHA256(key);
@@ -201,19 +107,7 @@ public static HMACSHA256 CreateHMACSHA256(byte[] key, int hashSize)
{
return new HMACSHA256(key, hashSize);
}
-#else
- public static global::SshNet.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA256(key);
- }
- public static global::SshNet.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key, int hashSize)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA256(key, hashSize);
- }
-#endif // FEATURE_HMAC_SHA256
-
-#if FEATURE_HMAC_SHA384
public static System.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key)
{
return new System.Security.Cryptography.HMACSHA384(key);
@@ -223,19 +117,7 @@ public static HMACSHA384 CreateHMACSHA384(byte[] key, int hashSize)
{
return new HMACSHA384(key, hashSize);
}
-#else
- public static global::SshNet.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA384(key);
- }
-
- public static global::SshNet.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key, int hashSize)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA384(key, hashSize);
- }
-#endif // FEATURE_HMAC_SHA384
-#if FEATURE_HMAC_SHA512
public static System.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key)
{
return new System.Security.Cryptography.HMACSHA512(key);
@@ -245,17 +127,6 @@ public static HMACSHA512 CreateHMACSHA512(byte[] key, int hashSize)
{
return new HMACSHA512(key, hashSize);
}
-#else
- public static global::SshNet.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA512(key);
- }
-
- public static global::SshNet.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key, int hashSize)
- {
- return new global::SshNet.Security.Cryptography.HMACSHA512(key, hashSize);
- }
-#endif // FEATURE_HMAC_SHA512
#if FEATURE_HMAC_RIPEMD160
public static System.Security.Cryptography.HMACRIPEMD160 CreateHMACRIPEMD160(byte[] key)
diff --git a/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs b/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
index 6fc1308ee..16ee1c0ab 100644
--- a/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
@@ -1,14 +1,10 @@
using System.Diagnostics;
-#if FEATURE_DIAGNOSTICS_TRACESOURCE
using System.Threading;
-#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
namespace Renci.SshNet.Abstractions
{
internal static class DiagnosticAbstraction
{
-#if FEATURE_DIAGNOSTICS_TRACESOURCE
-
private static readonly SourceSwitch SourceSwitch = new SourceSwitch("SshNetSwitch");
public static bool IsEnabled(TraceEventType traceEventType)
@@ -22,14 +18,11 @@ public static bool IsEnabled(TraceEventType traceEventType)
#else
new TraceSource("SshNet.Logging");
#endif // DEBUG
-#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
[Conditional("DEBUG")]
public static void Log(string text)
{
-#if FEATURE_DIAGNOSTICS_TRACESOURCE
Loggging.TraceEvent(TraceEventType.Verbose, Thread.CurrentThread.ManagedThreadId, text);
-#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
}
}
}
diff --git a/src/Renci.SshNet/Abstractions/DnsAbstraction.cs b/src/Renci.SshNet/Abstractions/DnsAbstraction.cs
index a2ac9d58f..707521eae 100644
--- a/src/Renci.SshNet/Abstractions/DnsAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/DnsAbstraction.cs
@@ -1,10 +1,7 @@
using System;
using System.Net;
using System.Net.Sockets;
-
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
#if FEATURE_DNS_SYNC
#elif FEATURE_DNS_APM
@@ -92,7 +89,6 @@ public static IPAddress[] GetHostAddresses(string hostNameOrAddress)
#endif
}
-#if FEATURE_TAP
///
/// Returns the Internet Protocol (IP) addresses for the specified host.
///
@@ -107,7 +103,5 @@ public static Task GetHostAddressesAsync(string hostNameOrAddress)
{
return Dns.GetHostAddressesAsync(hostNameOrAddress);
}
-#endif
-
}
}
diff --git a/src/Renci.SshNet/Abstractions/ReflectionAbstraction.cs b/src/Renci.SshNet/Abstractions/ReflectionAbstraction.cs
index 0c7abf5c6..1140c9a60 100644
--- a/src/Renci.SshNet/Abstractions/ReflectionAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/ReflectionAbstraction.cs
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
-#if FEATURE_REFLECTION_TYPEINFO
-using System.Reflection;
-#else
using System.Linq;
-#endif // FEATURE_REFLECTION_TYPEINFO
namespace Renci.SshNet.Abstractions
{
@@ -13,12 +9,8 @@ internal static class ReflectionAbstraction
public static IEnumerable GetCustomAttributes(this Type type, bool inherit)
where T:Attribute
{
-#if FEATURE_REFLECTION_TYPEINFO
- return type.GetTypeInfo().GetCustomAttributes(inherit);
-#else
var attributes = type.GetCustomAttributes(typeof(T), inherit);
return attributes.Cast();
-#endif
}
}
}
diff --git a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
index e358767a1..e7740d574 100644
--- a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs
@@ -3,9 +3,8 @@
using System.Net;
using System.Net.Sockets;
using System.Threading;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
+
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Transport;
@@ -17,11 +16,7 @@ public static bool CanRead(Socket socket)
{
if (socket.Connected)
{
-#if FEATURE_SOCKET_POLL
return socket.Poll(-1, SelectMode.SelectRead) && socket.Available > 0;
-#else
- return true;
-#endif // FEATURE_SOCKET_POLL
}
return false;
@@ -40,11 +35,7 @@ public static bool CanWrite(Socket socket)
{
if (socket != null && socket.Connected)
{
-#if FEATURE_SOCKET_POLL
return socket.Poll(-1, SelectMode.SelectWrite);
-#else
- return true;
-#endif // FEATURE_SOCKET_POLL
}
return false;
@@ -62,12 +53,10 @@ public static void Connect(Socket socket, IPEndPoint remoteEndpoint, TimeSpan co
ConnectCore(socket, remoteEndpoint, connectTimeout, false);
}
-#if FEATURE_TAP
public static async Task ConnectAsync(Socket socket, IPEndPoint remoteEndpoint, CancellationToken cancellationToken)
{
await socket.ConnectAsync(remoteEndpoint, cancellationToken).ConfigureAwait(false);
}
-#endif
private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSpan connectTimeout, bool ownsSocket)
{
@@ -153,7 +142,6 @@ public static void ClearReadBuffer(Socket socket)
public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size, TimeSpan timeout)
{
-#if FEATURE_SOCKET_SYNC
socket.ReceiveTimeout = (int) timeout.TotalMilliseconds;
try
@@ -167,53 +155,10 @@ public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size
"Socket read operation has timed out after {0:F0} milliseconds.", timeout.TotalMilliseconds));
throw;
}
-#elif FEATURE_SOCKET_EAP
- var receiveCompleted = new ManualResetEvent(false);
- var sendReceiveToken = new PartialSendReceiveToken(socket, receiveCompleted);
- var args = new SocketAsyncEventArgs
- {
- RemoteEndPoint = socket.RemoteEndPoint,
- UserToken = sendReceiveToken
- };
- args.Completed += ReceiveCompleted;
- args.SetBuffer(buffer, offset, size);
-
- try
- {
- if (socket.ReceiveAsync(args))
- {
- if (!receiveCompleted.WaitOne(timeout))
- throw new SshOperationTimeoutException(
- string.Format(
- CultureInfo.InvariantCulture,
- "Socket read operation has timed out after {0:F0} milliseconds.",
- timeout.TotalMilliseconds));
- }
- else
- {
- sendReceiveToken.Process(args);
- }
-
- if (args.SocketError != SocketError.Success)
- throw new SocketException((int) args.SocketError);
-
- return args.BytesTransferred;
- }
- finally
- {
- // initialize token to avoid the waithandle getting used after it's disposed
- args.UserToken = null;
- args.Dispose();
- receiveCompleted.Dispose();
- }
-#else
- #error Receiving data from a Socket is not implemented.
-#endif
}
public static void ReadContinuous(Socket socket, byte[] buffer, int offset, int size, Action processReceivedBytesAction)
{
-#if FEATURE_SOCKET_SYNC
// do not time-out receive
socket.ReceiveTimeout = 0;
@@ -247,30 +192,6 @@ public static void ReadContinuous(Socket socket, byte[] buffer, int offset, int
}
}
}
-#elif FEATURE_SOCKET_EAP
- var completionWaitHandle = new ManualResetEvent(false);
- var readToken = new ContinuousReceiveToken(socket, processReceivedBytesAction, completionWaitHandle);
- var args = new SocketAsyncEventArgs
- {
- RemoteEndPoint = socket.RemoteEndPoint,
- UserToken = readToken
- };
- args.Completed += ReceiveCompleted;
- args.SetBuffer(buffer, offset, size);
-
- if (!socket.ReceiveAsync(args))
- {
- ReceiveCompleted(null, args);
- }
-
- completionWaitHandle.WaitOne();
- completionWaitHandle.Dispose();
-
- if (readToken.Exception != null)
- throw readToken.Exception;
-#else
- #error Receiving data from a Socket is not implemented.
-#endif
}
///
@@ -327,12 +248,10 @@ public static byte[] Read(Socket socket, int size, TimeSpan timeout)
return buffer;
}
-#if FEATURE_TAP
public static Task ReadAsync(Socket socket, byte[] buffer, int offset, int length, CancellationToken cancellationToken)
{
return socket.ReceiveAsync(buffer, offset, length, cancellationToken);
}
-#endif
///
/// Receives data from a bound into a receive buffer.
@@ -358,7 +277,6 @@ public static Task ReadAsync(Socket socket, byte[] buffer, int offset, int
///
public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeSpan readTimeout)
{
-#if FEATURE_SOCKET_SYNC
var totalBytesRead = 0;
var totalBytesToRead = size;
@@ -386,52 +304,12 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS
throw new SshOperationTimeoutException(string.Format(CultureInfo.InvariantCulture,
"Socket read operation has timed out after {0:F0} milliseconds.", readTimeout.TotalMilliseconds));
- throw;
+ throw;
}
}
while (totalBytesRead < totalBytesToRead);
return totalBytesRead;
-#elif FEATURE_SOCKET_EAP
- var receiveCompleted = new ManualResetEvent(false);
- var sendReceiveToken = new BlockingSendReceiveToken(socket, buffer, offset, size, receiveCompleted);
-
- var args = new SocketAsyncEventArgs
- {
- UserToken = sendReceiveToken,
- RemoteEndPoint = socket.RemoteEndPoint
- };
- args.Completed += ReceiveCompleted;
- args.SetBuffer(buffer, offset, size);
-
- try
- {
- if (socket.ReceiveAsync(args))
- {
- if (!receiveCompleted.WaitOne(readTimeout))
- throw new SshOperationTimeoutException(string.Format(CultureInfo.InvariantCulture,
- "Socket read operation has timed out after {0:F0} milliseconds.", readTimeout.TotalMilliseconds));
- }
- else
- {
- sendReceiveToken.Process(args);
- }
-
- if (args.SocketError != SocketError.Success)
- throw new SocketException((int) args.SocketError);
-
- return sendReceiveToken.TotalBytesTransferred;
- }
- finally
- {
- // initialize token to avoid the waithandle getting used after it's disposed
- args.UserToken = null;
- args.Dispose();
- receiveCompleted.Dispose();
- }
-#else
-#error Receiving data from a Socket is not implemented.
-#endif
}
public static void Send(Socket socket, byte[] data)
@@ -441,7 +319,6 @@ public static void Send(Socket socket, byte[] data)
public static void Send(Socket socket, byte[] data, int offset, int size)
{
-#if FEATURE_SOCKET_SYNC
var totalBytesSent = 0; // how many bytes are already sent
var totalBytesToSend = size;
@@ -467,46 +344,6 @@ public static void Send(Socket socket, byte[] data, int offset, int size)
throw; // any serious error occurr
}
} while (totalBytesSent < totalBytesToSend);
-#elif FEATURE_SOCKET_EAP
- var sendCompleted = new ManualResetEvent(false);
- var sendReceiveToken = new BlockingSendReceiveToken(socket, data, offset, size, sendCompleted);
- var socketAsyncSendArgs = new SocketAsyncEventArgs
- {
- RemoteEndPoint = socket.RemoteEndPoint,
- UserToken = sendReceiveToken
- };
- socketAsyncSendArgs.SetBuffer(data, offset, size);
- socketAsyncSendArgs.Completed += SendCompleted;
-
- try
- {
- if (socket.SendAsync(socketAsyncSendArgs))
- {
- if (!sendCompleted.WaitOne())
- throw new SocketException((int) SocketError.TimedOut);
- }
- else
- {
- sendReceiveToken.Process(socketAsyncSendArgs);
- }
-
- if (socketAsyncSendArgs.SocketError != SocketError.Success)
- throw new SocketException((int) socketAsyncSendArgs.SocketError);
-
- if (sendReceiveToken.TotalBytesTransferred == 0)
- throw new SshConnectionException("An established connection was aborted by the server.",
- DisconnectReason.ConnectionLost);
- }
- finally
- {
- // initialize token to avoid the completion waithandle getting used after it's disposed
- socketAsyncSendArgs.UserToken = null;
- socketAsyncSendArgs.Dispose();
- sendCompleted.Dispose();
- }
-#else
- #error Sending data to a Socket is not implemented.
-#endif
}
public static bool IsErrorResumable(SocketError socketError)
@@ -531,199 +368,5 @@ private static void ConnectCompleted(object sender, SocketAsyncEventArgs e)
}
#endif // FEATURE_SOCKET_EAP
-#if FEATURE_SOCKET_EAP && !FEATURE_SOCKET_SYNC
- private static void ReceiveCompleted(object sender, SocketAsyncEventArgs e)
- {
- var sendReceiveToken = (Token) e.UserToken;
- if (sendReceiveToken != null)
- sendReceiveToken.Process(e);
- }
-
- private static void SendCompleted(object sender, SocketAsyncEventArgs e)
- {
- var sendReceiveToken = (Token) e.UserToken;
- if (sendReceiveToken != null)
- sendReceiveToken.Process(e);
- }
-
- private interface Token
- {
- void Process(SocketAsyncEventArgs args);
- }
-
- private class BlockingSendReceiveToken : Token
- {
- public BlockingSendReceiveToken(Socket socket, byte[] buffer, int offset, int size, EventWaitHandle completionWaitHandle)
- {
- _socket = socket;
- _buffer = buffer;
- _offset = offset;
- _bytesToTransfer = size;
- _completionWaitHandle = completionWaitHandle;
- }
-
- public void Process(SocketAsyncEventArgs args)
- {
- if (args.SocketError == SocketError.Success)
- {
- TotalBytesTransferred += args.BytesTransferred;
-
- if (TotalBytesTransferred == _bytesToTransfer)
- {
- // finished transferring specified bytes
- _completionWaitHandle.Set();
- return;
- }
-
- if (args.BytesTransferred == 0)
- {
- // remote server closed the connection
- _completionWaitHandle.Set();
- return;
- }
-
- _offset += args.BytesTransferred;
- args.SetBuffer(_buffer, _offset, _bytesToTransfer - TotalBytesTransferred);
- ResumeOperation(args);
- return;
- }
-
- if (IsErrorResumable(args.SocketError))
- {
- ThreadAbstraction.Sleep(30);
- ResumeOperation(args);
- return;
- }
-
- // we're dealing with a (fatal) error
- _completionWaitHandle.Set();
- }
-
- private void ResumeOperation(SocketAsyncEventArgs args)
- {
- switch (args.LastOperation)
- {
- case SocketAsyncOperation.Receive:
- _socket.ReceiveAsync(args);
- break;
- case SocketAsyncOperation.Send:
- _socket.SendAsync(args);
- break;
- }
- }
-
- private readonly int _bytesToTransfer;
- public int TotalBytesTransferred { get; private set; }
- private readonly EventWaitHandle _completionWaitHandle;
- private readonly Socket _socket;
- private readonly byte[] _buffer;
- private int _offset;
- }
-
- private class PartialSendReceiveToken : Token
- {
- public PartialSendReceiveToken(Socket socket, EventWaitHandle completionWaitHandle)
- {
- _socket = socket;
- _completionWaitHandle = completionWaitHandle;
- }
-
- public void Process(SocketAsyncEventArgs args)
- {
- if (args.SocketError == SocketError.Success)
- {
- _completionWaitHandle.Set();
- return;
- }
-
- if (IsErrorResumable(args.SocketError))
- {
- ThreadAbstraction.Sleep(30);
- ResumeOperation(args);
- return;
- }
-
- // we're dealing with a (fatal) error
- _completionWaitHandle.Set();
- }
-
- private void ResumeOperation(SocketAsyncEventArgs args)
- {
- switch (args.LastOperation)
- {
- case SocketAsyncOperation.Receive:
- _socket.ReceiveAsync(args);
- break;
- case SocketAsyncOperation.Send:
- _socket.SendAsync(args);
- break;
- }
- }
-
- private readonly EventWaitHandle _completionWaitHandle;
- private readonly Socket _socket;
- }
-
- private class ContinuousReceiveToken : Token
- {
- public ContinuousReceiveToken(Socket socket, Action processReceivedBytesAction, EventWaitHandle completionWaitHandle)
- {
- _socket = socket;
- _processReceivedBytesAction = processReceivedBytesAction;
- _completionWaitHandle = completionWaitHandle;
- }
-
- public Exception Exception { get; private set; }
-
- public void Process(SocketAsyncEventArgs args)
- {
- if (args.SocketError == SocketError.Success)
- {
- if (args.BytesTransferred == 0)
- {
- // remote socket was closed
- _completionWaitHandle.Set();
- return;
- }
-
- _processReceivedBytesAction(args.Buffer, args.Offset, args.BytesTransferred);
- ResumeOperation(args);
- return;
- }
-
- if (IsErrorResumable(args.SocketError))
- {
- ThreadAbstraction.Sleep(30);
- ResumeOperation(args);
- return;
- }
-
- if (args.SocketError != SocketError.OperationAborted)
- {
- Exception = new SocketException((int) args.SocketError);
- }
-
- // we're dealing with a (fatal) error
- _completionWaitHandle.Set();
- }
-
- private void ResumeOperation(SocketAsyncEventArgs args)
- {
- switch (args.LastOperation)
- {
- case SocketAsyncOperation.Receive:
- _socket.ReceiveAsync(args);
- break;
- case SocketAsyncOperation.Send:
- _socket.SendAsync(args);
- break;
- }
- }
-
- private readonly EventWaitHandle _completionWaitHandle;
- private readonly Socket _socket;
- private readonly Action _processReceivedBytesAction;
- }
-#endif // FEATURE_SOCKET_EAP && !FEATURE_SOCKET_SYNC
}
}
diff --git a/src/Renci.SshNet/Abstractions/SocketExtensions.cs b/src/Renci.SshNet/Abstractions/SocketExtensions.cs
index d763e1a34..7d3c30f93 100644
--- a/src/Renci.SshNet/Abstractions/SocketExtensions.cs
+++ b/src/Renci.SshNet/Abstractions/SocketExtensions.cs
@@ -1,5 +1,4 @@
-#if FEATURE_TAP
-using System;
+using System;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
@@ -116,4 +115,3 @@ public static async Task ReceiveAsync(this Socket socket, byte[] buffer, in
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs b/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs
index 8c344404b..35824ee10 100644
--- a/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/ThreadAbstraction.cs
@@ -10,13 +10,7 @@ internal static class ThreadAbstraction
/// The number of milliseconds for which the thread is suspended.
public static void Sleep(int millisecondsTimeout)
{
-#if FEATURE_THREAD_SLEEP
System.Threading.Thread.Sleep(millisecondsTimeout);
-#elif FEATURE_THREAD_TAP
- System.Threading.Tasks.Task.Delay(millisecondsTimeout).GetAwaiter().GetResult();
-#else
- #error Suspend of the current thread is not implemented.
-#endif
}
public static void ExecuteThreadLongRunning(Action action)
@@ -24,15 +18,8 @@ public static void ExecuteThreadLongRunning(Action action)
if (action == null)
throw new ArgumentNullException("action");
-#if FEATURE_THREAD_TAP
var taskCreationOptions = System.Threading.Tasks.TaskCreationOptions.LongRunning;
System.Threading.Tasks.Task.Factory.StartNew(action, taskCreationOptions);
-#else
- new System.Threading.Thread(() => action())
- {
- IsBackground = true
- }.Start();
-#endif
}
///
@@ -41,16 +28,10 @@ public static void ExecuteThreadLongRunning(Action action)
/// The action to execute.
public static void ExecuteThread(Action action)
{
-#if FEATURE_THREAD_THREADPOOL
if (action == null)
throw new ArgumentNullException("action");
System.Threading.ThreadPool.QueueUserWorkItem(o => action());
-#elif FEATURE_THREAD_TAP
- System.Threading.Tasks.Task.Run(action);
-#else
- #error Execution of action in a separate thread is not implemented.
-#endif
}
}
}
diff --git a/src/Renci.SshNet/BaseClient.cs b/src/Renci.SshNet/BaseClient.cs
index 754396108..fdc4e3a39 100644
--- a/src/Renci.SshNet/BaseClient.cs
+++ b/src/Renci.SshNet/BaseClient.cs
@@ -1,9 +1,8 @@
using System;
using System.Net.Sockets;
using System.Threading;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
+
using Renci.SshNet.Abstractions;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Transport;
@@ -242,7 +241,6 @@ public void Connect()
StartKeepAliveTimer();
}
-#if FEATURE_TAP
///
/// Asynchronously connects client to the server.
///
@@ -297,7 +295,6 @@ public async Task ConnectAsync(CancellationToken cancellationToken)
}
StartKeepAliveTimer();
}
-#endif
///
/// Disconnects client from the server.
@@ -533,7 +530,6 @@ private ISession CreateAndConnectSession()
}
}
-#if FEATURE_TAP
private async Task CreateAndConnectSessionAsync(CancellationToken cancellationToken)
{
var session = _serviceFactory.CreateSession(ConnectionInfo, _serviceFactory.CreateSocketFactory());
@@ -551,7 +547,6 @@ private async Task CreateAndConnectSessionAsync(CancellationToken canc
throw;
}
}
-#endif
private void DisposeSession(ISession session)
{
diff --git a/src/Renci.SshNet/Common/ASCIIEncoding.cs b/src/Renci.SshNet/Common/ASCIIEncoding.cs
deleted file mode 100644
index f41c49de8..000000000
--- a/src/Renci.SshNet/Common/ASCIIEncoding.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-#if !FEATURE_ENCODING_ASCII
-
-using System;
-using System.Text;
-
-namespace Renci.SshNet.Common
-{
- ///
- /// Implementation of ASCII Encoding
- ///
- public class ASCIIEncoding : Encoding
- {
- private readonly char _fallbackChar;
-
- private static readonly char[] ByteToChar;
-
- static ASCIIEncoding()
- {
- if (ByteToChar == null)
- {
- ByteToChar = new char[128];
- var ch = '\0';
- for (byte i = 0; i < 128; i++)
- {
- ByteToChar[i] = ch++;
- }
- }
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ASCIIEncoding()
- {
- _fallbackChar = '?';
- }
-
- ///
- /// Calculates the number of bytes produced by encoding a set of characters from the specified character array.
- ///
- /// The character array containing the set of characters to encode.
- /// The index of the first character to encode.
- /// The number of characters to encode.
- ///
- /// The number of bytes produced by encoding the specified characters.
- ///
- /// is null.
- /// or is less than zero.-or- and do not denote a valid range in .
- public override int GetByteCount(char[] chars, int index, int count)
- {
- return count;
- }
-
- ///
- /// Encodes a set of characters from the specified character array into the specified byte array.
- ///
- /// The character array containing the set of characters to encode.
- /// The index of the first character to encode.
- /// The number of characters to encode.
- /// The byte array to contain the resulting sequence of bytes.
- /// The index at which to start writing the resulting sequence of bytes.
- ///
- /// The actual number of bytes written into .
- ///
- /// is null.-or- is null.
- /// or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in .
- /// does not have enough capacity from to the end of the array to accommodate the resulting bytes.
- public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
- {
- for (var i = 0; i < charCount && i < chars.Length; i++)
- {
- var b = (byte)chars[i + charIndex];
-
- if (b > 127)
- b = (byte) _fallbackChar;
-
- bytes[i + byteIndex] = b;
- }
- return charCount;
- }
-
- ///
- /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
- ///
- /// The byte array containing the sequence of bytes to decode.
- /// The index of the first byte to decode.
- /// The number of bytes to decode.
- ///
- /// The number of characters produced by decoding the specified sequence of bytes.
- ///
- /// is null.
- /// or is less than zero.-or- and do not denote a valid range in .
- public override int GetCharCount(byte[] bytes, int index, int count)
- {
- return count;
- }
-
- ///
- /// Decodes a sequence of bytes from the specified byte array into the specified character array.
- ///
- /// The byte array containing the sequence of bytes to decode.
- /// The index of the first byte to decode.
- /// The number of bytes to decode.
- /// The character array to contain the resulting set of characters.
- /// The index at which to start writing the resulting set of characters.
- ///
- /// The actual number of characters written into .
- ///
- /// is null.-or- is null.
- /// or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in .
- /// does not have enough capacity from to the end of the array to accommodate the resulting characters.
- public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
- {
- for (var i = 0; i < byteCount; i++)
- {
- var b = bytes[i + byteIndex];
- char ch;
-
- if (b > 127)
- {
- ch = _fallbackChar;
- }
- else
- {
- ch = ByteToChar[b];
- }
-
- chars[i + charIndex] = ch;
- }
- return byteCount;
- }
-
- ///
- /// Calculates the maximum number of bytes produced by encoding the specified number of characters.
- ///
- /// The number of characters to encode.
- ///
- /// The maximum number of bytes produced by encoding the specified number of characters.
- ///
- /// is less than zero.
- public override int GetMaxByteCount(int charCount)
- {
- if (charCount < 0)
- throw new ArgumentOutOfRangeException("charCount", "Non-negative number required.");
-
- return charCount + 1;
- }
-
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
- /// The number of bytes to decode.
- ///
- /// The maximum number of characters produced by decoding the specified number of bytes.
- ///
- /// is less than zero.
- public override int GetMaxCharCount(int byteCount)
- {
- if (byteCount < 0)
- throw new ArgumentOutOfRangeException("byteCount", "Non-negative number required.");
-
- return byteCount;
- }
- }
-}
-
-#endif // !FEATURE_ENCODING_ASCII
\ No newline at end of file
diff --git a/src/Renci.SshNet/Common/CountdownEvent.cs b/src/Renci.SshNet/Common/CountdownEvent.cs
deleted file mode 100644
index 7387a786f..000000000
--- a/src/Renci.SshNet/Common/CountdownEvent.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-#if !FEATURE_THREAD_COUNTDOWNEVENT
-
-using System;
-using System.Threading;
-
-namespace Renci.SshNet.Common
-{
- ///
- /// Represents a synchronization primitive that is signaled when its count reaches zero.
- ///
- internal class CountdownEvent : IDisposable
- {
- private int _count;
- private ManualResetEvent _event;
- private bool _disposed;
-
- ///
- /// Initializes a new instance of class with the specified count.
- ///
- /// The number of signals initially required to set the .
- /// is less than zero.
- ///
- /// If is zero, the event is created in a signaled state.
- ///
- public CountdownEvent(int initialCount)
- {
- if (initialCount < 0)
- {
- throw new ArgumentOutOfRangeException("initialCount");
- }
-
- _count = initialCount;
-
- var initialState = _count == 0;
- _event = new ManualResetEvent(initialState);
- }
-
- ///
- /// Gets the number of remaining signals required to set the event.
- ///
- ///
- /// The number of remaining signals required to set the event.
- ///
- public int CurrentCount
- {
- get { return _count; }
- }
-
- ///
- /// Indicates whether the 's current count has reached zero.
- ///
- ///
- /// true if the current count is zero; otherwise, false.
- ///
- public bool IsSet
- {
- get { return _count == 0; }
- }
-
- ///
- /// Gets a that is used to wait for the event to be set.
- ///
- ///
- /// A that is used to wait for the event to be set.
- ///
- /// The current instance has already been disposed.
- public WaitHandle WaitHandle
- {
- get
- {
- EnsureNotDisposed();
-
- return _event;
- }
- }
-
-
- ///
- /// Registers a signal with the , decrementing the value of .
- ///
- ///
- /// true if the signal caused the count to reach zero and the event was set; otherwise, false.
- ///
- /// The current instance has already been disposed.
- /// The current instance is already set.
- public bool Signal()
- {
- EnsureNotDisposed();
-
- if (_count <= 0)
- throw new InvalidOperationException("Invalid attempt made to decrement the event's count below zero.");
-
- var newCount = Interlocked.Decrement(ref _count);
- if (newCount == 0)
- {
- _event.Set();
- return true;
- }
-
- return false;
- }
-
- ///
- /// Increments the 's current count by one.
- ///
- /// The current instance has already been disposed.
- /// The current instance is already set.
- /// is equal to or greather than .
- public void AddCount()
- {
- EnsureNotDisposed();
-
- if (_count == int.MaxValue)
- throw new InvalidOperationException("TODO");
-
- Interlocked.Increment(ref _count);
- }
-
- ///
- /// Blocks the current thread until the is set, using a
- /// to measure the timeout.
- ///
- /// A that represents the number of milliseconds to wait, or a that represents -1 milliseconds to wait indefinitely.
- ///
- /// true if the was set; otherwise, false.
- ///
- /// The current instance has already been disposed.
- public bool Wait(TimeSpan timeout)
- {
- EnsureNotDisposed();
-
- return _event.WaitOne(timeout);
- }
-
- ///
- /// Releases all resources used by the current instance of the class.
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases the unmanaged resources used by the , and optionally releases the managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- var theEvent = _event;
- if (theEvent != null)
- {
- _event = null;
- theEvent.Dispose();
- }
-
- _disposed = true;
- }
- }
-
- private void EnsureNotDisposed()
- {
- if (_disposed)
- throw new ObjectDisposedException(GetType().Name);
- }
- }
-}
-
-#endif // FEATURE_THREAD_COUNTDOWNEVENT
\ No newline at end of file
diff --git a/src/Renci.SshNet/Common/Extensions.cs b/src/Renci.SshNet/Common/Extensions.cs
index 17d72d7fb..3a5311f07 100644
--- a/src/Renci.SshNet/Common/Extensions.cs
+++ b/src/Renci.SshNet/Common/Extensions.cs
@@ -5,9 +5,6 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
-#if !FEATURE_WAITHANDLE_DISPOSE
-using System.Threading;
-#endif // !FEATURE_WAITHANDLE_DISPOSE
using Renci.SshNet.Abstractions;
using Renci.SshNet.Messages;
@@ -305,62 +302,5 @@ internal static bool IsConnected(this Socket socket)
return false;
return socket.Connected;
}
-
-#if !FEATURE_SOCKET_DISPOSE
- ///
- /// Disposes the specified socket.
- ///
- /// The socket.
- [DebuggerNonUserCode]
- internal static void Dispose(this Socket socket)
- {
- if (socket == null)
- throw new NullReferenceException();
-
- socket.Close();
- }
-#endif // !FEATURE_SOCKET_DISPOSE
-
-#if !FEATURE_WAITHANDLE_DISPOSE
- ///
- /// Disposes the specified handle.
- ///
- /// The handle.
- [DebuggerNonUserCode]
- internal static void Dispose(this WaitHandle handle)
- {
- if (handle == null)
- throw new NullReferenceException();
-
- handle.Close();
- }
-#endif // !FEATURE_WAITHANDLE_DISPOSE
-
-#if !FEATURE_HASHALGORITHM_DISPOSE
- ///
- /// Disposes the specified algorithm.
- ///
- /// The algorithm.
- [DebuggerNonUserCode]
- internal static void Dispose(this System.Security.Cryptography.HashAlgorithm algorithm)
- {
- if (algorithm == null)
- throw new NullReferenceException();
-
- algorithm.Clear();
- }
-#endif // FEATURE_HASHALGORITHM_DISPOSE
-
-#if !FEATURE_STRINGBUILDER_CLEAR
- ///
- /// Clears the contents of the string builder.
- ///
- /// The to clear.
- public static void Clear(this StringBuilder value)
- {
- value.Length = 0;
- value.Capacity = 16;
- }
-#endif // !FEATURE_STRINGBUILDER_CLEAR
}
}
diff --git a/src/Renci.SshNet/Common/PacketDump.cs b/src/Renci.SshNet/Common/PacketDump.cs
index 7b50582cb..cd68549d6 100644
--- a/src/Renci.SshNet/Common/PacketDump.cs
+++ b/src/Renci.SshNet/Common/PacketDump.cs
@@ -79,13 +79,9 @@ private static string AsHex(byte[] data, int length)
private static string AsAscii(byte[] data, int length)
{
-#if FEATURE_ENCODING_ASCII
- var encoding = Encoding.ASCII;
-#else
- var encoding = new ASCIIEncoding();
-#endif
+ var encoding = Encoding.ASCII;
- var ascii = new StringBuilder();
+ var ascii = new StringBuilder();
const char dot = '.';
for (var i = 0; i < length; i++)
diff --git a/src/Renci.SshNet/Common/SshData.cs b/src/Renci.SshNet/Common/SshData.cs
index 8e4eca406..844bace7a 100644
--- a/src/Renci.SshNet/Common/SshData.cs
+++ b/src/Renci.SshNet/Common/SshData.cs
@@ -11,11 +11,8 @@ public abstract class SshData
{
internal const int DefaultCapacity = 64;
-#if FEATURE_ENCODING_ASCII
internal static readonly Encoding Ascii = Encoding.ASCII;
-#else
- internal static readonly Encoding Ascii = new ASCIIEncoding();
-#endif
+
internal static readonly Encoding Utf8 = Encoding.UTF8;
private SshDataStream _stream;
diff --git a/src/Renci.SshNet/Common/SshDataStream.cs b/src/Renci.SshNet/Common/SshDataStream.cs
index 010800c3e..0e024491c 100644
--- a/src/Renci.SshNet/Common/SshDataStream.cs
+++ b/src/Renci.SshNet/Common/SshDataStream.cs
@@ -252,13 +252,7 @@ public override byte[] ToArray()
{
if (Capacity == Length)
{
-#if FEATURE_MEMORYSTREAM_GETBUFFER
return GetBuffer();
-#elif FEATURE_MEMORYSTREAM_TRYGETBUFFER
- ArraySegment buffer;
- if (TryGetBuffer(out buffer))
- return buffer.Array;
-#endif
}
return base.ToArray();
}
diff --git a/src/Renci.SshNet/Connection/ConnectorBase.cs b/src/Renci.SshNet/Connection/ConnectorBase.cs
index ffa026750..6bcd556fd 100644
--- a/src/Renci.SshNet/Connection/ConnectorBase.cs
+++ b/src/Renci.SshNet/Connection/ConnectorBase.cs
@@ -5,10 +5,7 @@
using System.Net;
using System.Net.Sockets;
using System.Threading;
-
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet.Connection
{
@@ -26,9 +23,7 @@ protected ConnectorBase(ISocketFactory socketFactory)
public abstract Socket Connect(IConnectionInfo connectionInfo);
-#if FEATURE_TAP
public abstract Task ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken);
-#endif
///
/// Establishes a socket connection to the specified host and port.
@@ -63,7 +58,6 @@ protected Socket SocketConnect(string host, int port, TimeSpan timeout)
}
}
-#if FEATURE_TAP
///
/// Establishes a socket connection to the specified host and port.
///
@@ -97,7 +91,6 @@ protected async Task SocketConnectAsync(string host, int port, Cancellat
throw;
}
}
-#endif
protected static byte SocketReadByte(Socket socket)
{
diff --git a/src/Renci.SshNet/Connection/DirectConnector.cs b/src/Renci.SshNet/Connection/DirectConnector.cs
index 0d07bb936..0f428fc31 100644
--- a/src/Renci.SshNet/Connection/DirectConnector.cs
+++ b/src/Renci.SshNet/Connection/DirectConnector.cs
@@ -14,11 +14,9 @@ public override Socket Connect(IConnectionInfo connectionInfo)
return SocketConnect(connectionInfo.Host, connectionInfo.Port, connectionInfo.Timeout);
}
-#if FEATURE_TAP
public override System.Threading.Tasks.Task ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken)
{
return SocketConnectAsync(connectionInfo.Host, connectionInfo.Port, cancellationToken);
}
-#endif
}
}
diff --git a/src/Renci.SshNet/Connection/IConnector.cs b/src/Renci.SshNet/Connection/IConnector.cs
index 9eccabe62..e49587b74 100644
--- a/src/Renci.SshNet/Connection/IConnector.cs
+++ b/src/Renci.SshNet/Connection/IConnector.cs
@@ -7,8 +7,6 @@ internal interface IConnector
{
Socket Connect(IConnectionInfo connectionInfo);
-#if FEATURE_TAP
System.Threading.Tasks.Task ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken);
-#endif
}
}
diff --git a/src/Renci.SshNet/Connection/IProtocolVersionExchange.cs b/src/Renci.SshNet/Connection/IProtocolVersionExchange.cs
index c804c291f..252cda986 100644
--- a/src/Renci.SshNet/Connection/IProtocolVersionExchange.cs
+++ b/src/Renci.SshNet/Connection/IProtocolVersionExchange.cs
@@ -19,8 +19,6 @@ internal interface IProtocolVersionExchange
///
SshIdentification Start(string clientVersion, Socket socket, TimeSpan timeout);
-#if FEATURE_TAP
System.Threading.Tasks.Task StartAsync(string clientVersion, Socket socket, System.Threading.CancellationToken cancellationToken);
-#endif
}
}
diff --git a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
index 4e6957c10..716b8a42c 100644
--- a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
+++ b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs
@@ -8,9 +8,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet.Connection
{
@@ -24,11 +22,7 @@ internal class ProtocolVersionExchange : IProtocolVersionExchange
{
private const byte Null = 0x00;
-#if FEATURE_REGEX_COMPILE
private static readonly Regex ServerVersionRe = new Regex("^SSH-(?[^-]+)-(?.+?)([ ](?.+))?$", RegexOptions.Compiled);
-#else
- private static readonly Regex ServerVersionRe = new Regex("^SSH-(?[^-]+)-(?.+?)([ ](?.+))?$");
-#endif
///
/// Performs the SSH protocol version exchange.
@@ -82,7 +76,6 @@ public SshIdentification Start(string clientVersion, Socket socket, TimeSpan tim
}
}
-#if FEATURE_TAP
public async Task StartAsync(string clientVersion, Socket socket, CancellationToken cancellationToken)
{
// Immediately send the identification string since the spec states both sides MUST send an identification string
@@ -125,7 +118,6 @@ public async Task StartAsync(string clientVersion, Socket soc
}
}
}
-#endif
private static string GetGroupValue(Match match, string groupName)
{
@@ -203,7 +195,6 @@ private static string SocketReadLine(Socket socket, TimeSpan timeout, List
return null;
}
-#if FEATURE_TAP
private static async Task SocketReadLineAsync(Socket socket, CancellationToken cancellationToken, List buffer)
{
var data = new byte[1];
@@ -254,7 +245,5 @@ private static async Task SocketReadLineAsync(Socket socket, Cancellatio
}
}
}
-#endif
-
}
}
diff --git a/src/Renci.SshNet/Connection/ProxyConnector.cs b/src/Renci.SshNet/Connection/ProxyConnector.cs
index 6cc2ac9d4..164ae4835 100644
--- a/src/Renci.SshNet/Connection/ProxyConnector.cs
+++ b/src/Renci.SshNet/Connection/ProxyConnector.cs
@@ -1,12 +1,8 @@
-#if !FEATURE_SOCKET_DISPOSE
-using Renci.SshNet.Common;
-#endif
-using System;
+using System;
using System.Net.Sockets;
-#if FEATURE_TAP
using System.Threading;
using System.Threading.Tasks;
-#endif
+
namespace Renci.SshNet.Connection
{
@@ -19,7 +15,6 @@ public ProxyConnector(ISocketFactory socketFactory) :
protected abstract void HandleProxyConnect(IConnectionInfo connectionInfo, Socket socket);
-#if FEATURE_TAP
// ToDo: Performs async/sync fallback, true async version should be implemented in derived classes
protected virtual Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, Socket socket, CancellationToken cancellationToken)
{
@@ -31,7 +26,6 @@ protected virtual Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, S
}
return Task.CompletedTask;
}
-#endif
public override Socket Connect(IConnectionInfo connectionInfo)
{
@@ -51,7 +45,6 @@ public override Socket Connect(IConnectionInfo connectionInfo)
}
}
-#if FEATURE_TAP
public override async Task ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken)
{
var socket = await SocketConnectAsync(connectionInfo.ProxyHost, connectionInfo.ProxyPort, cancellationToken).ConfigureAwait(false);
@@ -69,6 +62,5 @@ public override async Task ConnectAsync(IConnectionInfo connectionInfo,
throw;
}
}
-#endif
}
}
diff --git a/src/Renci.SshNet/Connection/Socks4Connector.cs b/src/Renci.SshNet/Connection/Socks4Connector.cs
index ccf4e1456..d507872c6 100644
--- a/src/Renci.SshNet/Connection/Socks4Connector.cs
+++ b/src/Renci.SshNet/Connection/Socks4Connector.cs
@@ -125,11 +125,7 @@ private static byte[] GetProxyUserBytes(string proxyUser)
return Array.Empty;
}
-#if FEATURE_ENCODING_ASCII
return Encoding.ASCII.GetBytes(proxyUser);
-#else
- return new ASCIIEncoding().GetBytes(proxyUser);
-#endif
}
}
}
diff --git a/src/Renci.SshNet/ConnectionInfo.cs b/src/Renci.SshNet/ConnectionInfo.cs
index af8e1ca5c..f0f8b57c7 100644
--- a/src/Renci.SshNet/ConnectionInfo.cs
+++ b/src/Renci.SshNet/ConnectionInfo.cs
@@ -382,11 +382,9 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
HostKeyAlgorithms = new Dictionary>
{
{"ssh-ed25519", data => new KeyHostAlgorithm("ssh-ed25519", new ED25519Key(), data)},
-#if FEATURE_ECDSA
{"ecdsa-sha2-nistp256", data => new KeyHostAlgorithm("ecdsa-sha2-nistp256", new EcdsaKey(), data)},
{"ecdsa-sha2-nistp384", data => new KeyHostAlgorithm("ecdsa-sha2-nistp384", new EcdsaKey(), data)},
{"ecdsa-sha2-nistp521", data => new KeyHostAlgorithm("ecdsa-sha2-nistp521", new EcdsaKey(), data)},
-#endif
{"ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data)},
{"ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data)},
//{"x509v3-sign-rsa", () => { ... },
diff --git a/src/Renci.SshNet/IBaseClient.cs b/src/Renci.SshNet/IBaseClient.cs
index bd9518ac4..c11adb4f6 100644
--- a/src/Renci.SshNet/IBaseClient.cs
+++ b/src/Renci.SshNet/IBaseClient.cs
@@ -2,9 +2,7 @@
using System;
using System.Net.Sockets;
using System.Threading;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet
{
@@ -68,7 +66,6 @@ public interface IBaseClient
/// Failed to establish proxy connection.
void Connect();
-#if FEATURE_TAP
///
/// Asynchronously connects client to the server.
///
@@ -82,7 +79,6 @@ public interface IBaseClient
/// Authentication of SSH session failed.
/// Failed to establish proxy connection.
Task ConnectAsync(CancellationToken cancellationToken);
-#endif
///
/// Disconnects client from the server.
diff --git a/src/Renci.SshNet/ISession.cs b/src/Renci.SshNet/ISession.cs
index cde647a46..bc123c776 100644
--- a/src/Renci.SshNet/ISession.cs
+++ b/src/Renci.SshNet/ISession.cs
@@ -6,9 +6,7 @@
using Renci.SshNet.Messages;
using Renci.SshNet.Messages.Authentication;
using Renci.SshNet.Messages.Connection;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet
{
@@ -57,7 +55,6 @@ internal interface ISession : IDisposable
/// Failed to establish proxy connection.
void Connect();
-#if FEATURE_TAP
///
/// Asynchronously connects to the server.
///
@@ -68,7 +65,6 @@ internal interface ISession : IDisposable
/// Authentication of SSH session failed.
/// Failed to establish proxy connection.
Task ConnectAsync(CancellationToken cancellationToken);
-#endif
///
/// Create a new SSH session channel.
diff --git a/src/Renci.SshNet/ISftpClient.cs b/src/Renci.SshNet/ISftpClient.cs
index eda042eff..99e1e7b06 100644
--- a/src/Renci.SshNet/ISftpClient.cs
+++ b/src/Renci.SshNet/ISftpClient.cs
@@ -4,10 +4,8 @@
using System.Text;
using Renci.SshNet.Sftp;
using Renci.SshNet.Common;
-#if FEATURE_TAP
using System.Threading;
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet
{
@@ -492,7 +490,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// The method was called after the client was disposed.
void DeleteFile(string path);
-#if FEATURE_TAP
///
/// Asynchronously deletes remote file specified by path.
///
@@ -506,7 +503,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
Task DeleteFileAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Downloads remote file specified by the path into the stream.
@@ -673,7 +669,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// The method was called after the client was disposed.
SftpFileSytemInformation GetStatus(string path);
-#if FEATURE_TAP
///
/// Asynchronously gets status using statvfs@openssh.com request.
///
@@ -687,7 +682,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// is null.
/// The method was called after the client was disposed.
Task GetStatusAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Retrieves list of files in remote directory.
@@ -704,8 +698,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// The method was called after the client was disposed.
IEnumerable ListDirectory(string path, Action listCallback = null);
-#if FEATURE_TAP
-
///
/// Asynchronously retrieves list of files in remote directory.
///
@@ -721,7 +713,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
Task> ListDirectoryAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Opens a on the specified path with read/write access.
@@ -750,7 +741,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// The method was called after the client was disposed.
SftpFileStream Open(string path, FileMode mode, FileAccess access);
-#if FEATURE_TAP
///
/// Asynchronously opens a on the specified path, with the specified mode and access.
///
@@ -766,7 +756,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// Client is not connected.
/// The method was called after the client was disposed.
Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken);
-#endif
///
/// Opens an existing file for reading.
@@ -906,7 +895,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// The method was called after the client was disposed.
void RenameFile(string oldPath, string newPath);
-#if FEATURE_TAP
///
/// Asynchronously renames remote file from old path to new path.
///
@@ -920,7 +908,6 @@ public interface ISftpClient : IBaseClient, IDisposable
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
Task RenameFileAsync(string oldPath, string newPath, CancellationToken cancellationToken);
-#endif
///
/// Renames remote file from old path to new path.
diff --git a/src/Renci.SshNet/NoneAuthenticationMethod.cs b/src/Renci.SshNet/NoneAuthenticationMethod.cs
index a5d842fd7..93586ade9 100644
--- a/src/Renci.SshNet/NoneAuthenticationMethod.cs
+++ b/src/Renci.SshNet/NoneAuthenticationMethod.cs
@@ -1,8 +1,5 @@
using System;
using System.Threading;
-#if !FEATURE_WAITHANDLE_DISPOSE
-using Renci.SshNet.Common;
-#endif // !FEATURE_WAITHANDLE_DISPOSE
using Renci.SshNet.Messages.Authentication;
using Renci.SshNet.Messages;
diff --git a/src/Renci.SshNet/PrivateKeyFile.cs b/src/Renci.SshNet/PrivateKeyFile.cs
index f29b3e958..5ec7f248d 100644
--- a/src/Renci.SshNet/PrivateKeyFile.cs
+++ b/src/Renci.SshNet/PrivateKeyFile.cs
@@ -66,11 +66,8 @@ namespace Renci.SshNet
public class PrivateKeyFile : IPrivateKeySource, IDisposable
{
private static readonly Regex PrivateKeyRegex = new Regex(@"^-+ *BEGIN (?\w+( \w+)*) PRIVATE KEY *-+\r?\n((Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: (?[A-Z0-9-]+),(?[A-F0-9]+)\r?\n\r?\n)|(Comment: ""?[^\r\n]*""?\r?\n))?(?([a-zA-Z0-9/+=]{1,80}\r?\n)+)-+ *END \k PRIVATE KEY *-+",
-#if FEATURE_REGEX_COMPILE
RegexOptions.Compiled | RegexOptions.Multiline);
-#else
- RegexOptions.Multiline);
-#endif
+
private Key _key;
@@ -221,12 +218,10 @@ private void Open(Stream privateKey, string passPhrase)
_key = new DsaKey(decryptedData);
HostKey = new KeyHostAlgorithm("ssh-dss", _key);
break;
-#if FEATURE_ECDSA
case "EC":
_key = new EcdsaKey(decryptedData);
HostKey = new KeyHostAlgorithm(_key.ToString(), _key);
break;
-#endif
case "OPENSSH":
_key = ParseOpenSshV1Key(decryptedData, passPhrase);
HostKey = new KeyHostAlgorithm(_key.ToString(), _key);
@@ -497,7 +492,6 @@ private Key ParseOpenSshV1Key(byte[] keyFileData, string passPhrase)
unencryptedPrivateKey = privateKeyReader.ReadBignum2();
parsedKey = new ED25519Key(publicKey.Reverse(), unencryptedPrivateKey);
break;
-#if FEATURE_ECDSA
case "ecdsa-sha2-nistp256":
case "ecdsa-sha2-nistp384":
case "ecdsa-sha2-nistp521":
@@ -510,7 +504,6 @@ private Key ParseOpenSshV1Key(byte[] keyFileData, string passPhrase)
unencryptedPrivateKey = privateKeyReader.ReadBignum2();
parsedKey = new EcdsaKey(curve, publicKey, unencryptedPrivateKey.TrimLeadingZeros());
break;
-#endif
case "ssh-rsa":
var modulus = privateKeyReader.ReadBignum(); //n
var exponent = privateKeyReader.ReadBignum(); //e
diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj
index d9399877b..2f39c80ec 100644
--- a/src/Renci.SshNet/Renci.SshNet.csproj
+++ b/src/Renci.SshNet/Renci.SshNet.csproj
@@ -11,7 +11,7 @@
- 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
+ FEATURE_BINARY_SERIALIZATION;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_DNS_SYNC;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_RIPEMD160
@@ -19,6 +19,6 @@
- FEATURE_STRINGBUILDER_CLEAR;FEATURE_HASHALGORITHM_DISPOSE;FEATURE_ENCODING_ASCII;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_DIRECTORYINFO_ENUMERATEFILES;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_RNG_CREATE;FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP;FEATURE_STREAM_APM;FEATURE_STREAM_TAP;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_TAP;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_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_ECDSA;FEATURE_TAP
+ FEATURE_DIRECTORYINFO_ENUMERATEFILES;FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP
diff --git a/src/Renci.SshNet/Security/BouncyCastle/crypto/prng/CryptoApiRandomGenerator.cs b/src/Renci.SshNet/Security/BouncyCastle/crypto/prng/CryptoApiRandomGenerator.cs
index 5dd468b04..50ae6f38d 100644
--- a/src/Renci.SshNet/Security/BouncyCastle/crypto/prng/CryptoApiRandomGenerator.cs
+++ b/src/Renci.SshNet/Security/BouncyCastle/crypto/prng/CryptoApiRandomGenerator.cs
@@ -9,9 +9,7 @@ internal class CryptoApiRandomGenerator
private readonly RandomNumberGenerator rndProv;
public CryptoApiRandomGenerator()
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
: this(Abstractions.CryptoAbstraction.CreateRandomNumberGenerator())
-#endif
{
}
@@ -34,15 +32,7 @@ public virtual void AddSeedMaterial(long seed)
public virtual void NextBytes(byte[] bytes)
{
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
rndProv.GetBytes(bytes);
-#else
- if (bytes == null)
- throw new ArgumentNullException("bytes");
-
- var buffer = Windows.Security.Cryptography.CryptographicBuffer.GenerateRandom((uint)bytes.Length);
- System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyTo(buffer, bytes);
-#endif
}
public virtual void NextBytes(byte[] bytes, int start, int len)
diff --git a/src/Renci.SshNet/Security/Cryptography/Bcrypt.cs b/src/Renci.SshNet/Security/Cryptography/Bcrypt.cs
index 837d00318..14f6169a5 100644
--- a/src/Renci.SshNet/Security/Cryptography/Bcrypt.cs
+++ b/src/Renci.SshNet/Security/Cryptography/Bcrypt.cs
@@ -499,14 +499,10 @@ public static string GenerateSalt(int workFactor)
throw new ArgumentOutOfRangeException("workFactor", "The work factor must be between 4 and 31 (inclusive)");
byte[] rnd = new byte[BCRYPT_SALT_LEN];
-#if FEATURE_RNG_CREATE
+
RandomNumberGenerator rng = RandomNumberGenerator.Create();
-#elif FEATURE_RNG_CSP
- RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
-#endif
-#if FEATURE_RNG_CREATE || FEATURE_RNG_CSP
+
rng.GetBytes(rnd);
-#endif
StringBuilder rs = new StringBuilder();
rs.AppendFormat("$2a${0:00}$", workFactor);
diff --git a/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs
index 920614672..b5561b5da 100644
--- a/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs
+++ b/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs
@@ -1,5 +1,4 @@
-#if FEATURE_ECDSA
-using System;
+using System;
using Renci.SshNet.Common;
using System.Globalization;
using System.Security.Cryptography;
@@ -186,4 +185,3 @@ protected override int BufferCapacity
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs
index 46f1dcc65..1674a6677 100644
--- a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs
+++ b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs
@@ -1,5 +1,4 @@
-#if FEATURE_ECDSA
-using System;
+using System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
@@ -467,4 +466,3 @@ protected virtual void Dispose(bool disposing)
#endregion
}
}
-#endif
\ No newline at end of file
diff --git a/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs b/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs
index 86b246432..cd129fe69 100644
--- a/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs
+++ b/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs
@@ -1,6 +1,4 @@
-#if FEATURE_HMAC_MD5
-
-using System.Security.Cryptography;
+using System.Security.Cryptography;
using Renci.SshNet.Common;
namespace Renci.SshNet.Security.Cryptography
@@ -57,5 +55,3 @@ protected override byte[] HashFinal()
}
}
}
-
-#endif // FEATURE_HMAC_MD5
diff --git a/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs b/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs
index d8f47af12..49ad384d4 100644
--- a/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs
+++ b/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs
@@ -1,6 +1,4 @@
-#if FEATURE_HMAC_SHA1
-
-using System.Security.Cryptography;
+using System.Security.Cryptography;
using Renci.SshNet.Common;
namespace Renci.SshNet.Security.Cryptography
@@ -57,5 +55,3 @@ protected override byte[] HashFinal()
}
}
}
-
-#endif // FEATURE_HMAC_SHA1
diff --git a/src/Renci.SshNet/Security/Cryptography/HMACSHA256.cs b/src/Renci.SshNet/Security/Cryptography/HMACSHA256.cs
index cb1c31859..2598704e4 100644
--- a/src/Renci.SshNet/Security/Cryptography/HMACSHA256.cs
+++ b/src/Renci.SshNet/Security/Cryptography/HMACSHA256.cs
@@ -1,6 +1,4 @@
-#if FEATURE_HMAC_SHA256
-
-using System.Security.Cryptography;
+using System.Security.Cryptography;
using Renci.SshNet.Common;
namespace Renci.SshNet.Security.Cryptography
@@ -58,5 +56,3 @@ protected override byte[] HashFinal()
}
}
}
-
-#endif // FEATURE_HMAC_SHA256
diff --git a/src/Renci.SshNet/Security/Cryptography/HMACSHA384.cs b/src/Renci.SshNet/Security/Cryptography/HMACSHA384.cs
index 142e51ed7..f5f0b26c5 100644
--- a/src/Renci.SshNet/Security/Cryptography/HMACSHA384.cs
+++ b/src/Renci.SshNet/Security/Cryptography/HMACSHA384.cs
@@ -1,6 +1,4 @@
-#if FEATURE_HMAC_SHA384
-
-using System.Security.Cryptography;
+using System.Security.Cryptography;
using Renci.SshNet.Common;
namespace Renci.SshNet.Security.Cryptography
@@ -57,5 +55,3 @@ protected override byte[] HashFinal()
}
}
}
-
-#endif // FEATURE_HMAC_SHA384
diff --git a/src/Renci.SshNet/Security/Cryptography/HMACSHA512.cs b/src/Renci.SshNet/Security/Cryptography/HMACSHA512.cs
index a297ed088..72e758155 100644
--- a/src/Renci.SshNet/Security/Cryptography/HMACSHA512.cs
+++ b/src/Renci.SshNet/Security/Cryptography/HMACSHA512.cs
@@ -1,6 +1,4 @@
-#if FEATURE_HMAC_SHA512
-
-using System.Security.Cryptography;
+using System.Security.Cryptography;
using Renci.SshNet.Common;
namespace Renci.SshNet.Security.Cryptography
@@ -57,5 +55,3 @@ protected override byte[] HashFinal()
}
}
}
-
-#endif // FEATURE_HMAC_SHA512
diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs
index 0846cb2cd..13764e386 100644
--- a/src/Renci.SshNet/Session.cs
+++ b/src/Renci.SshNet/Session.cs
@@ -16,9 +16,7 @@
using System.Linq;
using Renci.SshNet.Abstractions;
using Renci.SshNet.Security.Cryptography;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet
{
@@ -172,13 +170,11 @@ public class Session : ISession
///
private Socket _socket;
-#if FEATURE_SOCKET_POLL
///
/// Holds an object that is used to ensure only a single thread can read from
/// at any given time.
///
private readonly object _socketReadLock = new object();
-#endif // FEATURE_SOCKET_POLL
///
/// Holds an object that is used to ensure only a single thread can write to
@@ -673,7 +669,6 @@ public void Connect()
}
}
-#if FEATURE_TAP
///
/// Asynchronously connects to the server.
///
@@ -777,7 +772,6 @@ public async Task ConnectAsync(CancellationToken cancellationToken)
RegisterMessage("SSH_MSG_CHANNEL_EOF");
RegisterMessage("SSH_MSG_CHANNEL_CLOSE");
}
-#endif
///
/// Disconnects from the server.
@@ -1150,13 +1144,11 @@ private Message ReceiveMessage(Socket socket)
byte[] data;
uint packetLength;
-#if FEATURE_SOCKET_POLL
// avoid reading from socket while IsSocketConnected is attempting to determine whether the
// socket is still connected by invoking Socket.Poll(...) and subsequently verifying value of
// Socket.Available
lock (_socketReadLock)
{
-#endif // FEATURE_SOCKET_POLL
// Read first block - which starts with the packet length
var firstBlock = new byte[blockSize];
if (TrySocketRead(socket, firstBlock, 0, blockSize) == 0)
@@ -1204,9 +1196,7 @@ private Message ReceiveMessage(Socket socket)
return null;
}
}
-#if FEATURE_SOCKET_POLL
}
-#endif // FEATURE_SOCKET_POLL
if (_serverCipher != null)
{
@@ -1767,7 +1757,6 @@ internal static string ToHex(byte[] bytes)
#endregion
-#if FEATURE_SOCKET_POLL
///
/// Gets a value indicating whether the socket is connected.
///
@@ -1807,23 +1796,10 @@ internal static string ToHex(byte[] bytes)
/// we synchronize reads from the .
///
///
-#else
- ///
- /// Gets a value indicating whether the socket is connected.
- ///
- ///
- /// true if the socket is connected; otherwise, false.
- ///
- ///
- /// We verify whether is true. However, this only returns the state
- /// of the socket as of the last I/O operation.
- ///
-#endif
private bool IsSocketConnected()
{
lock (_socketDisposeLock)
{
-#if FEATURE_SOCKET_POLL
if (!_socket.IsConnected())
{
return false;
@@ -1834,9 +1810,6 @@ private bool IsSocketConnected()
var connectionClosedOrDataAvailable = _socket.Poll(0, SelectMode.SelectRead);
return !(connectionClosedOrDataAvailable && _socket.Available == 0);
}
-#else
- return _socket.IsConnected();
-#endif // FEATURE_SOCKET_POLL
}
}
@@ -1915,10 +1888,8 @@ private void MessageListener()
break;
}
-#if FEATURE_SOCKET_POLL || FEATURE_SOCKET_SELECT
try
{
-#if FEATURE_SOCKET_POLL
// Block until either data is available or the socket is closed
var connectionClosedOrDataAvailable = socket.Poll(-1, SelectMode.SelectRead);
if (connectionClosedOrDataAvailable && socket.Available == 0)
@@ -1926,43 +1897,6 @@ private void MessageListener()
// connection with SSH server was closed or connection was reset
break;
}
-#elif FEATURE_SOCKET_SELECT
- var readSockets = new List { socket };
-
- // if the socket is already disposed when Select is invoked, then a SocketException
- // stating "An operation was attempted on something that is not a socket" is thrown;
- // we attempt to avoid this exception by having an IsConnected() that can break the
- // message loop
- //
- // note that there's no guarantee that the socket will not be disposed between the
- // IsConnected() check and the Select invocation; we can't take a "dispose" lock
- // that includes the Select invocation as we want Dispose() to be able to interrupt
- // the Select
-
- // perform a blocking select to determine whether there's is data available to be
- // read; we do not use a blocking read to allow us to use Socket.Poll to determine
- // if the connection is still available (in IsSocketConnected)
-
- Socket.Select(readSockets, null, null, -1);
-
- // the Select invocation will be interrupted in one of the following conditions:
- // * data is available to be read
- // => the socket will not be removed from "readSockets"
- // * the socket connection is closed during the Select invocation
- // => the socket will be removed from "readSockets"
- // * the socket is disposed during the Select invocation
- // => the socket will not be removed from "readSocket"
- //
- // since we handle the second and third condition the same way and Socket.Connected
- // allows us to check for both conditions, we use that instead of both checking for
- // the removal from "readSockets" and the Connection check
- if (!socket.IsConnected())
- {
- // connection with SSH server was closed or socket was disposed;
- // break out of the message loop
- break;
- }
-#endif // FEATURE_SOCKET_SELECT
}
catch (ObjectDisposedException)
{
@@ -1972,7 +1906,6 @@ private void MessageListener()
// * a SSH_MSG_DISCONNECT received from server
break;
}
-#endif // FEATURE_SOCKET_POLL || FEATURE_SOCKET_SELECT
var message = ReceiveMessage(socket);
if (message == null)
diff --git a/src/Renci.SshNet/Sftp/ISftpSession.cs b/src/Renci.SshNet/Sftp/ISftpSession.cs
index 4a3648bd4..8971bd571 100644
--- a/src/Renci.SshNet/Sftp/ISftpSession.cs
+++ b/src/Renci.SshNet/Sftp/ISftpSession.cs
@@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using Renci.SshNet.Sftp.Responses;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet.Sftp
{
@@ -41,9 +39,7 @@ internal interface ISftpSession : ISubsystemSession
///
string GetCanonicalPath(string path);
-#if FEATURE_TAP
Task GetCanonicalPathAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_FSTAT request.
@@ -55,9 +51,7 @@ internal interface ISftpSession : ISubsystemSession
///
SftpFileAttributes RequestFStat(byte[] handle, bool nullOnError);
-#if FEATURE_TAP
Task RequestFStatAsync(byte[] handle, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_STAT request.
@@ -135,9 +129,7 @@ internal interface ISftpSession : ISubsystemSession
/// File handle.
byte[] RequestOpen(string path, Flags flags, bool nullOnError = false);
-#if FEATURE_TAP
Task RequestOpenAsync(string path, Flags flags, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_OPEN request
@@ -173,9 +165,7 @@ internal interface ISftpSession : ISubsystemSession
/// File handle.
byte[] RequestOpenDir(string path, bool nullOnError = false);
-#if FEATURE_TAP
Task RequestOpenDirAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Performs posix-rename@openssh.com extended request.
@@ -220,9 +210,7 @@ internal interface ISftpSession : ISubsystemSession
/// is null.
byte[] EndRead(SftpReadAsyncResult asyncResult);
-#if FEATURE_TAP
Task RequestReadAsync(byte[] handle, ulong offset, uint length, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_READDIR request
@@ -231,9 +219,7 @@ internal interface ISftpSession : ISubsystemSession
///
KeyValuePair[] RequestReadDir(byte[] handle);
-#if FEATURE_TAP
Task[]> RequestReadDirAsync(byte[] handle, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_REALPATH request.
@@ -262,9 +248,7 @@ internal interface ISftpSession : ISubsystemSession
/// The path.
void RequestRemove(string path);
-#if FEATURE_TAP
Task RequestRemoveAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_RENAME request.
@@ -273,9 +257,7 @@ internal interface ISftpSession : ISubsystemSession
/// The new path.
void RequestRename(string oldPath, string newPath);
-#if FEATURE_TAP
Task RequestRenameAsync(string oldPath, string newPath, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_RMDIR request.
@@ -298,9 +280,7 @@ internal interface ISftpSession : ISubsystemSession
///
SftpFileSytemInformation RequestStatVfs(string path, bool nullOnError = false);
-#if FEATURE_TAP
Task RequestStatVfsAsync(string path, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_SYMLINK request.
@@ -334,9 +314,7 @@ void RequestWrite(byte[] handle,
AutoResetEvent wait,
Action writeCompleted = null);
-#if FEATURE_TAP
Task RequestWriteAsync(byte[] handle, ulong serverOffset, byte[] data, int offset, int length, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_CLOSE request.
@@ -344,9 +322,7 @@ void RequestWrite(byte[] handle,
/// The handle.
void RequestClose(byte[] handle);
-#if FEATURE_TAP
Task RequestCloseAsync(byte[] handle, CancellationToken cancellationToken);
-#endif
///
/// Performs SSH_FXP_CLOSE request.
diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs
index b47023687..a266b35b8 100644
--- a/src/Renci.SshNet/Sftp/SftpFileStream.cs
+++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs
@@ -3,9 +3,7 @@
using System.Threading;
using System.Diagnostics.CodeAnalysis;
using Renci.SshNet.Common;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet.Sftp
{
@@ -293,7 +291,6 @@ internal SftpFileStream(ISftpSession session, string path, FileMode mode, FileAc
}
}
-#if FEATURE_TAP
internal static async Task OpenAsync(ISftpSession session, string path, FileMode mode, FileAccess access, int bufferSize, CancellationToken cancellationToken)
{
if (session == null)
@@ -390,7 +387,6 @@ internal static async Task OpenAsync(ISftpSession session, strin
return new SftpFileStream(session, path, access, bufferSize, handle, position);
}
-#endif
///
/// Releases unmanaged resources and performs other cleanup operations before the
@@ -423,7 +419,6 @@ public override void Flush()
}
}
-#if FEATURE_TAP
///
/// Asynchronously clears all buffers for this stream and causes any buffered data to be written to the file.
///
@@ -446,7 +441,6 @@ public override Task FlushAsync(CancellationToken cancellationToken)
return Task.CompletedTask;
}
-#endif
///
/// Reads a sequence of bytes from the current stream and advances the position within the stream by the
@@ -588,7 +582,6 @@ public override int Read(byte[] buffer, int offset, int count)
return readLen;
}
-#if FEATURE_TAP
///
/// Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the
/// number of bytes read.
@@ -700,7 +693,6 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count,
// return the number of bytes that were read to the caller.
return readLen;
}
-#endif
///
/// Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
@@ -986,7 +978,7 @@ public override void Write(byte[] buffer, int offset, int count)
}
}
-#if FEATURE_TAP
+
///
/// Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
///
@@ -1062,7 +1054,6 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
_bufferPosition = 0;
}
}
-#endif
///
/// Writes a byte to the current position in the stream and advances the position within the stream by one byte.
@@ -1181,7 +1172,6 @@ private void FlushWriteBuffer()
}
}
-#if FEATURE_TAP
private async Task FlushWriteBufferAsync(CancellationToken cancellationToken)
{
if (_bufferPosition > 0)
@@ -1190,7 +1180,6 @@ private async Task FlushWriteBufferAsync(CancellationToken cancellationToken)
_bufferPosition = 0;
}
}
-#endif
///
/// Setups the read.
diff --git a/src/Renci.SshNet/Sftp/SftpSession.cs b/src/Renci.SshNet/Sftp/SftpSession.cs
index c33c70e34..dd38bd36e 100644
--- a/src/Renci.SshNet/Sftp/SftpSession.cs
+++ b/src/Renci.SshNet/Sftp/SftpSession.cs
@@ -6,9 +6,7 @@
using System.Globalization;
using Renci.SshNet.Sftp.Responses;
using Renci.SshNet.Sftp.Requests;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet.Sftp
{
@@ -139,7 +137,6 @@ public string GetCanonicalPath(string path)
return string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", canonizedPath, slash, pathParts[pathParts.Length - 1]);
}
-#if FEATURE_TAP
public async Task GetCanonicalPathAsync(string path, CancellationToken cancellationToken)
{
var fullPath = GetFullRemotePath(path);
@@ -185,7 +182,6 @@ public async Task GetCanonicalPathAsync(string path, CancellationToken c
slash = "/";
return canonizedPath + slash + pathParts[pathParts.Length - 1];
}
-#endif
public ISftpFileReader CreateFileReader(byte[] handle, ISftpSession sftpSession, uint chunkSize, int maxPendingReads, long? fileSize)
{
@@ -436,7 +432,6 @@ public byte[] RequestOpen(string path, Flags flags, bool nullOnError = false)
return handle;
}
-#if FEATURE_TAP
public async Task RequestOpenAsync(string path, Flags flags, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -452,7 +447,6 @@ public async Task RequestOpenAsync(string path, Flags flags, Cancellatio
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_OPEN request
@@ -541,7 +535,6 @@ public void RequestClose(byte[] handle)
}
}
-#if FEATURE_TAP
public async Task RequestCloseAsync(byte[] handle, CancellationToken cancellationToken)
{
TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
@@ -566,8 +559,6 @@ public async Task RequestCloseAsync(byte[] handle, CancellationToken cancellatio
await tcs.Task.ConfigureAwait(false);
}
}
-#endif
-
///
/// Performs SSH_FXP_CLOSE request.
@@ -732,7 +723,6 @@ public byte[] RequestRead(byte[] handle, ulong offset, uint length)
return data;
}
-#if FEATURE_TAP
public async Task RequestReadAsync(byte[] handle, ulong offset, uint length, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -758,7 +748,6 @@ public async Task RequestReadAsync(byte[] handle, ulong offset, uint len
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_WRITE request.
@@ -804,7 +793,6 @@ public void RequestWrite(byte[] handle,
}
}
-#if FEATURE_TAP
public async Task RequestWriteAsync(byte[] handle, ulong serverOffset, byte[] data, int offset, int length, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -829,7 +817,6 @@ public async Task RequestWriteAsync(byte[] handle, ulong serverOffset, byte[] da
await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_LSTAT request.
@@ -963,7 +950,6 @@ public SftpFileAttributes RequestFStat(byte[] handle, bool nullOnError)
return attributes;
}
-#if FEATURE_TAP
public async Task RequestFStatAsync(byte[] handle, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -979,7 +965,6 @@ public async Task RequestFStatAsync(byte[] handle, Cancellat
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_SETSTAT request.
@@ -1078,7 +1063,6 @@ public byte[] RequestOpenDir(string path, bool nullOnError = false)
return handle;
}
-#if FEATURE_TAP
public async Task RequestOpenDirAsync(string path, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1094,7 +1078,6 @@ public async Task RequestOpenDirAsync(string path, CancellationToken can
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_READDIR request
@@ -1137,7 +1120,6 @@ public KeyValuePair[] RequestReadDir(byte[] handle)
return result;
}
-#if FEATURE_TAP
public async Task[]> RequestReadDirAsync(byte[] handle, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1163,8 +1145,6 @@ public async Task[]> RequestReadDirAsyn
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
-
///
/// Performs SSH_FXP_REMOVE request.
@@ -1194,7 +1174,6 @@ public void RequestRemove(string path)
}
}
-#if FEATURE_TAP
public async Task RequestRemoveAsync(string path, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1219,8 +1198,6 @@ public async Task RequestRemoveAsync(string path, CancellationToken cancellation
await tcs.Task.ConfigureAwait(false);
}
}
-#endif
-
///
/// Performs SSH_FXP_MKDIR request.
@@ -1319,7 +1296,6 @@ internal KeyValuePair[] RequestRealPath(string path,
return result;
}
-#if FEATURE_TAP
internal async Task[]> RequestRealPathAsync(string path, bool nullOnError, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1345,7 +1321,6 @@ internal async Task[]> RequestRealPathA
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_REALPATH request.
@@ -1528,8 +1503,6 @@ public void RequestRename(string oldPath, string newPath)
}
}
-
-#if FEATURE_TAP
public async Task RequestRenameAsync(string oldPath, string newPath, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1554,7 +1527,6 @@ public async Task RequestRenameAsync(string oldPath, string newPath, Cancellatio
await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs SSH_FXP_READLINK request.
@@ -1722,8 +1694,6 @@ public SftpFileSytemInformation RequestStatVfs(string path, bool nullOnError = f
return information;
}
-
-#if FEATURE_TAP
public async Task RequestStatVfsAsync(string path, CancellationToken cancellationToken)
{
if (ProtocolVersion < 3)
@@ -1744,7 +1714,6 @@ public async Task RequestStatVfsAsync(string path, Can
return await tcs.Task.ConfigureAwait(false);
}
}
-#endif
///
/// Performs fstatvfs@openssh.com extended request.
diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs
index a7ce34538..2705382ad 100644
--- a/src/Renci.SshNet/SftpClient.cs
+++ b/src/Renci.SshNet/SftpClient.cs
@@ -10,9 +10,7 @@
using Renci.SshNet.Abstractions;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
-#if FEATURE_TAP
using System.Threading.Tasks;
-#endif
namespace Renci.SshNet
{
@@ -376,7 +374,6 @@ public void DeleteFile(string path)
_sftpSession.RequestRemove(fullPath);
}
-#if FEATURE_TAP
///
/// Asynchronously deletes remote file specified by path.
///
@@ -401,7 +398,6 @@ public async Task DeleteFileAsync(string path, CancellationToken cancellationTok
var fullPath = await _sftpSession.GetCanonicalPathAsync(path, cancellationToken).ConfigureAwait(false);
await _sftpSession.RequestRemoveAsync(fullPath, cancellationToken).ConfigureAwait(false);
}
-#endif
///
/// Renames remote file from old path to new path.
@@ -418,7 +414,6 @@ public void RenameFile(string oldPath, string newPath)
RenameFile(oldPath, newPath, false);
}
-#if FEATURE_TAP
///
/// Asynchronously renames remote file from old path to new path.
///
@@ -446,7 +441,6 @@ public async Task RenameFileAsync(string oldPath, string newPath, CancellationTo
var newFullPath = await _sftpSession.GetCanonicalPathAsync(newPath, cancellationToken).ConfigureAwait(false);
await _sftpSession.RequestRenameAsync(oldFullPath, newFullPath, cancellationToken).ConfigureAwait(false);
}
-#endif
///
/// Renames remote file from old path to new path.
@@ -536,8 +530,6 @@ public IEnumerable ListDirectory(string path, Action listCallbac
return InternalListDirectory(path, listCallback);
}
-#if FEATURE_TAP
-
///
/// Asynchronously retrieves list of files in remote directory.
///
@@ -594,8 +586,6 @@ public async Task> ListDirectoryAsync(string path, Cancel
return result;
}
-#endif
-
///
/// Begins an asynchronous operation of retrieving list of files in remote directory.
///
@@ -1129,7 +1119,6 @@ public SftpFileSytemInformation GetStatus(string path)
return _sftpSession.RequestStatVfs(fullPath);
}
-#if FEATURE_TAP
///
/// Asynchronously gets status using statvfs@openssh.com request.
///
@@ -1154,7 +1143,6 @@ public async Task GetStatusAsync(string path, Cancella
var fullPath = await _sftpSession.GetCanonicalPathAsync(path, cancellationToken).ConfigureAwait(false);
return await _sftpSession.RequestStatVfsAsync(fullPath, cancellationToken).ConfigureAwait(false);
}
-#endif
#region File Methods
@@ -1503,7 +1491,6 @@ public SftpFileStream Open(string path, FileMode mode, FileAccess access)
return new SftpFileStream(_sftpSession, path, mode, access, (int) _bufferSize);
}
-#if FEATURE_TAP
///
/// Asynchronously opens a on the specified path, with the specified mode and access.
///
@@ -1529,7 +1516,6 @@ public Task OpenAsync(string path, FileMode mode, FileAccess acc
return SftpFileStream.OpenAsync(_sftpSession, path, mode, access, (int)_bufferSize, cancellationToken);
}
-#endif
///
/// Opens an existing file for reading.
diff --git a/src/Renci.SshNet/Shell.cs b/src/Renci.SshNet/Shell.cs
index c508be896..3e68e6b12 100644
--- a/src/Renci.SshNet/Shell.cs
+++ b/src/Renci.SshNet/Shell.cs
@@ -129,7 +129,6 @@ public void Start()
while (_channel.IsOpen)
{
-#if FEATURE_STREAM_TAP
var readTask = _input.ReadAsync(buffer, 0, buffer.Length);
var readWaitHandle = ((IAsyncResult) readTask).AsyncWaitHandle;
@@ -139,24 +138,7 @@ public void Start()
_channel.SendData(buffer, 0, read);
continue;
}
-#elif FEATURE_STREAM_APM
- var asyncResult = _input.BeginRead(buffer, 0, buffer.Length, result =>
- {
- // If input stream is closed and disposed already don't finish reading the stream
- if (_input == null)
- return;
- var read = _input.EndRead(result);
- _channel.SendData(buffer, 0, read);
- }, null);
-
- WaitHandle.WaitAny(new[] { asyncResult.AsyncWaitHandle, _channelClosedWaitHandle });
-
- if (asyncResult.IsCompleted)
- continue;
-#else
- #error Async receive is not implemented.
-#endif
break;
}
}