From a849350a99d9a8f0477ebce5f75a3703f809a076 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 2 Feb 2025 10:44:55 +0100 Subject: [PATCH 01/11] Drop net6.0 target --- Directory.Build.props | 2 +- .../Abstractions/CancellationTokenSourceExtensions.cs | 4 ++-- .../Abstractions/SocketAbstraction.Async.cs | 4 ++-- src/Renci.SshNet/Abstractions/SocketAbstraction.cs | 2 +- src/Renci.SshNet/Abstractions/SocketExtensions.cs | 2 +- src/Renci.SshNet/Common/Extensions.cs | 6 +++--- src/Renci.SshNet/Common/SshDataStream.cs | 4 ++-- src/Renci.SshNet/Common/TaskToAsyncResult.cs | 8 ++++---- src/Renci.SshNet/Common/ThrowHelper.cs | 8 ++++---- src/Renci.SshNet/Compression/Zlib.cs | 8 ++++---- src/Renci.SshNet/Connection/HttpConnector.cs | 2 +- .../Connection/ProtocolVersionExchange.cs | 6 +++--- src/Renci.SshNet/Netconf/NetConfSession.cs | 6 +++--- src/Renci.SshNet/PrivateKeyFile.cs | 2 +- src/Renci.SshNet/Renci.SshNet.csproj | 7 ++----- src/Renci.SshNet/ScpClient.cs | 2 +- .../Security/Cryptography/Ciphers/AesCipher.cs | 2 +- .../Cryptography/Ciphers/AesGcmCipher.BclImpl.cs | 6 +++--- .../Security/Cryptography/Ciphers/AesGcmCipher.cs | 4 ++-- .../Cryptography/Ciphers/TripleDesCipher.BlockImpl.cs | 2 +- .../Security/Cryptography/Ciphers/TripleDesCipher.cs | 4 ++-- src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs | 2 +- src/Renci.SshNet/Security/KeyExchangeECDH.BclImpl.cs | 2 +- src/Renci.SshNet/Security/KeyExchangeECDH.cs | 4 ++-- src/Renci.SshNet/Security/KeyExchangeECDH256.cs | 2 +- src/Renci.SshNet/Security/KeyExchangeECDH384.cs | 2 +- src/Renci.SshNet/Security/KeyExchangeECDH521.cs | 2 +- src/Renci.SshNet/Session.cs | 4 ++-- src/Renci.SshNet/Sftp/SftpFileStream.cs | 10 +++++----- src/Renci.SshNet/Shell.cs | 2 +- src/Renci.SshNet/ShellStream.cs | 4 ++-- .../OldIntegrationTests/ForwardedPortLocalTest.cs | 10 +++++----- .../OldIntegrationTests/ScpClientTest.cs | 11 +++-------- .../SftpClientTest.ListDirectory.cs | 2 +- .../OldIntegrationTests/SshCommandTest.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 ++-- .../Classes/BaseClientTest_ConnectAsync_Timeout.cs | 2 +- .../Classes/SftpClientTest_AsyncExceptions.cs | 2 +- test/Renci.SshNet.Tests/Properties/AssemblyInfo.cs | 4 ++-- test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj | 2 +- 40 files changed, 78 insertions(+), 86 deletions(-) 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/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..db3c778d4 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; diff --git a/src/Renci.SshNet/Common/Extensions.cs b/src/Renci.SshNet/Common/Extensions.cs index 2f3ae6ac0..9b41bb8f6 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_OR_GREATER || 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_OR_GREATER || 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/SshDataStream.cs b/src/Renci.SshNet/Common/SshDataStream.cs index d322dbad3..f892544f9 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_OR_GREATER || 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_OR_GREATER || 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..a39dd8a0c 100644 --- a/src/Renci.SshNet/Common/TaskToAsyncResult.cs +++ b/src/Renci.SshNet/Common/TaskToAsyncResult.cs @@ -1,5 +1,5 @@ #pragma warning disable -#if !NET8_0_OR_GREATER +#if !NET // Copied verbatim from https://github.com/dotnet/runtime/blob/78bd7debe6d8b454294c673c9cb969c6b8a14692/src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs // Licensed to the .NET Foundation under one or more agreements. @@ -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/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..69be301bb 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,11 +36,8 @@ true - - true - - + true true diff --git a/src/Renci.SshNet/ScpClient.cs b/src/Renci.SshNet/ScpClient.cs index 55b166d78..756e1a5da 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(); 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..0e2a1a41b 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,7 +16,7 @@ private sealed class BclImpl : Impl public BclImpl(byte[] key, byte[] nonce) { -#if NET8_0_OR_GREATER +#if NET _aesGcm = new AesGcm(key, TagSizeInBytes); #else _aesGcm = new AesGcm(key); @@ -47,7 +47,7 @@ public override void Decrypt(byte[] input, int cipherTextOffset, int cipherTextL { _aesGcm.Decrypt(_nonce, cipherText, tag, output, associatedData); } -#if NET8_0_OR_GREATER +#if NET catch (AuthenticationTagMismatchException ex) #else catch (CryptographicException 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..55c744f31 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_OR_GREATER || 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 a8bb707ae..35eee4135 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -1331,7 +1331,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_OR_GREATER || 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)) @@ -1359,7 +1359,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_OR_GREATER || 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/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.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs index f97345175..eb7f9ca2e 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); @@ -119,7 +119,7 @@ public void Test_PortForwarding_Local_Without_Connecting() { var start = DateTime.Now; -#if NET6_0_OR_GREATER +#if NET var httpClient = new HttpClient(); using (var response = httpClient.GetAsync("http://localhost:8084").GetAwaiter().GetResult()) { @@ -129,7 +129,7 @@ public void Test_PortForwarding_Local_Without_Connecting() using (var response = (HttpWebResponse)request.GetResponse()) { var data = ReadStream(response.GetResponseStream()); -#endif // NET6_0_OR_GREATER +#endif // NET var end = DateTime.Now; Debug.WriteLine(string.Format("Request# {2}: Lenght: {0} Time: {1}", data.Length, end - start, counter)); diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs index e9015a3c6..ef04fe4a1 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs @@ -299,17 +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 + MD5 md5 = MD5.Create(); var hash = md5.ComputeHash(file); -#endif // NET7_0_OR_GREATER - +#endif // #NET file.Close(); var sb = new StringBuilder(); diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs index a5660fa3c..ea8f5bfb5 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs @@ -68,7 +68,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/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 From b59da7c9cbf4a8fc56edc2e77db549a9be77219e Mon Sep 17 00:00:00 2001 From: mus65 Date: Sun, 2 Feb 2025 19:06:04 +0100 Subject: [PATCH 02/11] Update src/Renci.SshNet/Common/TaskToAsyncResult.cs Co-authored-by: Rob Hague --- src/Renci.SshNet/Common/TaskToAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Common/TaskToAsyncResult.cs b/src/Renci.SshNet/Common/TaskToAsyncResult.cs index a39dd8a0c..febeb6580 100644 --- a/src/Renci.SshNet/Common/TaskToAsyncResult.cs +++ b/src/Renci.SshNet/Common/TaskToAsyncResult.cs @@ -1,6 +1,6 @@ #pragma warning disable #if !NET -// Copied verbatim from https://github.com/dotnet/runtime/blob/78bd7debe6d8b454294c673c9cb969c6b8a14692/src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs +// 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. From a0bb44cec332184f7e2c3be6d3ced4ecdadfd7c2 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 2 Feb 2025 19:11:29 +0100 Subject: [PATCH 03/11] remove redundant #if for some reason this made the compiler suddenly realize that the plain text variables are unused. --- .../Cryptography/Ciphers/AesGcmCipher.BclImpl.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs index 0e2a1a41b..742925a63 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs @@ -16,11 +16,7 @@ private sealed class BclImpl : Impl public BclImpl(byte[] key, byte[] nonce) { -#if NET _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); } -#if NET catch (AuthenticationTagMismatchException ex) -#else - catch (CryptographicException ex) -#endif { throw new SshConnectionException("MAC error", DisconnectReason.MacError, ex); } From 076ede161d05a1418710c68ba7ecc647bc74ef5c Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 2 Feb 2025 19:39:38 +0100 Subject: [PATCH 04/11] use TargetFrameworkIdentifier this doesn't work in Directory.Build.props, moved it to Directory.Build.targets. --- Directory.Build.props | 7 ------- Directory.Build.targets | 8 ++++++++ Renci.SshNet.sln | 1 + src/Renci.SshNet/Renci.SshNet.csproj | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 Directory.Build.targets diff --git a/Directory.Build.props b/Directory.Build.props index 7c214d4b3..b2de734de 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,13 +28,6 @@ NU1901;NU1902;NU1903;NU1904 - - - $(NoWarn);CS8602;CS8604;CS8777 - - diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 000000000..59959cc55 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,8 @@ + + + + $(NoWarn);nullable + + diff --git a/Renci.SshNet.sln b/Renci.SshNet.sln index 5bfc241d8..ecfcf13a2 100644 --- a/Renci.SshNet.sln +++ b/Renci.SshNet.sln @@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution stylecop.json = stylecop.json THIRD-PARTY-NOTICES.TXT = THIRD-PARTY-NOTICES.TXT version.json = version.json + Directory.Build.targets = Directory.Build.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D21A4D03-0AC2-4613-BB6D-74D2D16A72CC}" diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 69be301bb..a428c1715 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -36,7 +36,7 @@ true - + true true From e059332bb2150c0dbf9542e637ee30b91b37717b Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sun, 2 Feb 2025 19:51:36 +0100 Subject: [PATCH 05/11] fix null reference warnings in Benchmarks seems like the warnings were (somehow) disabled here before and were fixed by the previous TargetFrameworkIdentifier change. --- .../Common/HostKeyEventArgsBenchmarks.cs | 2 +- .../Security/Cryptography/ED25519DigitalSignatureBenchmarks.cs | 2 +- .../Security/Cryptography/RsaDigitalSignatureBenchmarks.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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); } From 85cbbb5fcf0224fd4235acdfc7d244410531c676 Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Sun, 2 Feb 2025 20:55:16 +0100 Subject: [PATCH 06/11] fix unused plainTextOffset in AesGcmCipher.BclImpl --- .../Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs index 742925a63..de174d673 100644 --- a/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs +++ b/src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs @@ -39,7 +39,7 @@ public override void Decrypt(byte[] input, int cipherTextOffset, int cipherTextL try { - _aesGcm.Decrypt(_nonce, cipherText, tag, output, associatedData); + _aesGcm.Decrypt(_nonce, cipherText, tag, output.AsSpan(plainTextOffset), associatedData); } catch (AuthenticationTagMismatchException ex) { From 218a9a2d2e46ec0239aef179f00a1e9d9818fbe5 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Thu, 6 Feb 2025 19:42:37 +0100 Subject: [PATCH 07/11] CI retry From b6cdd7163b5974fd82a9ccbd16a8fe71852fbce6 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Mon, 17 Feb 2025 09:21:46 +0100 Subject: [PATCH 08/11] more cosmetics --- .../Abstractions/SocketExtensions.cs | 8 ++++---- .../Abstractions/StreamExtensions.cs | 6 ++---- src/Renci.SshNet/ClientAuthentication.cs | 4 ++-- src/Renci.SshNet/Common/Extensions.cs | 4 ++-- src/Renci.SshNet/Common/SshData.cs | 4 ++-- src/Renci.SshNet/Common/SshDataStream.cs | 4 ++-- src/Renci.SshNet/Connection/ProxyConnector.cs | 12 ++++++------ .../Messages/Authentication/FailureMessage.cs | 4 ++-- src/Renci.SshNet/ScpClient.cs | 4 ++-- .../Security/Cryptography/EcdsaKey.cs | 2 +- src/Renci.SshNet/Session.cs | 4 ++-- src/Renci.SshNet/Sftp/SftpSession.cs | 16 ++++++++-------- src/Renci.SshNet/SftpClient.cs | 4 ++-- .../OldIntegrationTests/ScpClientTest.cs | 6 ++---- .../Classes/Common/PipeStreamTest.cs | 2 +- 15 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/Renci.SshNet/Abstractions/SocketExtensions.cs b/src/Renci.SshNet/Abstractions/SocketExtensions.cs index db3c778d4..05d71d3de 100644 --- a/src/Renci.SshNet/Abstractions/SocketExtensions.cs +++ b/src/Renci.SshNet/Abstractions/SocketExtensions.cs @@ -93,11 +93,11 @@ public static async Task ConnectAsync(this Socket socket, EndPoint remoteEndpoin { args.RemoteEndPoint = remoteEndpoint; -#if NET || NETSTANDARD2_1_OR_GREATER +#if NET || 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 NET || 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 9b41bb8f6..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 || NET +#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 || NET +#if NETSTANDARD2_1 || NET return new BigInteger(data, isBigEndian: true, isUnsigned: true); #else if ((data[0] & (1 << 7)) != 0) 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 f892544f9..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 || NET +#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 || NET +#if NETSTANDARD2_1 || NET return new BigInteger(data, isBigEndian: true); #else return new BigInteger(data.Reverse()); 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/ScpClient.cs b/src/Renci.SshNet/ScpClient.cs index 756e1a5da..ce9fbffaf 100644 --- a/src/Renci.SshNet/ScpClient.cs +++ b/src/Renci.SshNet/ScpClient.cs @@ -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/EcdsaKey.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs index 55c744f31..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 || NET +#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/Session.cs b/src/Renci.SshNet/Session.cs index 35eee4135..507881e99 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -1331,7 +1331,7 @@ private Message ReceiveMessage(Socket socket) if (_serverMac != null && _serverEtm) { var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength); -#if NETSTANDARD2_1_OR_GREATER || NET +#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)) @@ -1359,7 +1359,7 @@ private Message ReceiveMessage(Socket socket) if (_serverMac != null && !_serverEtm) { var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength); -#if NETSTANDARD2_1_OR_GREATER || NET +#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/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/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs index d2b17203e..20106a2c5 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs @@ -302,11 +302,9 @@ protected static string CalculateMD5(string fileName) #if NET var hash = MD5.HashData(file); #else - MD5 md5 = MD5.Create(); + using MD5 md5 = MD5.Create(); var hash = md5.ComputeHash(file); -#endif // #NET - file.Close(); - +#endif var sb = new StringBuilder(); for (var i = 0; i < hash.Length; i++) 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; From f04f8db994a9cf473db26d52c79a08c9f9dd967e Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Mon, 17 Feb 2025 09:32:38 +0100 Subject: [PATCH 09/11] more --- src/Renci.SshNet/Abstractions/SocketExtensions.cs | 4 ++-- src/Renci.SshNet/Renci.SshNet.csproj | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Renci.SshNet/Abstractions/SocketExtensions.cs b/src/Renci.SshNet/Abstractions/SocketExtensions.cs index 05d71d3de..11c875643 100644 --- a/src/Renci.SshNet/Abstractions/SocketExtensions.cs +++ b/src/Renci.SshNet/Abstractions/SocketExtensions.cs @@ -93,7 +93,7 @@ public static async Task ConnectAsync(this Socket socket, EndPoint remoteEndpoin { args.RemoteEndPoint = remoteEndpoint; -#if NET || NETSTANDARD2_1 +#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)) @@ -112,7 +112,7 @@ public static async Task ReceiveAsync(this Socket socket, byte[] buffer, in { args.SetBuffer(buffer, offset, length); -#if NET || NETSTANDARD2_1 +#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)) diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index a428c1715..075b42af0 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -37,7 +37,6 @@ - true true From 799c8b671c040105d60c6b8ec995a287712398c2 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Wed, 19 Feb 2025 08:56:37 +0100 Subject: [PATCH 10/11] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 978d1133b8104a9d46c8565061b65eb4128e12f5 Mon Sep 17 00:00:00 2001 From: Robert Hague Date: Wed, 19 Feb 2025 12:45:39 +0100 Subject: [PATCH 11/11] Revert "use TargetFrameworkIdentifier" This reverts commit 076ede161d05a1418710c68ba7ecc647bc74ef5c. --- Directory.Build.props | 7 +++++++ Directory.Build.targets | 8 -------- Renci.SshNet.sln | 1 - src/Renci.SshNet/Renci.SshNet.csproj | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 Directory.Build.targets diff --git a/Directory.Build.props b/Directory.Build.props index b2de734de..7c214d4b3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,6 +28,13 @@ NU1901;NU1902;NU1903;NU1904 + + + $(NoWarn);CS8602;CS8604;CS8777 + + diff --git a/Directory.Build.targets b/Directory.Build.targets deleted file mode 100644 index 59959cc55..000000000 --- a/Directory.Build.targets +++ /dev/null @@ -1,8 +0,0 @@ - - - - $(NoWarn);nullable - - diff --git a/Renci.SshNet.sln b/Renci.SshNet.sln index 2e581250a..4a0a20538 100644 --- a/Renci.SshNet.sln +++ b/Renci.SshNet.sln @@ -21,7 +21,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution stylecop.json = stylecop.json THIRD-PARTY-NOTICES.TXT = THIRD-PARTY-NOTICES.TXT version.json = version.json - Directory.Build.targets = Directory.Build.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D21A4D03-0AC2-4613-BB6D-74D2D16A72CC}" diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 075b42af0..c6ab62f32 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -36,7 +36,7 @@ true - + true