diff --git a/Directory.Build.props b/Directory.Build.props index ac8b4b82d..7c214d4b3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,7 +31,7 @@ - + $(NoWarn);CS8602;CS8604;CS8777 diff --git a/README.md b/README.md index c27b7ebce..b29808811 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ Private keys in PuTTY private key format can be encrypted using the following ci **SSH.NET** supports the following target frameworks: * .NETFramework 4.6.2 (and higher) * .NET Standard 2.0 and 2.1 -* .NET 6 (and higher) +* .NET 8 (and higher) ## Building the library diff --git a/src/Renci.SshNet/Abstractions/CancellationTokenSourceExtensions.cs b/src/Renci.SshNet/Abstractions/CancellationTokenSourceExtensions.cs index 93ad8e28e..adab8437a 100644 --- a/src/Renci.SshNet/Abstractions/CancellationTokenSourceExtensions.cs +++ b/src/Renci.SshNet/Abstractions/CancellationTokenSourceExtensions.cs @@ -1,3 +1,4 @@ +#if !NET using System.Threading; using System.Threading.Tasks; @@ -5,12 +6,11 @@ namespace Renci.SshNet.Abstractions { internal static class CancellationTokenSourceExtensions { -#if !NET8_OR_GREATER public static Task CancelAsync(this CancellationTokenSource cancellationTokenSource) { cancellationTokenSource.Cancel(); return Task.CompletedTask; } -#endif } } +#endif diff --git a/src/Renci.SshNet/Abstractions/SocketAbstraction.Async.cs b/src/Renci.SshNet/Abstractions/SocketAbstraction.Async.cs index 6cc6918ea..5d13b09d9 100644 --- a/src/Renci.SshNet/Abstractions/SocketAbstraction.Async.cs +++ b/src/Renci.SshNet/Abstractions/SocketAbstraction.Async.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if NET using System; using System.Diagnostics; @@ -47,4 +47,4 @@ static async ValueTask SendAsyncCore(Socket socket, ReadOnlyMemory data, C } } } -#endif // NET6_0_OR_GREATER +#endif // NET diff --git a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs index 3dfb521c5..7114247ae 100644 --- a/src/Renci.SshNet/Abstractions/SocketAbstraction.cs +++ b/src/Renci.SshNet/Abstractions/SocketAbstraction.cs @@ -311,7 +311,7 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS return totalBytesRead; } -#if NET6_0_OR_GREATER == false +#if !NET public static Task ReadAsync(Socket socket, byte[] buffer, CancellationToken cancellationToken) { return socket.ReceiveAsync(buffer, 0, buffer.Length, cancellationToken); diff --git a/src/Renci.SshNet/Abstractions/SocketExtensions.cs b/src/Renci.SshNet/Abstractions/SocketExtensions.cs index cf8d05f41..11c875643 100644 --- a/src/Renci.SshNet/Abstractions/SocketExtensions.cs +++ b/src/Renci.SshNet/Abstractions/SocketExtensions.cs @@ -1,4 +1,4 @@ -#if !NET6_0_OR_GREATER +#if !NET using System; using System.Net; using System.Net.Sockets; @@ -93,11 +93,11 @@ public static async Task ConnectAsync(this Socket socket, EndPoint remoteEndpoin { args.RemoteEndPoint = remoteEndpoint; -#if NET || NETSTANDARD2_1_OR_GREATER +#if NETSTANDARD2_1 await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false)) #else using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false)) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { await args.ExecuteAsync(socket.ConnectAsync); } @@ -112,11 +112,11 @@ public static async Task ReceiveAsync(this Socket socket, byte[] buffer, in { args.SetBuffer(buffer, offset, length); -#if NET || NETSTANDARD2_1_OR_GREATER +#if NETSTANDARD2_1 await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false)) #else using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false)) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { await args.ExecuteAsync(socket.ReceiveAsync); } diff --git a/src/Renci.SshNet/Abstractions/StreamExtensions.cs b/src/Renci.SshNet/Abstractions/StreamExtensions.cs index cbc85c7d1..ec6027f41 100644 --- a/src/Renci.SshNet/Abstractions/StreamExtensions.cs +++ b/src/Renci.SshNet/Abstractions/StreamExtensions.cs @@ -1,18 +1,16 @@ -#if !NET && !NETSTANDARD2_1_OR_GREATER +#if NETFRAMEWORK || NETSTANDARD2_0 using System.IO; using System.Threading.Tasks; -#endif namespace Renci.SshNet.Abstractions { internal static class StreamExtensions { -#if !NET && !NETSTANDARD2_1_OR_GREATER public static ValueTask DisposeAsync(this Stream stream) { stream.Dispose(); return default; } -#endif } } +#endif diff --git a/src/Renci.SshNet/ClientAuthentication.cs b/src/Renci.SshNet/ClientAuthentication.cs index 94ffaa8fb..e527a88d5 100644 --- a/src/Renci.SshNet/ClientAuthentication.cs +++ b/src/Renci.SshNet/ClientAuthentication.cs @@ -105,11 +105,11 @@ private bool TryAuthenticate(ISession session, { authenticationException = new SshAuthenticationException(string.Format(CultureInfo.InvariantCulture, "No suitable authentication method found to complete authentication ({0}).", -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 string.Join(',', allowedAuthenticationMethods))) #else string.Join(",", allowedAuthenticationMethods))) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif ; return false; } diff --git a/src/Renci.SshNet/Common/Extensions.cs b/src/Renci.SshNet/Common/Extensions.cs index 2f3ae6ac0..f0b5d0da8 100644 --- a/src/Renci.SshNet/Common/Extensions.cs +++ b/src/Renci.SshNet/Common/Extensions.cs @@ -48,7 +48,7 @@ internal static ServiceName ToServiceName(this byte[] data) internal static BigInteger ToBigInteger(this byte[] data) { -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1 || NET return new BigInteger(data, isBigEndian: true); #else var reversed = new byte[data.Length]; @@ -62,7 +62,7 @@ internal static BigInteger ToBigInteger(this byte[] data) /// public static BigInteger ToBigInteger2(this byte[] data) { -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1 || NET return new BigInteger(data, isBigEndian: true, isUnsigned: true); #else if ((data[0] & (1 << 7)) != 0) @@ -95,7 +95,7 @@ public static byte[] ToByteArray(this BigInteger bigInt, bool isUnsigned = false } #endif -#if !NET6_0_OR_GREATER +#if !NET public static long GetBitLength(this BigInteger bigint) { // Taken from https://github.com/dotnet/runtime/issues/31308 diff --git a/src/Renci.SshNet/Common/SshData.cs b/src/Renci.SshNet/Common/SshData.cs index f84c3fb39..af1c5ead2 100644 --- a/src/Renci.SshNet/Common/SshData.cs +++ b/src/Renci.SshNet/Common/SshData.cs @@ -372,11 +372,11 @@ protected void Write(BigInteger data) /// name-list data to write. protected void Write(string[] data) { -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 Write(string.Join(',', data), Ascii); #else Write(string.Join(",", data), Ascii); -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif } /// diff --git a/src/Renci.SshNet/Common/SshDataStream.cs b/src/Renci.SshNet/Common/SshDataStream.cs index d322dbad3..49793e874 100644 --- a/src/Renci.SshNet/Common/SshDataStream.cs +++ b/src/Renci.SshNet/Common/SshDataStream.cs @@ -139,7 +139,7 @@ public void Write(string s, Encoding encoding) { ThrowHelper.ThrowIfNull(encoding); -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1 || NET ReadOnlySpan value = s; var count = encoding.GetByteCount(value); var bytes = count <= 256 ? stackalloc byte[count] : new byte[count]; @@ -207,7 +207,7 @@ public BigInteger ReadBigInt() { var data = ReadBinary(); -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1 || NET return new BigInteger(data, isBigEndian: true); #else return new BigInteger(data.Reverse()); diff --git a/src/Renci.SshNet/Common/TaskToAsyncResult.cs b/src/Renci.SshNet/Common/TaskToAsyncResult.cs index df3e904ba..febeb6580 100644 --- a/src/Renci.SshNet/Common/TaskToAsyncResult.cs +++ b/src/Renci.SshNet/Common/TaskToAsyncResult.cs @@ -1,6 +1,6 @@ #pragma warning disable -#if !NET8_0_OR_GREATER -// Copied verbatim from https://github.com/dotnet/runtime/blob/78bd7debe6d8b454294c673c9cb969c6b8a14692/src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs +#if !NET +// Copied verbatim from https://github.com/dotnet/runtime/blob/261611930d6b436d7c4395450356b624d903d9bf/src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. @@ -35,7 +35,7 @@ static class TaskToAsyncResult /// public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(task); #else if (task is null) @@ -72,7 +72,7 @@ public static TResult End(IAsyncResult asyncResult) => /// was not produced by a call to . public static Task Unwrap(IAsyncResult asyncResult) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(asyncResult); #else if (asyncResult is null) @@ -101,7 +101,7 @@ public static Task Unwrap(IAsyncResult asyncResult) /// public static Task Unwrap(IAsyncResult asyncResult) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(asyncResult); #else if (asyncResult is null) diff --git a/src/Renci.SshNet/Common/ThrowHelper.cs b/src/Renci.SshNet/Common/ThrowHelper.cs index e3ba53761..398a2c120 100644 --- a/src/Renci.SshNet/Common/ThrowHelper.cs +++ b/src/Renci.SshNet/Common/ThrowHelper.cs @@ -9,7 +9,7 @@ internal static class ThrowHelper { public static void ThrowObjectDisposedIf(bool condition, object instance) { -#if NET7_0_OR_GREATER +#if NET ObjectDisposedException.ThrowIf(condition, instance); #else if (condition) @@ -26,7 +26,7 @@ static void Throw(object? instance) public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(argument, paramName); #else if (argument is null) @@ -44,7 +44,7 @@ static void Throw(string? paramName) public static void ThrowIfNullOrWhiteSpace([NotNull] string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) { -#if NET8_0_OR_GREATER +#if NET ArgumentException.ThrowIfNullOrWhiteSpace(argument, paramName); #else if (string.IsNullOrWhiteSpace(argument)) @@ -63,7 +63,7 @@ static void Throw(string? argument, string? paramName) public static void ThrowIfNullOrEmpty([NotNull] string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null) { -#if NET7_0_OR_GREATER +#if NET ArgumentException.ThrowIfNullOrEmpty(argument, paramName); #else if (string.IsNullOrEmpty(argument)) diff --git a/src/Renci.SshNet/Compression/Zlib.cs b/src/Renci.SshNet/Compression/Zlib.cs index f82015de1..519e4cf90 100644 --- a/src/Renci.SshNet/Compression/Zlib.cs +++ b/src/Renci.SshNet/Compression/Zlib.cs @@ -1,5 +1,5 @@ using System.IO; -#if NET6_0_OR_GREATER +#if NET using System.IO.Compression; #else using Org.BouncyCastle.Utilities.Zlib; @@ -14,7 +14,7 @@ namespace Renci.SshNet.Compression public class Zlib : Compressor #pragma warning restore CA1724 // Type names should not match namespaces { -#if NET6_0_OR_GREATER +#if NET private readonly ZLibStream _compressor; private readonly ZLibStream _decompressor; #else @@ -45,7 +45,7 @@ protected Zlib(bool delayedCompression) _compressorStream = new MemoryStream(); _decompressorStream = new MemoryStream(); -#if NET6_0_OR_GREATER +#if NET _compressor = new ZLibStream(_compressorStream, CompressionMode.Compress); _decompressor = new ZLibStream(_decompressorStream, CompressionMode.Decompress); #else @@ -74,7 +74,7 @@ protected override byte[] CompressCore(byte[] data, int offset, int length) /// protected override byte[] DecompressCore(byte[] data, int offset, int length) { -#if NET6_0_OR_GREATER +#if NET _decompressorStream.Write(data, offset, length); _decompressorStream.Position = 0; diff --git a/src/Renci.SshNet/Connection/HttpConnector.cs b/src/Renci.SshNet/Connection/HttpConnector.cs index a05222fe3..76bb79c08 100644 --- a/src/Renci.SshNet/Connection/HttpConnector.cs +++ b/src/Renci.SshNet/Connection/HttpConnector.cs @@ -34,7 +34,7 @@ internal sealed partial class HttpConnector : ProxyConnector private const string HttpResponsePattern = @"HTTP/(?\d[.]\d) (?\d{3}) (?.+)$"; private const string HttpHeaderPattern = @"(?[^\[\]()<>@,;:\""/?={} \t]+):(?.+)?"; -#if NET7_0_OR_GREATER +#if NET private static readonly Regex HttpResponseRegex = GetHttpResponseRegex(); private static readonly Regex HttpHeaderRegex = GetHttpHeaderRegex(); diff --git a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs index b3c736335..a0c67a865 100644 --- a/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs +++ b/src/Renci.SshNet/Connection/ProtocolVersionExchange.cs @@ -24,7 +24,7 @@ internal sealed partial class ProtocolVersionExchange : IProtocolVersionExchange private const byte Null = 0x00; private const string ServerVersionPattern = "^SSH-(?[^-]+)-(?.*?)([ ](?.+))?$"; -#if NET7_0_OR_GREATER +#if NET private static readonly Regex ServerVersionRegex = GetServerVersionRegex(); [GeneratedRegex(ServerVersionPattern, RegexOptions.ExplicitCapture)] @@ -89,11 +89,11 @@ public async Task StartAsync(string clientVersion, Socket soc { // Immediately send the identification string since the spec states both sides MUST send an identification string // when the connection has been established -#if NET6_0_OR_GREATER +#if NET await SocketAbstraction.SendAsync(socket, Encoding.UTF8.GetBytes(clientVersion + "\x0D\x0A"), cancellationToken).ConfigureAwait(false); #else SocketAbstraction.Send(socket, Encoding.UTF8.GetBytes(clientVersion + "\x0D\x0A")); -#endif // NET6_0_OR_GREATER +#endif // NET var bytesReceived = new List(); diff --git a/src/Renci.SshNet/Connection/ProxyConnector.cs b/src/Renci.SshNet/Connection/ProxyConnector.cs index 2e5b715b5..e76f81127 100644 --- a/src/Renci.SshNet/Connection/ProxyConnector.cs +++ b/src/Renci.SshNet/Connection/ProxyConnector.cs @@ -21,27 +21,27 @@ protected ProxyConnector(ISocketFactory socketFactory) // ToDo: Performs async/sync fallback, true async version should be implemented in derived classes protected virtual -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 async -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, Socket socket, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 await using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false)) #else using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false)) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { #pragma warning disable MA0042 // Do not use blocking calls in an async method; false positive caused by https://github.com/meziantou/Meziantou.Analyzer/issues/613 HandleProxyConnect(connectionInfo, socket); #pragma warning restore MA0042 // Do not use blocking calls in an async method } -#if !NET && !NETSTANDARD2_1_OR_GREATER +#if !NET && !NETSTANDARD2_1 return Task.CompletedTask; -#endif // !NET && !NETSTANDARD2_1_OR_GREATER +#endif } /// diff --git a/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs b/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs index 9b36c9122..24dceed71 100644 --- a/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs +++ b/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs @@ -55,11 +55,11 @@ protected override void LoadData() PartialSuccess = ReadBoolean(); if (PartialSuccess) { -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 Message = string.Join(',', AllowedAuthentications); #else Message = string.Join(",", AllowedAuthentications); -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif } } diff --git a/src/Renci.SshNet/Netconf/NetConfSession.cs b/src/Renci.SshNet/Netconf/NetConfSession.cs index d844a3162..acc99974b 100644 --- a/src/Renci.SshNet/Netconf/NetConfSession.cs +++ b/src/Renci.SshNet/Netconf/NetConfSession.cs @@ -21,7 +21,7 @@ internal sealed partial class NetConfSession : SubsystemSession, INetConfSession private StringBuilder _rpcReply = new StringBuilder(); private int _messageId; -#if NET7_0_OR_GREATER +#if NET private static readonly Regex LengthRegex = GetLengthRegex(); private static readonly Regex ReplyRegex = GetReplyRegex(); @@ -181,11 +181,11 @@ protected override void OnDataReceived(byte[] data) position += match.Index + match.Length + fractionLength; } -#if NET7_0_OR_GREATER +#if NET if (ReplyRegex.IsMatch(chunk.AsSpan(position))) #else if (ReplyRegex.IsMatch(chunk.Substring(position))) -#endif // NET7_0_OR_GREATER +#endif // NET { _ = _rpcReplyReceived.Set(); } diff --git a/src/Renci.SshNet/PrivateKeyFile.cs b/src/Renci.SshNet/PrivateKeyFile.cs index cbd037390..fe19ddfe5 100644 --- a/src/Renci.SshNet/PrivateKeyFile.cs +++ b/src/Renci.SshNet/PrivateKeyFile.cs @@ -119,7 +119,7 @@ public partial class PrivateKeyFile : IPrivateKeySource, IDisposable private const string PuTTYPrivateKeyPattern = @"^(?PuTTY-User-Key-File)-(?\d+): (?[\w-]+)\r?\nEncryption: (?[\w-]+)\r?\nComment: (?.*?)\r?\nPublic-Lines: \d+\r?\n(?(([a-zA-Z0-9/+=]{1,64})\r?\n)+)(Key-Derivation: (?\w+)\r?\nArgon2-Memory: (?\d+)\r?\nArgon2-Passes: (?\d+)\r?\nArgon2-Parallelism: (?\d+)\r?\nArgon2-Salt: (?[a-fA-F0-9]+)\r?\n)?Private-Lines: \d+\r?\n(?(([a-zA-Z0-9/+=]{1,64})\r?\n)+)+Private-MAC: (?[a-fA-F0-9]+)"; private const string CertificatePattern = @"(?[-\w]+@openssh\.com)\s(?[a-zA-Z0-9\/+=]*)(\s+(?.*))?"; -#if NET7_0_OR_GREATER +#if NET private static readonly Regex PrivateKeyRegex = GetPrivateKeyRegex(); private static readonly Regex PuTTYPrivateKeyRegex = GetPrivateKeyPuTTYRegex(); private static readonly Regex CertificateRegex = GetCertificateRegex(); diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 81225f6b7..c6ab62f32 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;netstandard2.1;net6.0;net8.0;net9.0 + net462;netstandard2.0;netstandard2.1;net8.0;net9.0 @@ -36,10 +36,6 @@ true - - true - - true diff --git a/src/Renci.SshNet/ScpClient.cs b/src/Renci.SshNet/ScpClient.cs index 55b166d78..ce9fbffaf 100644 --- a/src/Renci.SshNet/ScpClient.cs +++ b/src/Renci.SshNet/ScpClient.cs @@ -37,7 +37,7 @@ public partial class ScpClient : BaseClient private const string DirectoryInfoPattern = @"D(?\d{4}) (?\d+) (?.+)"; private const string TimestampPattern = @"T(?\d+) 0 (?\d+) 0"; -#if NET7_0_OR_GREATER +#if NET private static readonly Regex FileInfoRegex = GetFileInfoRegex(); private static readonly Regex DirectoryInfoRegex = GetDirectoryInfoRegex(); private static readonly Regex TimestampRegex = GetTimestampRegex(); @@ -670,7 +670,7 @@ private string ReadString(Stream stream) /// The file or directory to upload. private void UploadTimes(IChannelSession channel, Stream input, FileSystemInfo fileOrDirectory) { -#if NET ||NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 var zeroTime = DateTime.UnixEpoch; #else var zeroTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); @@ -851,7 +851,7 @@ private void InternalDownload(IChannelSession channel, Stream input, FileSystemI var mtime = long.Parse(match.Result("${mtime}"), CultureInfo.InvariantCulture); var atime = long.Parse(match.Result("${atime}"), CultureInfo.InvariantCulture); -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 var zeroTime = DateTime.UnixEpoch; #else var zeroTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs index e92b66d13..e0963dff2 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs @@ -31,7 +31,7 @@ public AesCipher(byte[] key, byte[] iv, AesCipherMode mode, bool pkcs7Padding = // OFB is not supported on modern .NET _impl = new BlockImpl(key, new OfbCipherMode(iv), pkcs7Padding ? new Pkcs7Padding() : null); } -#if !NET6_0_OR_GREATER +#if !NET else if (mode == AesCipherMode.CFB) { // CFB not supported on NetStandard 2.1 diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs index 4ed11cf51..de174d673 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if NET using System; using System.Security.Cryptography; @@ -16,11 +16,7 @@ private sealed class BclImpl : Impl public BclImpl(byte[] key, byte[] nonce) { -#if NET8_0_OR_GREATER _aesGcm = new AesGcm(key, TagSizeInBytes); -#else - _aesGcm = new AesGcm(key); -#endif _nonce = nonce; } @@ -37,21 +33,15 @@ public override void Encrypt(byte[] input, int plainTextOffset, int plainTextLen public override void Decrypt(byte[] input, int cipherTextOffset, int cipherTextLength, int associatedDataOffset, int associatedDataLength, byte[] output, int plainTextOffset) { - var plainTextLength = cipherTextLength; var cipherText = new ReadOnlySpan(input, cipherTextOffset, cipherTextLength); var tag = new ReadOnlySpan(input, cipherTextOffset + cipherTextLength, TagSizeInBytes); - var plainText = new Span(output, plainTextOffset, plainTextLength); var associatedData = new ReadOnlySpan(input, associatedDataOffset, associatedDataLength); try { - _aesGcm.Decrypt(_nonce, cipherText, tag, output, associatedData); + _aesGcm.Decrypt(_nonce, cipherText, tag, output.AsSpan(plainTextOffset), associatedData); } -#if NET8_0_OR_GREATER catch (AuthenticationTagMismatchException ex) -#else - catch (CryptographicException ex) -#endif { throw new SshConnectionException("MAC error", DisconnectReason.MacError, ex); } diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs index b40c2343f..820416bb2 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs @@ -15,7 +15,7 @@ internal sealed partial class AesGcmCipher : SymmetricCipher, IDisposable private const int TagSizeInBytes = 16; private readonly byte[] _iv; private readonly int _aadLength; -#if NET6_0_OR_GREATER +#if NET private readonly Impl _impl; #else private readonly BouncyCastleImpl _impl; @@ -62,7 +62,7 @@ public AesGcmCipher(byte[] key, byte[] iv, int aadLength) // SSH AES-GCM requires a 12-octet Initial IV _iv = iv.Take(12); _aadLength = aadLength; -#if NET6_0_OR_GREATER +#if NET if (System.Security.Cryptography.AesGcm.IsSupported) { _impl = new BclImpl(key, _iv); diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.BlockImpl.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.BlockImpl.cs index 53f9b56fd..592c5f795 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.BlockImpl.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.BlockImpl.cs @@ -1,4 +1,4 @@ -#if !NET6_0_OR_GREATER +#if !NET using System; using System.Security.Cryptography; diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs index 0a6aec5dc..59af932c2 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs @@ -1,7 +1,7 @@ using System; using System.Security.Cryptography; -#if !NET6_0_OR_GREATER +#if !NET using Org.BouncyCastle.Crypto.Paddings; using Renci.SshNet.Security.Cryptography.Ciphers.Modes; @@ -31,7 +31,7 @@ public sealed partial class TripleDesCipher : BlockCipher, IDisposable public TripleDesCipher(byte[] key, byte[] iv, System.Security.Cryptography.CipherMode mode, bool pkcs7Padding) : base(key, 8, mode: null, padding: null) { -#if !NET6_0_OR_GREATER +#if !NET if (mode == System.Security.Cryptography.CipherMode.CFB) { // CFB8 not supported on .NET Framework, but supported on .NET diff --git a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs index 36fbe5fe7..d6ebd0699 100644 --- a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs +++ b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs @@ -147,7 +147,7 @@ public override BigInteger[] Public Buffer.BlockCopy(qy, 0, q, qx.Length + 1, qy.Length); // returns Curve-Name and x/y as ECPoint -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1 || NET return new[] { curve, new BigInteger(q, isBigEndian: true) }; #else return new[] { curve, new BigInteger(q.Reverse()) }; diff --git a/src/Renci.SshNet/Security/KeyExchangeECDH.BclImpl.cs b/src/Renci.SshNet/Security/KeyExchangeECDH.BclImpl.cs index 7c1a5fb51..0cd1dd346 100644 --- a/src/Renci.SshNet/Security/KeyExchangeECDH.BclImpl.cs +++ b/src/Renci.SshNet/Security/KeyExchangeECDH.BclImpl.cs @@ -1,4 +1,4 @@ -#if NET8_0_OR_GREATER +#if NET using System; using System.Security.Cryptography; diff --git a/src/Renci.SshNet/Security/KeyExchangeECDH.cs b/src/Renci.SshNet/Security/KeyExchangeECDH.cs index 7ce0e40eb..35ef3b5c0 100644 --- a/src/Renci.SshNet/Security/KeyExchangeECDH.cs +++ b/src/Renci.SshNet/Security/KeyExchangeECDH.cs @@ -9,7 +9,7 @@ namespace Renci.SshNet.Security { internal abstract partial class KeyExchangeECDH : KeyExchangeEC { -#if NET8_0_OR_GREATER +#if NET private Impl _impl; /// @@ -40,7 +40,7 @@ public override void Start(Session session, KeyExchangeInitMessage message, bool Session.KeyExchangeEcdhReplyMessageReceived += Session_KeyExchangeEcdhReplyMessageReceived; -#if NET8_0_OR_GREATER +#if NET if (!OperatingSystem.IsWindows() || OperatingSystem.IsWindowsVersionAtLeast(10)) { _impl = new BclImpl(Curve); diff --git a/src/Renci.SshNet/Security/KeyExchangeECDH256.cs b/src/Renci.SshNet/Security/KeyExchangeECDH256.cs index 2a3be0af8..1272ec9f4 100644 --- a/src/Renci.SshNet/Security/KeyExchangeECDH256.cs +++ b/src/Renci.SshNet/Security/KeyExchangeECDH256.cs @@ -15,7 +15,7 @@ public override string Name get { return "ecdh-sha2-nistp256"; } } -#if NET8_0_OR_GREATER +#if NET /// /// Gets the curve. /// diff --git a/src/Renci.SshNet/Security/KeyExchangeECDH384.cs b/src/Renci.SshNet/Security/KeyExchangeECDH384.cs index b9d440f7d..0bd964707 100644 --- a/src/Renci.SshNet/Security/KeyExchangeECDH384.cs +++ b/src/Renci.SshNet/Security/KeyExchangeECDH384.cs @@ -15,7 +15,7 @@ public override string Name get { return "ecdh-sha2-nistp384"; } } -#if NET8_0_OR_GREATER +#if NET /// /// Gets the curve. /// diff --git a/src/Renci.SshNet/Security/KeyExchangeECDH521.cs b/src/Renci.SshNet/Security/KeyExchangeECDH521.cs index 07d993cee..a73eedd6e 100644 --- a/src/Renci.SshNet/Security/KeyExchangeECDH521.cs +++ b/src/Renci.SshNet/Security/KeyExchangeECDH521.cs @@ -15,7 +15,7 @@ public override string Name get { return "ecdh-sha2-nistp521"; } } -#if NET8_0_OR_GREATER +#if NET /// /// Gets the curve. /// diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index 8f7ffae6d..c5356db8e 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -1326,7 +1326,7 @@ private Message ReceiveMessage(Socket socket) if (_serverMac != null && _serverEtm) { var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength); -#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER +#if NETSTANDARD2_1 || NET if (!CryptographicOperations.FixedTimeEquals(clientHash, new ReadOnlySpan(data, data.Length - serverMacLength, serverMacLength))) #else if (!Org.BouncyCastle.Utilities.Arrays.FixedTimeEquals(serverMacLength, clientHash, 0, data, data.Length - serverMacLength)) @@ -1354,7 +1354,7 @@ private Message ReceiveMessage(Socket socket) if (_serverMac != null && !_serverEtm) { var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength); -#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER +#if NETSTANDARD2_1 || NET if (!CryptographicOperations.FixedTimeEquals(clientHash, new ReadOnlySpan(data, data.Length - serverMacLength, serverMacLength))) #else if (!Org.BouncyCastle.Utilities.Arrays.FixedTimeEquals(serverMacLength, clientHash, 0, data, data.Length - serverMacLength)) diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs index 8ef5d960d..06f44f98d 100644 --- a/src/Renci.SshNet/Sftp/SftpFileStream.cs +++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs @@ -515,7 +515,7 @@ public override int Read(byte[] buffer, int offset, int count) ThrowHelper.ThrowIfNull(buffer); -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(offset); ArgumentOutOfRangeException.ThrowIfNegative(count); #else @@ -657,7 +657,7 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count, ThrowHelper.ThrowIfNull(buffer); -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(offset); ArgumentOutOfRangeException.ThrowIfNegative(count); #else @@ -952,7 +952,7 @@ public override long Seek(long offset, SeekOrigin origin) /// public override void SetLength(long value) { -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(value); #else if (value < 0) @@ -1007,7 +1007,7 @@ public override void Write(byte[] buffer, int offset, int count) { ThrowHelper.ThrowIfNull(buffer); -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(offset); ArgumentOutOfRangeException.ThrowIfNegative(count); #else @@ -1107,7 +1107,7 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc { ThrowHelper.ThrowIfNull(buffer); -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(offset); ArgumentOutOfRangeException.ThrowIfNegative(count); #else diff --git a/src/Renci.SshNet/Sftp/SftpSession.cs b/src/Renci.SshNet/Sftp/SftpSession.cs index f96b6d306..de83bd887 100644 --- a/src/Renci.SshNet/Sftp/SftpSession.cs +++ b/src/Renci.SshNet/Sftp/SftpSession.cs @@ -135,22 +135,22 @@ public string GetCanonicalPath(string path) if (fullPath.EndsWith("/.", StringComparison.OrdinalIgnoreCase) || fullPath.EndsWith("/..", StringComparison.OrdinalIgnoreCase) || fullPath.Equals("/", StringComparison.OrdinalIgnoreCase) || -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 fullPath.IndexOf('/', StringComparison.OrdinalIgnoreCase) < 0) #else fullPath.IndexOf('/') < 0) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { return fullPath; } var pathParts = fullPath.Split('/'); -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 var partialFullPath = string.Join('/', pathParts, 0, pathParts.Length - 1); #else var partialFullPath = string.Join("/", pathParts, 0, pathParts.Length - 1); -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif if (string.IsNullOrEmpty(partialFullPath)) { @@ -206,22 +206,22 @@ public async Task GetCanonicalPathAsync(string path, CancellationToken c if (fullPath.EndsWith("/.", StringComparison.Ordinal) || fullPath.EndsWith("/..", StringComparison.Ordinal) || fullPath.Equals("/", StringComparison.Ordinal) || -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 fullPath.IndexOf('/', StringComparison.Ordinal) < 0) #else fullPath.IndexOf('/') < 0) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { return fullPath; } var pathParts = fullPath.Split('/'); -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 var partialFullPath = string.Join('/', pathParts); #else var partialFullPath = string.Join("/", pathParts); -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif if (string.IsNullOrEmpty(partialFullPath)) { diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs index 4a5d7dbe7..7cf5e62a3 100644 --- a/src/Renci.SshNet/SftpClient.cs +++ b/src/Renci.SshNet/SftpClient.cs @@ -2336,11 +2336,11 @@ private List InternalListDirectory(string path, SftpListDirectoryAsyn var basePath = fullPath; -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1 if (!basePath.EndsWith('/')) #else if (!basePath.EndsWith("/", StringComparison.Ordinal)) -#endif // NET || NETSTANDARD2_1_OR_GREATER +#endif { basePath = string.Format("{0}/", fullPath); } diff --git a/src/Renci.SshNet/Shell.cs b/src/Renci.SshNet/Shell.cs index c38cac83c..fe43d491b 100644 --- a/src/Renci.SshNet/Shell.cs +++ b/src/Renci.SshNet/Shell.cs @@ -118,7 +118,7 @@ private Shell(ISession session, Stream input, Stream output, Stream extendedOutp { bufferSize = DefaultBufferSize; } -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegativeOrZero(bufferSize); #else if (bufferSize <= 0) diff --git a/src/Renci.SshNet/ShellStream.cs b/src/Renci.SshNet/ShellStream.cs index 40325a0bb..55bbec864 100644 --- a/src/Renci.SshNet/ShellStream.cs +++ b/src/Renci.SshNet/ShellStream.cs @@ -160,7 +160,7 @@ private ShellStream(ISession session, int bufferSize, bool noTerminal) { bufferSize = DefaultBufferSize; } -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegativeOrZero(bufferSize); #else if (bufferSize <= 0) @@ -481,7 +481,7 @@ public void Expect(TimeSpan timeout, int lookback, params ExpectAction[] expectA foreach (var expectAction in expectActions) { -#if NET7_0_OR_GREATER +#if NET var matchEnumerator = expectAction.Expect.EnumerateMatches(bufferText.AsSpan(searchStart)); if (matchEnumerator.MoveNext()) diff --git a/test/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs b/test/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs index 3109ea26b..60519ef2e 100644 --- a/test/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs +++ b/test/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs @@ -19,7 +19,7 @@ private static KeyHostAlgorithm GetKeyHostAlgorithm() { using (var s = typeof(HostKeyEventArgsBenchmarks).Assembly.GetManifestResourceStream("Renci.SshNet.Benchmarks.Data.Key.RSA.txt")) { - var privateKey = new PrivateKeyFile(s); + var privateKey = new PrivateKeyFile(s!); return (KeyHostAlgorithm)privateKey.HostKeyAlgorithms.First(); } } diff --git a/test/Renci.SshNet.Benchmarks/Security/Cryptography/ED25519DigitalSignatureBenchmarks.cs b/test/Renci.SshNet.Benchmarks/Security/Cryptography/ED25519DigitalSignatureBenchmarks.cs index eb390155d..52a3d272d 100644 --- a/test/Renci.SshNet.Benchmarks/Security/Cryptography/ED25519DigitalSignatureBenchmarks.cs +++ b/test/Renci.SshNet.Benchmarks/Security/Cryptography/ED25519DigitalSignatureBenchmarks.cs @@ -21,7 +21,7 @@ public ED25519DigitalSignatureBenchmarks() using (var s = typeof(ED25519DigitalSignatureBenchmarks).Assembly.GetManifestResourceStream("Renci.SshNet.Benchmarks.Data.Key.OPENSSH.ED25519.txt")) { - _key = (ED25519Key)new PrivateKeyFile(s).Key; + _key = (ED25519Key)new PrivateKeyFile(s!).Key; } _signature = new ED25519DigitalSignature(_key).Sign(_data); } diff --git a/test/Renci.SshNet.Benchmarks/Security/Cryptography/RsaDigitalSignatureBenchmarks.cs b/test/Renci.SshNet.Benchmarks/Security/Cryptography/RsaDigitalSignatureBenchmarks.cs index 9f5356694..fa864d8c3 100644 --- a/test/Renci.SshNet.Benchmarks/Security/Cryptography/RsaDigitalSignatureBenchmarks.cs +++ b/test/Renci.SshNet.Benchmarks/Security/Cryptography/RsaDigitalSignatureBenchmarks.cs @@ -23,7 +23,7 @@ public RsaDigitalSignatureBenchmarks() using (var s = typeof(RsaDigitalSignatureBenchmarks).Assembly.GetManifestResourceStream("Renci.SshNet.Benchmarks.Data.Key.OPENSSH.RSA.txt")) { - _key = (RsaKey)new PrivateKeyFile(s).Key; + _key = (RsaKey)new PrivateKeyFile(s!).Key; } _signature = new RsaDigitalSignature(_key, HashAlgorithmName.SHA256).Sign(_data); } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs index d13c92ddf..e0a0696bc 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs @@ -1,5 +1,5 @@ using System.Diagnostics; -#if !NET6_0_OR_GREATER +#if !NET using System.Net; #endif @@ -42,7 +42,7 @@ public void Test_PortForwarding_Local_Stop_Hangs_On_Wait() var url = "http://www.google.com/"; Debug.WriteLine("Starting web request to \"" + url + "\""); -#if NET6_0_OR_GREATER +#if NET var httpClient = new HttpClient(); var response = httpClient.GetAsync(url) .ConfigureAwait(false) @@ -51,7 +51,7 @@ public void Test_PortForwarding_Local_Stop_Hangs_On_Wait() #else var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); -#endif // NET6_0_OR_GREATER +#endif // NET Assert.IsNotNull(response); diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs index 0716280d3..20106a2c5 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs @@ -299,19 +299,12 @@ protected static string CalculateMD5(string fileName) { using (var file = new FileStream(fileName, FileMode.Open)) { -#if NET7_0_OR_GREATER +#if NET var hash = MD5.HashData(file); #else -#if NET6_0 - var md5 = MD5.Create(); -#else - MD5 md5 = new MD5CryptoServiceProvider(); -#endif // NET6_0 + using MD5 md5 = MD5.Create(); var hash = md5.ComputeHash(file); -#endif // NET7_0_OR_GREATER - - file.Close(); - +#endif var sb = new StringBuilder(); for (var i = 0; i < hash.Length; i++) diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs index 846d02fc4..2fbe6460b 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs @@ -54,7 +54,7 @@ public void Test_Sftp_ListDirectory_Current() } } -#if NET6_0_OR_GREATER +#if NET [TestMethod] [TestCategory("Sftp")] public async Task Test_Sftp_ListDirectoryAsync_Current() diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs index 8f355f96b..1993c2b2a 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -#if !NET8_0_OR_GREATER +#if !NET using Renci.SshNet.Abstractions; #endif using Renci.SshNet.Common; diff --git a/test/Renci.SshNet.IntegrationTests/Properties/AssemblyInfo.cs b/test/Renci.SshNet.IntegrationTests/Properties/AssemblyInfo.cs index a3ec2d895..886e59996 100644 --- a/test/Renci.SshNet.IntegrationTests/Properties/AssemblyInfo.cs +++ b/test/Renci.SshNet.IntegrationTests/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ -#if NET6_0_OR_GREATER +#if NET using System.Diagnostics.CodeAnalysis; [assembly: ExcludeFromCodeCoverage] -#endif // NET6_0_OR_GREATER +#endif // NET diff --git a/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs b/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs index d1d9df3bd..db464b18c 100644 --- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs +++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs @@ -6,7 +6,7 @@ using Moq; -#if !NET8_0_OR_GREATER +#if !NET using Renci.SshNet.Abstractions; #endif using Renci.SshNet.Common; diff --git a/test/Renci.SshNet.Tests/Classes/Common/PipeStreamTest.cs b/test/Renci.SshNet.Tests/Classes/Common/PipeStreamTest.cs index dd84c898a..5964a649a 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/PipeStreamTest.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/PipeStreamTest.cs @@ -4,7 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NET && !NETSTANDARD2_1_OR_GREATER +#if NETFRAMEWORK using Renci.SshNet.Abstractions; #endif using Renci.SshNet.Common; diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs index 791e3b3a2..e308cac18 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs @@ -8,7 +8,7 @@ using Moq; -#if !NET8_0_OR_GREATER +#if !NET using Renci.SshNet.Abstractions; #endif using Renci.SshNet.Channels; diff --git a/test/Renci.SshNet.Tests/Properties/AssemblyInfo.cs b/test/Renci.SshNet.Tests/Properties/AssemblyInfo.cs index a3ec2d895..886e59996 100644 --- a/test/Renci.SshNet.Tests/Properties/AssemblyInfo.cs +++ b/test/Renci.SshNet.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ -#if NET6_0_OR_GREATER +#if NET using System.Diagnostics.CodeAnalysis; [assembly: ExcludeFromCodeCoverage] -#endif // NET6_0_OR_GREATER +#endif // NET diff --git a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj index 2716f9447..1f8c5bcaa 100644 --- a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj +++ b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj @@ -1,7 +1,7 @@  - net462;net6.0;net8.0;net9.0 + net462;net8.0;net9.0