Skip to content

Commit 03e2821

Browse files
authored
Drop netstandard2.1 target (#1647)
1 parent a024b83 commit 03e2821

File tree

17 files changed

+32
-40
lines changed

17 files changed

+32
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ OpenSSH certificate authentication is supported for all of the above, e.g. ssh-e
176176

177177
**SSH.NET** supports the following target frameworks:
178178
* .NETFramework 4.6.2 (and higher)
179-
* .NET Standard 2.0 and 2.1
179+
* .NET Standard 2.0
180180
* .NET 8 (and higher)
181181

182182
## Building the library

src/Renci.SshNet/Abstractions/SocketExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ public static async Task ConnectAsync(this Socket socket, EndPoint remoteEndpoin
9393
{
9494
args.RemoteEndPoint = remoteEndpoint;
9595

96-
#if NETSTANDARD2_1
97-
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
98-
#else
9996
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
100-
#endif
10197
{
10298
await args.ExecuteAsync(socket.ConnectAsync);
10399
}
@@ -112,11 +108,7 @@ public static async Task<int> ReceiveAsync(this Socket socket, byte[] buffer, in
112108
{
113109
args.SetBuffer(buffer, offset, length);
114110

115-
#if NETSTANDARD2_1
116-
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
117-
#else
118111
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
119-
#endif
120112
{
121113
await args.ExecuteAsync(socket.ReceiveAsync);
122114
}

src/Renci.SshNet/Abstractions/StreamExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if !NET
22
using System;
33
using System.IO;
44
using System.Threading.Tasks;

src/Renci.SshNet/ClientAuthentication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private bool TryAuthenticate(ISession session,
105105
{
106106
authenticationException = new SshAuthenticationException(string.Format(CultureInfo.InvariantCulture,
107107
"No suitable authentication method found to complete authentication ({0}).",
108-
#if NET || NETSTANDARD2_1
108+
#if NET
109109
string.Join(',', allowedAuthenticationMethods)))
110110
#else
111111
string.Join(",", allowedAuthenticationMethods)))

src/Renci.SshNet/Common/Extensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal static ServiceName ToServiceName(this byte[] data)
5050

5151
internal static BigInteger ToBigInteger(this ReadOnlySpan<byte> data)
5252
{
53-
#if NETSTANDARD2_1 || NET
53+
#if NET
5454
return new BigInteger(data, isBigEndian: true);
5555
#else
5656
var reversed = data.ToArray();
@@ -61,7 +61,7 @@ internal static BigInteger ToBigInteger(this ReadOnlySpan<byte> data)
6161

6262
internal static BigInteger ToBigInteger(this byte[] data)
6363
{
64-
#if NETSTANDARD2_1 || NET
64+
#if NET
6565
return new BigInteger(data, isBigEndian: true);
6666
#else
6767
var reversed = new byte[data.Length];
@@ -76,7 +76,7 @@ internal static BigInteger ToBigInteger(this byte[] data)
7676
/// </summary>
7777
public static BigInteger ToBigInteger2(this byte[] data)
7878
{
79-
#if NETSTANDARD2_1 || NET
79+
#if NET
8080
return new BigInteger(data, isBigEndian: true, isUnsigned: true);
8181
#else
8282
if ((data[0] & (1 << 7)) != 0)
@@ -91,7 +91,7 @@ public static BigInteger ToBigInteger2(this byte[] data)
9191
#endif
9292
}
9393

94-
#if NETFRAMEWORK || NETSTANDARD2_0
94+
#if !NET
9595
public static byte[] ToByteArray(this BigInteger bigInt, bool isUnsigned = false, bool isBigEndian = false)
9696
{
9797
var data = bigInt.ToByteArray();
@@ -361,7 +361,7 @@ internal static string Join(this IEnumerable<string> values, string separator)
361361
return string.Join(separator, values);
362362
}
363363

364-
#if NETFRAMEWORK || NETSTANDARD2_0
364+
#if !NET
365365
internal static bool TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
366366
{
367367
if (!dictionary.ContainsKey(key))

src/Renci.SshNet/Common/PipeStream.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override int Read(byte[] buffer, int offset, int count)
5151
return Read(buffer.AsSpan(offset, count));
5252
}
5353

54-
#if NETSTANDARD2_1 || NET
54+
#if NET
5555
/// <inheritdoc/>
5656
public override int Read(Span<byte> buffer)
5757
#else
@@ -99,7 +99,7 @@ public override void Write(byte[] buffer, int offset, int count)
9999
}
100100
}
101101

102-
#if NETSTANDARD2_1 || NET
102+
#if NET
103103
/// <inheritdoc/>
104104
public override void Write(ReadOnlySpan<byte> buffer)
105105
{
@@ -157,7 +157,7 @@ public override Task WriteAsync(byte[] buffer, int offset, int count, Cancellati
157157
return WriteAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();
158158
}
159159

160-
#if NETSTANDARD2_1 || NET
160+
#if NET
161161
/// <inheritdoc/>
162162
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
163163
#else

src/Renci.SshNet/Common/SshData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ protected void Write(BigInteger data)
372372
/// <param name="data">name-list data to write.</param>
373373
protected void Write(string[] data)
374374
{
375-
#if NET || NETSTANDARD2_1
375+
#if NET
376376
Write(string.Join(',', data), Ascii);
377377
#else
378378
Write(string.Join(",", data), Ascii);

src/Renci.SshNet/Common/SshDataStream.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public bool IsEndOfData
5959
}
6060
}
6161

62-
#if NETFRAMEWORK || NETSTANDARD2_0
62+
#if !NET
6363
private void Write(ReadOnlySpan<byte> buffer)
6464
{
6565
var sharedBuffer = System.Buffers.ArrayPool<byte>.Shared.Rent(buffer.Length);
@@ -129,7 +129,7 @@ public void Write(string s, Encoding encoding)
129129
ThrowHelper.ThrowIfNull(s);
130130
ThrowHelper.ThrowIfNull(encoding);
131131

132-
#if NETSTANDARD2_1 || NET
132+
#if NET
133133
ReadOnlySpan<char> value = s;
134134
var count = encoding.GetByteCount(value);
135135
var bytes = count <= 256 ? stackalloc byte[count] : new byte[count];
@@ -220,7 +220,7 @@ public void WriteBinary(byte[] buffer, int offset, int count)
220220
/// </returns>
221221
public BigInteger ReadBigInt()
222222
{
223-
#if NETSTANDARD2_1 || NET
223+
#if NET
224224
var data = ReadBinarySegment();
225225
return new BigInteger(data, isBigEndian: true);
226226
#else

src/Renci.SshNet/Connection/ProxyConnector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ protected ProxyConnector(ISocketFactory socketFactory)
2121

2222
// ToDo: Performs async/sync fallback, true async version should be implemented in derived classes
2323
protected virtual
24-
#if NET || NETSTANDARD2_1
24+
#if NET
2525
async
2626
#endif
2727
Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, Socket socket, CancellationToken cancellationToken)
2828
{
2929
cancellationToken.ThrowIfCancellationRequested();
3030

31-
#if NET || NETSTANDARD2_1
31+
#if NET
3232
await using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
3333
#else
3434
using (cancellationToken.Register(o => ((Socket)o).Dispose(), socket, useSynchronizationContext: false))
@@ -39,7 +39,7 @@ Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, Socket socket, Canc
3939
#pragma warning restore MA0042 // Do not use blocking calls in an async method
4040
}
4141

42-
#if !NET && !NETSTANDARD2_1
42+
#if !NET
4343
return Task.CompletedTask;
4444
#endif
4545
}

src/Renci.SshNet/Messages/Authentication/FailureMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected override void LoadData()
5555
PartialSuccess = ReadBoolean();
5656
if (PartialSuccess)
5757
{
58-
#if NET || NETSTANDARD2_1
58+
#if NET
5959
Message = string.Join(',', AllowedAuthentications);
6060
#else
6161
Message = string.Join(",", AllowedAuthentications);

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AssemblyName>Renci.SshNet</AssemblyName>
55
<Product>SSH.NET</Product>
66
<AssemblyTitle>SSH.NET</AssemblyTitle>
7-
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks>
7+
<TargetFrameworks>net462;netstandard2.0;net8.0;net9.0</TargetFrameworks>
88
</PropertyGroup>
99

1010
<PropertyGroup>

src/Renci.SshNet/ScpClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ private string ReadString(Stream stream)
670670
/// <param name="fileOrDirectory">The file or directory to upload.</param>
671671
private void UploadTimes(IChannelSession channel, Stream input, FileSystemInfo fileOrDirectory)
672672
{
673-
#if NET || NETSTANDARD2_1
673+
#if NET
674674
var zeroTime = DateTime.UnixEpoch;
675675
#else
676676
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
851851
var mtime = long.Parse(match.Result("${mtime}"), CultureInfo.InvariantCulture);
852852
var atime = long.Parse(match.Result("${atime}"), CultureInfo.InvariantCulture);
853853

854-
#if NET || NETSTANDARD2_1
854+
#if NET
855855
var zeroTime = DateTime.UnixEpoch;
856856
#else
857857
var zeroTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public override BigInteger[] Public
147147
Buffer.BlockCopy(qy, 0, q, qx.Length + 1, qy.Length);
148148

149149
// returns Curve-Name and x/y as ECPoint
150-
#if NETSTANDARD2_1 || NET
150+
#if NET
151151
return new[] { curve, new BigInteger(q, isBigEndian: true) };
152152
#else
153153
Array.Reverse(q);

src/Renci.SshNet/Session.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ private Message ReceiveMessage(Socket socket)
13261326
if (_serverMac != null && _serverEtm)
13271327
{
13281328
var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength);
1329-
#if NETSTANDARD2_1 || NET
1329+
#if NET
13301330
if (!CryptographicOperations.FixedTimeEquals(clientHash, new ReadOnlySpan<byte>(data, data.Length - serverMacLength, serverMacLength)))
13311331
#else
13321332
if (!Org.BouncyCastle.Utilities.Arrays.FixedTimeEquals(serverMacLength, clientHash, 0, data, data.Length - serverMacLength))
@@ -1354,7 +1354,7 @@ private Message ReceiveMessage(Socket socket)
13541354
if (_serverMac != null && !_serverEtm)
13551355
{
13561356
var clientHash = _serverMac.ComputeHash(data, 0, data.Length - serverMacLength);
1357-
#if NETSTANDARD2_1 || NET
1357+
#if NET
13581358
if (!CryptographicOperations.FixedTimeEquals(clientHash, new ReadOnlySpan<byte>(data, data.Length - serverMacLength, serverMacLength)))
13591359
#else
13601360
if (!Org.BouncyCastle.Utilities.Arrays.FixedTimeEquals(serverMacLength, clientHash, 0, data, data.Length - serverMacLength))

src/Renci.SshNet/Sftp/SftpSession.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public string GetCanonicalPath(string path)
136136
if (fullPath.EndsWith("/.", StringComparison.OrdinalIgnoreCase) ||
137137
fullPath.EndsWith("/..", StringComparison.OrdinalIgnoreCase) ||
138138
fullPath.Equals("/", StringComparison.OrdinalIgnoreCase) ||
139-
#if NET || NETSTANDARD2_1
139+
#if NET
140140
fullPath.IndexOf('/', StringComparison.OrdinalIgnoreCase) < 0)
141141
#else
142142
fullPath.IndexOf('/') < 0)
@@ -147,7 +147,7 @@ public string GetCanonicalPath(string path)
147147

148148
var pathParts = fullPath.Split('/');
149149

150-
#if NET || NETSTANDARD2_1
150+
#if NET
151151
var partialFullPath = string.Join('/', pathParts, 0, pathParts.Length - 1);
152152
#else
153153
var partialFullPath = string.Join("/", pathParts, 0, pathParts.Length - 1);
@@ -207,7 +207,7 @@ public async Task<string> GetCanonicalPathAsync(string path, CancellationToken c
207207
if (fullPath.EndsWith("/.", StringComparison.Ordinal) ||
208208
fullPath.EndsWith("/..", StringComparison.Ordinal) ||
209209
fullPath.Equals("/", StringComparison.Ordinal) ||
210-
#if NET || NETSTANDARD2_1
210+
#if NET
211211
fullPath.IndexOf('/', StringComparison.Ordinal) < 0)
212212
#else
213213
fullPath.IndexOf('/') < 0)
@@ -218,7 +218,7 @@ public async Task<string> GetCanonicalPathAsync(string path, CancellationToken c
218218

219219
var pathParts = fullPath.Split('/');
220220

221-
#if NET || NETSTANDARD2_1
221+
#if NET
222222
var partialFullPath = string.Join('/', pathParts);
223223
#else
224224
var partialFullPath = string.Join("/", pathParts);

src/Renci.SshNet/SftpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,7 @@ private List<ISftpFile> InternalListDirectory(string path, SftpListDirectoryAsyn
23102310

23112311
var basePath = fullPath;
23122312

2313-
#if NET || NETSTANDARD2_1
2313+
#if NET
23142314
if (!basePath.EndsWith('/'))
23152315
#else
23162316
if (!basePath.EndsWith("/", StringComparison.Ordinal))

src/Renci.SshNet/ShellStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public override int Read(byte[] buffer, int offset, int count)
781781
return Read(buffer.AsSpan(offset, count));
782782
}
783783

784-
#if NETSTANDARD2_1 || NET
784+
#if NET
785785
/// <inheritdoc/>
786786
public override int Read(Span<byte> buffer)
787787
#else
@@ -857,7 +857,7 @@ public override void Write(byte[] buffer, int offset, int count)
857857
Write(buffer.AsSpan(offset, count));
858858
}
859859

860-
#if NETSTANDARD2_1 || NET
860+
#if NET
861861
/// <inheritdoc/>
862862
public override void Write(ReadOnlySpan<byte> buffer)
863863
#else

0 commit comments

Comments
 (0)