diff --git a/.editorconfig b/.editorconfig
index 788ade7af..7f0d54c91 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -726,6 +726,12 @@ dotnet_diagnostic.CA1848.severity = silent
# By default, this diagnostic is only reported for private members.
dotnet_code_quality.CA1859.api_surface = private,internal
+# CA1873: Evaluation of this argument may be expensive and unnecessary if logging is disabled
+dotnet_diagnostic.CA1873.severity = suggestion
+
+# CA1508: Avoid dead conditional code. Too many false positives.
+dotnet_diagnostic.CA1508.severity = suggestion
+
# CA2208: Instantiate argument exceptions correctly
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2208
#
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1bc033d8e..bb8385bc5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,33 +18,33 @@ jobs:
uses: actions/setup-dotnet@v4
- name: Build Unit Tests .NET
- run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
+ run: dotnet build -f net10.0 test/Renci.SshNet.Tests/
- name: Build IntegrationTests .NET
- run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
+ run: dotnet build -f net10.0 test/Renci.SshNet.IntegrationTests/
- name: Run Unit Tests .NET
run: |
dotnet test \
- -f net9.0 \
+ -f net10.0 \
--no-build \
--logger "console;verbosity=normal" \
--logger GitHubActions \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=cobertura \
- -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \
+ -p:CoverletOutput=../../coverlet/linux_unit_test_net_10_coverage.xml \
test/Renci.SshNet.Tests/
- name: Run Integration Tests .NET
run: |
dotnet test \
- -f net9.0 \
+ -f net10.0 \
--no-build \
--logger "console;verbosity=normal" \
--logger GitHubActions \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=cobertura \
- -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
+ -p:CoverletOutput=../../coverlet/linux_integration_test_net_10_coverage.xml \
test/Renci.SshNet.IntegrationTests/
- name: Archive Coverlet Results
@@ -82,13 +82,13 @@ jobs:
- name: Run Unit Tests .NET
run: |
dotnet test `
- -f net9.0 `
+ -f net10.0 `
--no-build `
--logger "console;verbosity=normal" `
--logger GitHubActions `
-p:CollectCoverage=true `
-p:CoverletOutputFormat=cobertura `
- -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml `
+ -p:CoverletOutput=../../coverlet/windows_unit_test_net_10_coverage.xml `
test/Renci.SshNet.Tests/
- name: Run Unit Tests .NET Framework
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 6ae4272d0..b971991c6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -12,7 +12,7 @@
-
+
@@ -23,4 +23,4 @@
-
\ No newline at end of file
+
diff --git a/global.json b/global.json
index 3be1c15ac..41db5496e 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,7 @@
{
"sdk": {
- "version": "9.0.300",
+ "version": "10.0.100-preview.6.25358.103",
+ "allowPrerelease": true,
"rollForward": "latestFeature"
}
}
diff --git a/src/Renci.SshNet/Common/Lock.cs b/src/Renci.SshNet/Common/Lock.cs
index fc29776d3..6e9496be6 100644
--- a/src/Renci.SshNet/Common/Lock.cs
+++ b/src/Renci.SshNet/Common/Lock.cs
@@ -5,14 +5,16 @@ namespace Renci.SshNet.Common
{
internal sealed class Lock
{
+ private readonly object _lockObject = new object();
+
public bool TryEnter()
{
- return Monitor.TryEnter(this);
+ return Monitor.TryEnter(_lockObject);
}
public void Exit()
{
- Monitor.Exit(this);
+ Monitor.Exit(_lockObject);
}
}
}
diff --git a/src/Renci.SshNet/NetConfClient.cs b/src/Renci.SshNet/NetConfClient.cs
index e4b66ad92..5b509dc51 100644
--- a/src/Renci.SshNet/NetConfClient.cs
+++ b/src/Renci.SshNet/NetConfClient.cs
@@ -299,11 +299,8 @@ protected override void Dispose(bool disposing)
if (disposing)
{
- if (_netConfSession != null)
- {
- _netConfSession.Dispose();
- _netConfSession = null;
- }
+ _netConfSession?.Dispose();
+ _netConfSession = null;
}
}
diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs
index 2044a7852..60edc2d81 100644
--- a/src/Renci.SshNet/Netconf/NetConfSession.cs
+++ b/src/Renci.SshNet/Netconf/NetConfSession.cs
@@ -213,17 +213,11 @@ protected override void Dispose(bool disposing)
if (disposing)
{
- if (_serverCapabilitiesConfirmed != null)
- {
- _serverCapabilitiesConfirmed.Dispose();
- _serverCapabilitiesConfirmed = null;
- }
+ _serverCapabilitiesConfirmed?.Dispose();
+ _serverCapabilitiesConfirmed = null;
- if (_rpcReplyReceived != null)
- {
- _rpcReplyReceived.Dispose();
- _rpcReplyReceived = null;
- }
+ _rpcReplyReceived?.Dispose();
+ _rpcReplyReceived = null;
}
}
}
diff --git a/src/Renci.SshNet/PrivateKeyFile.OpenSSH.cs b/src/Renci.SshNet/PrivateKeyFile.OpenSSH.cs
index 0a02d8cf9..55fc11cae 100644
--- a/src/Renci.SshNet/PrivateKeyFile.OpenSSH.cs
+++ b/src/Renci.SshNet/PrivateKeyFile.OpenSSH.cs
@@ -32,7 +32,7 @@ public OpenSSH(byte[] data, string? passPhrase)
///
public Key Parse()
{
- var keyReader = new SshDataStream(_data);
+ using var keyReader = new SshDataStream(_data);
// check magic header
var authMagic = "openssh-key-v1\0"u8;
@@ -171,7 +171,7 @@ public Key Parse()
// now parse the data we called the private key, it actually contains the public key again
// so we need to parse through it to get the private key bytes, plus there's some
// validation we need to do.
- var privateKeyReader = new SshDataStream(privateKeyBytes);
+ using var privateKeyReader = new SshDataStream(privateKeyBytes);
// check ints should match, they wouldn't match for example if the wrong passphrase was supplied
var checkInt1 = (int)privateKeyReader.ReadUInt32();
@@ -200,7 +200,9 @@ public Key Parse()
// k || ENC(A)
unencryptedPrivateKey = privateKeyReader.ReadBinary();
+#pragma warning disable CA2000 // Dispose objects before losing scope
parsedKey = new ED25519Key(unencryptedPrivateKey);
+#pragma warning restore CA2000 // Dispose objects before losing scope
break;
case "ecdsa-sha2-nistp256":
case "ecdsa-sha2-nistp384":
@@ -210,7 +212,9 @@ public Key Parse()
publicKey = privateKeyReader.ReadBinary();
unencryptedPrivateKey = privateKeyReader.ReadBinary();
+#pragma warning disable CA2000 // Dispose objects before losing scope
parsedKey = new EcdsaKey(curve, publicKey, unencryptedPrivateKey.TrimLeadingZeros());
+#pragma warning restore CA2000 // Dispose objects before losing scope
break;
case "ssh-rsa":
var modulus = privateKeyReader.ReadBigInt();
@@ -219,7 +223,9 @@ public Key Parse()
var inverseQ = privateKeyReader.ReadBigInt();
var p = privateKeyReader.ReadBigInt();
var q = privateKeyReader.ReadBigInt();
+#pragma warning disable CA2000 // Dispose objects before losing scope
parsedKey = new RsaKey(modulus, exponent, d, p, q, inverseQ);
+#pragma warning restore CA2000 // Dispose objects before losing scope
break;
default:
throw new SshException("OpenSSH key type '" + keyType + "' is not supported.");
diff --git a/src/Renci.SshNet/PrivateKeyFile.PuTTY.cs b/src/Renci.SshNet/PrivateKeyFile.PuTTY.cs
index 3ac40242b..5e5b63118 100644
--- a/src/Renci.SshNet/PrivateKeyFile.PuTTY.cs
+++ b/src/Renci.SshNet/PrivateKeyFile.PuTTY.cs
@@ -163,11 +163,11 @@ public Key Parse()
throw new SshException("MAC verification failed for PuTTY key file");
}
- var publicKeyReader = new SshDataStream(_publicKey);
+ using var publicKeyReader = new SshDataStream(_publicKey);
var keyType = publicKeyReader.ReadString(Encoding.UTF8);
Debug.Assert(keyType == _algorithmName, $"{nameof(keyType)} is not the same as {nameof(_algorithmName)}");
- var privateKeyReader = new SshDataStream(privateKey);
+ using var privateKeyReader = new SshDataStream(privateKey);
Key parsedKey;
diff --git a/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs b/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
index 5be439608..5bae05f20 100644
--- a/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
+++ b/src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs
@@ -28,22 +28,22 @@ public SSHCOM(byte[] data, string? passPhrase)
public Key Parse()
{
- var reader = new SshDataStream(_data);
- var magicNumber = reader.ReadUInt32();
+ using var dataReader = new SshDataStream(_data);
+ var magicNumber = dataReader.ReadUInt32();
if (magicNumber != 0x3f6ff9eb)
{
throw new SshException("Invalid SSH2 private key.");
}
- _ = reader.ReadUInt32(); // Read total bytes length including magic number
- var keyType = reader.ReadString(SshData.Ascii);
- var ssh2CipherName = reader.ReadString(SshData.Ascii);
- var blobSize = (int)reader.ReadUInt32();
+ _ = dataReader.ReadUInt32(); // Read total bytes length including magic number
+ var keyType = dataReader.ReadString(SshData.Ascii);
+ var ssh2CipherName = dataReader.ReadString(SshData.Ascii);
+ var blobSize = (int)dataReader.ReadUInt32();
byte[] keyData;
if (ssh2CipherName == "none")
{
- keyData = reader.ReadBytes(blobSize);
+ keyData = dataReader.ReadBytes(blobSize);
}
else if (ssh2CipherName == "3des-cbc")
{
@@ -53,17 +53,17 @@ public Key Parse()
}
var key = GetCipherKey(_passPhrase, 192 / 8);
- var ssh2Сipher = new TripleDesCipher(key, new byte[8], CipherMode.CBC, pkcs7Padding: false);
- keyData = ssh2Сipher.Decrypt(reader.ReadBytes(blobSize));
+ using var ssh2Сipher = new TripleDesCipher(key, new byte[8], CipherMode.CBC, pkcs7Padding: false);
+ keyData = ssh2Сipher.Decrypt(dataReader.ReadBytes(blobSize));
}
else
{
throw new SshException(string.Format("Cipher method '{0}' is not supported.", ssh2CipherName));
}
- reader = new SshDataStream(keyData);
+ using var keyReader = new SshDataStream(keyData);
- var decryptedLength = reader.ReadUInt32();
+ var decryptedLength = keyReader.ReadUInt32();
if (decryptedLength > blobSize - 4)
{
@@ -72,12 +72,12 @@ public Key Parse()
if (keyType.Contains("rsa"))
{
- var exponent = ReadBigIntWithBits(reader);
- var d = ReadBigIntWithBits(reader);
- var modulus = ReadBigIntWithBits(reader);
- var inverseQ = ReadBigIntWithBits(reader);
- var q = ReadBigIntWithBits(reader);
- var p = ReadBigIntWithBits(reader);
+ var exponent = ReadBigIntWithBits(keyReader);
+ var d = ReadBigIntWithBits(keyReader);
+ var modulus = ReadBigIntWithBits(keyReader);
+ var inverseQ = ReadBigIntWithBits(keyReader);
+ var q = ReadBigIntWithBits(keyReader);
+ var p = ReadBigIntWithBits(keyReader);
return new RsaKey(modulus, exponent, d, p, q, inverseQ);
}
diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj
index 446865229..091ee6a7a 100644
--- a/src/Renci.SshNet/Renci.SshNet.csproj
+++ b/src/Renci.SshNet/Renci.SshNet.csproj
@@ -4,7 +4,7 @@
Renci.SshNet
SSH.NET
SSH.NET
- net462;netstandard2.0;net8.0;net9.0
+ net462;netstandard2.0;net8.0;net9.0;net10.0
diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs
index ec3eac878..e94ebeb27 100644
--- a/src/Renci.SshNet/Session.cs
+++ b/src/Renci.SshNet/Session.cs
@@ -1570,17 +1570,11 @@ internal void OnNewKeysReceived(NewKeysMessage message)
disposableClientCipher.Dispose();
}
- if (_serverMac != null)
- {
- _serverMac.Dispose();
- _serverMac = null;
- }
+ _serverMac?.Dispose();
+ _serverMac = null;
- if (_clientMac != null)
- {
- _clientMac.Dispose();
- _clientMac = null;
- }
+ _clientMac?.Dispose();
+ _clientMac = null;
// Update negotiated algorithms
_serverCipher = _keyExchange.CreateServerCipher(out _serverAead);
diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs
index c5e486a9a..60ffcb52f 100644
--- a/src/Renci.SshNet/Sftp/SftpFileStream.cs
+++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs
@@ -210,7 +210,9 @@ private SftpFileStream(ISftpSession session, string path, FileAccess access, int
internal static SftpFileStream Open(ISftpSession session, string path, FileMode mode, FileAccess access, int bufferSize)
{
+#pragma warning disable CA2000 // Dispose objects before losing scope
return Open(session, path, mode, access, bufferSize, isAsync: false, CancellationToken.None).GetAwaiter().GetResult();
+#pragma warning restore CA2000 // Dispose objects before losing scope
}
internal static Task OpenAsync(ISftpSession session, string path, FileMode mode, FileAccess access, int bufferSize, CancellationToken cancellationToken)
diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs
index 2d3ac574b..4ff3e72f3 100644
--- a/src/Renci.SshNet/SftpClient.cs
+++ b/src/Renci.SshNet/SftpClient.cs
@@ -2305,6 +2305,8 @@ private List InternalSynchronizeDirectories(string sourcePath, string
var remoteFileName = string.Format(CultureInfo.InvariantCulture, @"{0}/{1}", destinationPath, localFile.Name);
try
{
+#pragma warning disable CA2000 // Dispose objects before losing scope
+#pragma warning disable CA2025 // Do not pass 'IDisposable' instances into unawaited tasks
using (var file = File.OpenRead(localFile.FullName))
{
InternalUploadFile(
@@ -2316,6 +2318,8 @@ private List InternalSynchronizeDirectories(string sourcePath, string
isAsync: false,
CancellationToken.None).GetAwaiter().GetResult();
}
+#pragma warning restore CA2025 // Do not pass 'IDisposable' instances into unawaited tasks
+#pragma warning restore CA2000 // Dispose objects before losing scope
uploadedFiles.Add(localFile);
@@ -2482,6 +2486,7 @@ private async Task InternalDownloadFileAsync(string path, Stream output, Cancell
}
#pragma warning disable S6966 // Awaitable method should be used
+#pragma warning disable CA1849 // Call async methods when in an async method
private async Task InternalUploadFile(
Stream input,
string path,
@@ -2621,6 +2626,7 @@ private async Task InternalUploadFile(
}
}
#pragma warning restore S6966 // Awaitable method should be used
+#pragma warning restore CA1849 // Call async methods when in an async method
///
/// Called when client is connected to the server.
diff --git a/src/Renci.SshNet/SshClient.cs b/src/Renci.SshNet/SshClient.cs
index 3051074e1..05508462d 100644
--- a/src/Renci.SshNet/SshClient.cs
+++ b/src/Renci.SshNet/SshClient.cs
@@ -325,11 +325,8 @@ protected override void Dispose(bool disposing)
if (disposing)
{
- if (_inputStream != null)
- {
- _inputStream.Dispose();
- _inputStream = null;
- }
+ _inputStream?.Dispose();
+ _inputStream = null;
_isDisposed = true;
}
diff --git a/test/Renci.SshNet.AotCompatibilityTestApp/Program.cs b/test/Renci.SshNet.AotCompatibilityTestApp/Program.cs
index a85c7ceda..4d5d1ced5 100644
--- a/test/Renci.SshNet.AotCompatibilityTestApp/Program.cs
+++ b/test/Renci.SshNet.AotCompatibilityTestApp/Program.cs
@@ -2,7 +2,7 @@
namespace Renci.SshNet.AotCompatibilityTestApp
{
- public static class Program
+ internal static class Program
{
public static void Main()
{
diff --git a/test/Renci.SshNet.AotCompatibilityTestApp/Renci.SshNet.AotCompatibilityTestApp.csproj b/test/Renci.SshNet.AotCompatibilityTestApp/Renci.SshNet.AotCompatibilityTestApp.csproj
index a18321dae..9d8a4d821 100644
--- a/test/Renci.SshNet.AotCompatibilityTestApp/Renci.SshNet.AotCompatibilityTestApp.csproj
+++ b/test/Renci.SshNet.AotCompatibilityTestApp/Renci.SshNet.AotCompatibilityTestApp.csproj
@@ -2,7 +2,7 @@
Exe
- net9.0
+ net10.0
true
true
false
diff --git a/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj b/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
index f421ad23f..e178dc835 100644
--- a/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
+++ b/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
@@ -2,7 +2,7 @@
Exe
- net9.0
+ net10.0
enable
enable
diff --git a/test/Renci.SshNet.IntegrationBenchmarks/Renci.SshNet.IntegrationBenchmarks.csproj b/test/Renci.SshNet.IntegrationBenchmarks/Renci.SshNet.IntegrationBenchmarks.csproj
index 3f32fe9bb..2a98efd7a 100644
--- a/test/Renci.SshNet.IntegrationBenchmarks/Renci.SshNet.IntegrationBenchmarks.csproj
+++ b/test/Renci.SshNet.IntegrationBenchmarks/Renci.SshNet.IntegrationBenchmarks.csproj
@@ -2,7 +2,7 @@
Exe
- net9.0
+ net10.0
enable
enable
diff --git a/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj b/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
index 8755ffb44..83d1a7be7 100644
--- a/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
+++ b/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
@@ -1,7 +1,7 @@
- net48;net8.0;net9.0
+ net48;net8.0;net9.0;net10.0
enable
true
true
diff --git a/test/Renci.SshNet.IntegrationTests/SshTests.cs b/test/Renci.SshNet.IntegrationTests/SshTests.cs
index 276030e5d..4a4b5ffa3 100644
--- a/test/Renci.SshNet.IntegrationTests/SshTests.cs
+++ b/test/Renci.SshNet.IntegrationTests/SshTests.cs
@@ -542,7 +542,8 @@ public void Ssh_LocalPortForwardingCloseChannels()
{
using HttpClientHandler handler = new()
{
- AllowAutoRedirect = false
+ AllowAutoRedirect = false,
+ CheckCertificateRevocationList = true,
};
using HttpClient httpClient = new(handler);
@@ -598,7 +599,8 @@ public void Ssh_LocalPortForwarding()
{
using HttpClientHandler handler = new()
{
- AllowAutoRedirect = false
+ AllowAutoRedirect = false,
+ CheckCertificateRevocationList = true,
};
using HttpClient httpClient = new(handler);
diff --git a/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs b/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
index 332f3cfe7..8e4c13ea3 100644
--- a/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
+++ b/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
@@ -47,17 +47,11 @@ public void Initialize()
[TestCleanup]
public void CleanUp()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
+ _client?.Dispose();
+ _client = null;
- if (_listener != null)
- {
- _listener.Stop();
- _listener = null;
- }
+ _listener?.Stop();
+ _listener = null;
}
private void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs b/test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
index 8617aba37..4fcf476f7 100644
--- a/test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
+++ b/test/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs
@@ -47,23 +47,14 @@ public void Initialize()
[TestCleanup]
public void CleanUp()
{
- if (_remoteListener != null)
- {
- _remoteListener.Stop();
- _remoteListener = null;
- }
+ _remoteListener?.Stop();
+ _remoteListener = null;
- if (_channelThread != null)
- {
- _channelThread.Join();
- _channelThread = null;
- }
+ _channelThread?.Join();
+ _channelThread = null;
- if (_channel != null)
- {
- _channel.Dispose();
- _channel = null;
- }
+ _channel?.Dispose();
+ _channel = null;
}
private void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked.cs b/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked.cs
index f6eb2933b..ed2946e49 100644
--- a/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked.cs
+++ b/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked.cs
@@ -31,11 +31,8 @@ public class ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofNotReceiv
[TestCleanup]
public void TearDown()
{
- if (_channelClosedEventHandlerCompleted != null)
- {
- _channelClosedEventHandlerCompleted.Dispose();
- _channelClosedEventHandlerCompleted = null;
- }
+ _channelClosedEventHandlerCompleted?.Dispose();
+ _channelClosedEventHandlerCompleted = null;
}
protected override void SetupData()
diff --git a/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived.cs b/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived.cs
index 4f11009bb..c03bfea11 100644
--- a/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived.cs
+++ b/test/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived.cs
@@ -91,23 +91,14 @@ protected override void SetupMocks()
[TestCleanup]
public void TearDown()
{
- if (_channelClosedReceived != null)
- {
- _channelClosedReceived.Dispose();
- _channelClosedReceived = null;
- }
-
- if (_raiseChannelCloseReceivedThread != null)
- {
- _raiseChannelCloseReceivedThread.Join();
- _raiseChannelCloseReceivedThread = null;
- }
-
- if (_channelClosedEventHandlerCompleted != null)
- {
- _channelClosedEventHandlerCompleted.Dispose();
- _channelClosedEventHandlerCompleted = null;
- }
+ _channelClosedReceived?.Dispose();
+ _channelClosedReceived = null;
+
+ _raiseChannelCloseReceivedThread?.Join();
+ _raiseChannelCloseReceivedThread = null;
+
+ _channelClosedEventHandlerCompleted?.Dispose();
+ _channelClosedEventHandlerCompleted = null;
}
protected override void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ConnectionClosedByServer_NoDataSentByServer.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ConnectionClosedByServer_NoDataSentByServer.cs
index 43aa9a3b1..b6ba2dbe5 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ConnectionClosedByServer_NoDataSentByServer.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ConnectionClosedByServer_NoDataSentByServer.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseContainsNullCharacter.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseContainsNullCharacter.cs
index 164cb6a70..4d55fba2e 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseContainsNullCharacter.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseContainsNullCharacter.cs
@@ -38,11 +38,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseInvalid_SshIdentificationOnlyContainsProtocolVersion.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseInvalid_SshIdentificationOnlyContainsProtocolVersion.cs
index 3b0649517..b68588ecb 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseInvalid_SshIdentificationOnlyContainsProtocolVersion.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseInvalid_SshIdentificationOnlyContainsProtocolVersion.cs
@@ -38,11 +38,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_Comments.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_Comments.cs
index 2af8062b6..3835e6516 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_Comments.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_Comments.cs
@@ -37,11 +37,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_EmptySoftwareVersion.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_EmptySoftwareVersion.cs
index c7daaf14d..141bf4189 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_EmptySoftwareVersion.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_EmptySoftwareVersion.cs
@@ -38,11 +38,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_NoComments.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_NoComments.cs
index 365967209..ce80d99dd 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_NoComments.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_NoComments.cs
@@ -37,11 +37,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_TerminatedByLineFeedWithoutCarriageReturn.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_TerminatedByLineFeedWithoutCarriageReturn.cs
index 2c35bce53..ad4953789 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_TerminatedByLineFeedWithoutCarriageReturn.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_ServerResponseValid_TerminatedByLineFeedWithoutCarriageReturn.cs
@@ -37,11 +37,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
if (_client != null)
{
diff --git a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_TimeoutReadingIdentificationString.cs b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_TimeoutReadingIdentificationString.cs
index 3710e2064..3917c9b29 100644
--- a/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_TimeoutReadingIdentificationString.cs
+++ b/test/Renci.SshNet.Tests/Classes/Connection/ProtocolVersionExchangeTest_TimeoutReadingIdentificationString.cs
@@ -37,17 +37,11 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_server != null)
- {
- _server.Dispose();
- _server = null;
- }
+ _server?.Dispose();
+ _server = null;
- if (_client != null)
- {
- _client.Close();
- _client = null;
- }
+ _client?.Close();
+ _client = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortDisposed.cs
index d39a91fab..8da9eee67 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortDisposed.cs
@@ -24,11 +24,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs
index a9ce2b49e..adacc6c7a 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortNeverStarted.cs
@@ -32,11 +32,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs
index 692afe88d..76e819d5f 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelBound.cs
@@ -46,26 +46,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
- if (_channelBindStarted != null)
- {
- _channelBindStarted.Dispose();
- _channelBindStarted = null;
- }
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
+ _channelBindStarted?.Dispose();
+ _channelBindStarted = null;
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
private void CreateMocks()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs
index 5804f6db1..ba949c2c2 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs
@@ -38,16 +38,10 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs
index 85ef70f8b..5a847d72a 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStopped.cs
@@ -32,11 +32,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs
index c98784edd..dd26b91d5 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_SessionErrorOccurred_ChannelBound.cs
@@ -47,26 +47,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
- if (_channelBindStarted != null)
- {
- _channelBindStarted.Dispose();
- _channelBindStarted = null;
- }
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
+ _channelBindStarted?.Dispose();
+ _channelBindStarted = null;
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
private void CreateMocks()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortDisposed.cs
index 2ceac31e4..394be33e2 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortDisposed.cs
@@ -25,11 +25,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs
index adc55951d..32d70787c 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortNeverStarted.cs
@@ -34,11 +34,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs
index d39263b5b..922897a4b 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStarted.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs
index ad71d804c..bffee25fd 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_PortStopped.cs
@@ -34,11 +34,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNull.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNull.cs
index c326c00d1..7c97f2aad 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNull.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Start_SessionNull.cs
@@ -28,11 +28,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs
index e58bf3d9c..597b0a0ec 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketSendShutdownImmediately.cs
@@ -59,11 +59,8 @@ public void Cleanup()
}
}
- if (_channelDisposed != null)
- {
- _channelDisposed.Dispose();
- _channelDisposed = null;
- }
+ _channelDisposed?.Dispose();
+ _channelDisposed = null;
}
private void SetupData()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs
index d28c311b2..850f6fcf1 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Started_SocketVersionNotSupported.cs
@@ -45,17 +45,11 @@ public void Cleanup()
_forwardedPort.Stop();
}
- if (_client != null)
- {
- _client.Close();
- _client = null;
- }
+ _client?.Close();
+ _client = null;
- if (_exceptionFired != null)
- {
- _exceptionFired.Dispose();
- _exceptionFired = null;
- }
+ _exceptionFired?.Dispose();
+ _exceptionFired = null;
}
private void SetupData()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortDisposed.cs
index 58b020323..aa99838af 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortDisposed.cs
@@ -27,11 +27,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortNeverStarted.cs
index 118b075e4..1125acde1 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortNeverStarted.cs
@@ -27,11 +27,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs
index fcfc88a0f..cfda2a209 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs
@@ -45,26 +45,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
- if (_channelBindStarted != null)
- {
- _channelBindStarted.Dispose();
- _channelBindStarted = null;
- }
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
+ _channelBindStarted?.Dispose();
+ _channelBindStarted = null;
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
private void CreateMocks()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs
index fa716b6b3..6a3e0839e 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs
@@ -38,16 +38,10 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs
index dbc738801..a976733b7 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStopped.cs
@@ -32,11 +32,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs
index 66cc6d57f..7ae63cb4e 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed.cs
@@ -30,11 +30,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed_NeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed_NeverStarted.cs
index fb74e217d..9a12182e3 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed_NeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortDisposed_NeverStarted.cs
@@ -24,11 +24,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs
index 22a1ae9fe..82c220624 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortNeverStarted.cs
@@ -33,11 +33,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs
index 6980d3661..5f3ab59c1 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelBound.cs
@@ -40,26 +40,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
- if (_channelBindStarted != null)
- {
- _channelBindStarted.Dispose();
- _channelBindStarted = null;
- }
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
+ _channelBindStarted?.Dispose();
+ _channelBindStarted = null;
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs
index 0f3b0a57c..f684f9ed5 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStarted_ChannelNotBound.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs
index a9dacf9a6..c17165b9f 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Dispose_PortStopped.cs
@@ -33,11 +33,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortDisposed.cs
index 6d841b9c9..d49b3219d 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortDisposed.cs
@@ -28,11 +28,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs
index 9d003ff12..4a884631c 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortNeverStarted.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs
index 60718f7b3..d3b4f4894 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStarted.cs
@@ -36,11 +36,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs
index c7d13ec38..0c61346cd 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Start_PortStopped.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortDisposed.cs
index 2806ec540..e62ac1cd6 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortDisposed.cs
@@ -24,11 +24,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs
index a6432f38a..440a6f41c 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelBound.cs
@@ -40,26 +40,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_client != null)
- {
- _client.Dispose();
- _client = null;
- }
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
- if (_channelBound != null)
- {
- _channelBound.Dispose();
- _channelBound = null;
- }
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ _client?.Dispose();
+ _client = null;
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
+ _channelBound?.Dispose();
+ _channelBound = null;
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
private void CreateMocks()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs
index b8e893db0..08c4e6ccc 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStarted_ChannelNotBound.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs
index 7ec8bde32..54b2594d9 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs
@@ -33,11 +33,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortDisposed.cs
index 2cedfbe5a..a8e2bd1b8 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortDisposed.cs
@@ -27,11 +27,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs
index 37f526e40..f559fec53 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortNeverStarted.cs
@@ -35,11 +35,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs
index eea751b13..eb08449a8 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStarted_ChannelBound.cs
@@ -49,23 +49,14 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (ForwardedPort != null)
- {
- ForwardedPort.Dispose();
- ForwardedPort = null;
- }
-
- if (_channelBindStarted != null)
- {
- _channelBindStarted.Dispose();
- _channelBindStarted = null;
- }
-
- if (_channelBindCompleted != null)
- {
- _channelBindCompleted.Dispose();
- _channelBindCompleted = null;
- }
+ ForwardedPort?.Dispose();
+ ForwardedPort = null;
+
+ _channelBindStarted?.Dispose();
+ _channelBindStarted = null;
+
+ _channelBindCompleted?.Dispose();
+ _channelBindCompleted = null;
}
private void CreateMocks()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs
index ecb1a2ac2..fddcd680c 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Dispose_PortStopped.cs
@@ -37,11 +37,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (ForwardedPort != null)
- {
- ForwardedPort.Dispose();
- ForwardedPort = null;
- }
+ ForwardedPort?.Dispose();
+ ForwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortDisposed.cs
index 8b0b05112..ee7ee8699 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_PortDisposed.cs
@@ -28,11 +28,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNull.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNull.cs
index 9cd3a3046..7428b3652 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNull.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Start_SessionNull.cs
@@ -28,11 +28,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortDisposed.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortDisposed.cs
index 796bdda4d..53df67037 100644
--- a/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortDisposed.cs
+++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortDisposed.cs
@@ -27,11 +27,8 @@ public void Setup()
[TestCleanup]
public void Cleanup()
{
- if (_forwardedPort != null)
- {
- _forwardedPort.Dispose();
- _forwardedPort = null;
- }
+ _forwardedPort?.Dispose();
+ _forwardedPort = null;
}
protected void Arrange()
diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
index 24291fe73..c8ff510e9 100644
--- a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
+++ b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs
@@ -66,23 +66,14 @@ public void Setup()
[TestCleanup]
public void TearDown()
{
- if (ServerListener != null)
- {
- ServerListener.Dispose();
- ServerListener = null;
- }
+ ServerListener?.Dispose();
+ ServerListener = null;
- if (ServerSocket != null)
- {
- ServerSocket.Dispose();
- ServerSocket = null;
- }
+ ServerSocket?.Dispose();
+ ServerSocket = null;
- if (Session != null)
- {
- Session.Dispose();
- Session = null;
- }
+ Session?.Dispose();
+ Session = null;
if (ClientSocket != null && ClientSocket.Connected)
{
@@ -90,11 +81,8 @@ public void TearDown()
ClientSocket.Dispose();
}
- if (FirstKexReceived != null)
- {
- FirstKexReceived.Dispose();
- FirstKexReceived = null;
- }
+ FirstKexReceived?.Dispose();
+ FirstKexReceived = null;
}
protected virtual void SetupData()
diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs
index e8bb7bd7d..957bf2ece 100644
--- a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs
+++ b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectingBase.cs
@@ -79,23 +79,14 @@ protected virtual void ActionAfterKexInit()
[TestCleanup]
public void TearDown()
{
- if (ServerListener != null)
- {
- ServerListener.Dispose();
- ServerListener = null;
- }
+ ServerListener?.Dispose();
+ ServerListener = null;
- if (ServerSocket != null)
- {
- ServerSocket.Dispose();
- ServerSocket = null;
- }
+ ServerSocket?.Dispose();
+ ServerSocket = null;
- if (Session != null)
- {
- Session.Dispose();
- Session = null;
- }
+ Session?.Dispose();
+ Session = null;
if (ClientSocket != null && ClientSocket.Connected)
{
diff --git a/test/Renci.SshNet.Tests/Common/AsyncSocketListener.cs b/test/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
index 23e48799a..575d37160 100644
--- a/test/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
+++ b/test/Renci.SshNet.Tests/Common/AsyncSocketListener.cs
@@ -90,11 +90,8 @@ public void Stop()
_listener?.Dispose();
- if (_receiveThread != null)
- {
- _receiveThread.Join();
- _receiveThread = null;
- }
+ _receiveThread?.Join();
+ _receiveThread = null;
}
public void Dispose()
diff --git a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
index 1a7145aa3..25ffbd8f9 100644
--- a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
+++ b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
@@ -1,7 +1,7 @@
- net462;net8.0;net9.0
+ net462;net8.0;net9.0;net10.0