Skip to content

Commit ee25d61

Browse files
committed
Merge branch 'develop' into logging
2 parents bf0c45c + 752b1db commit ee25d61

File tree

16 files changed

+57
-28
lines changed

16 files changed

+57
-28
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ dotnet_diagnostic.S2971.severity = none
195195
# This is rather harmless.
196196
dotnet_diagnostic.S3218.severity = none
197197

198+
# S3236: Remove this argument from the method call; it hides the caller information.
199+
dotnet_diagnostic.S3236.severity = none
200+
198201
# S3267: Loops should be simplified with "LINQ" expressions
199202
# https://rules.sonarsource.com/csharp/RSPEC-3267
200203
#

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ jobs:
1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v4
1919
with:
20-
dotnet-version: 8.0.x
20+
dotnet-version: 9.0.x
2121

2222
- name: Build Unit Tests .NET
23-
run: dotnet build -f net8.0 test/Renci.SshNet.Tests/
23+
run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
2424

2525
- name: Build IntegrationTests .NET
26-
run: dotnet build -f net8.0 test/Renci.SshNet.IntegrationTests/
26+
run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
2727

2828
- name: Build IntegrationTests .NET Framework
2929
run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/
3030

3131
- name: Run Unit Tests .NET
3232
run: |
3333
dotnet test \
34-
-f net8.0 \
34+
-f net9.0 \
3535
--no-build \
3636
--logger "console;verbosity=normal" \
3737
--logger GitHubActions \
3838
-p:CollectCoverage=true \
3939
-p:CoverletOutputFormat=cobertura \
40-
-p:CoverletOutput=../../coverlet/linux_unit_test_net_8_coverage.xml \
40+
-p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \
4141
test/Renci.SshNet.Tests/
4242
4343
- name: Run Integration Tests .NET
4444
run: |
4545
dotnet test \
46-
-f net8.0 \
46+
-f net9.0 \
4747
--no-build \
4848
--logger "console;verbosity=normal" \
4949
--logger GitHubActions \
5050
-p:CollectCoverage=true \
5151
-p:CoverletOutputFormat=cobertura \
52-
-p:CoverletOutput=../../coverlet/linux_integration_test_net_8_coverage.xml \
52+
-p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
5353
test/Renci.SshNet.IntegrationTests/
5454
5555
# Also run a subset of the integration tests targeting netfx using mono. This is a temporary measure to get
@@ -111,13 +111,13 @@ jobs:
111111
- name: Run Unit Tests .NET
112112
run: |
113113
dotnet test `
114-
-f net8.0 `
114+
-f net9.0 `
115115
--no-build `
116116
--logger "console;verbosity=normal" `
117117
--logger GitHubActions `
118118
-p:CollectCoverage=true `
119119
-p:CoverletOutputFormat=cobertura `
120-
-p:CoverletOutput=../../coverlet/windows_unit_test_net_8_coverage.xml `
120+
-p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml `
121121
test/Renci.SshNet.Tests/
122122
123123
- name: Run Unit Tests .NET Framework

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.100",
44
"rollForward": "latestMajor"
55
}
66
}

src/Renci.SshNet/Channels/Channel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Renci.SshNet.Channels
1515
/// </summary>
1616
internal abstract class Channel : IChannel
1717
{
18-
private readonly object _serverWindowSizeLock = new object();
19-
private readonly object _messagingLock = new object();
18+
private readonly Lock _serverWindowSizeLock = new Lock();
19+
private readonly Lock _messagingLock = new Lock();
2020
private readonly uint _initialWindowSize;
2121
private readonly ISession _session;
2222
private readonly ILogger _logger;

src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ namespace Renci.SshNet.Channels
1616
/// </summary>
1717
internal sealed class ChannelDirectTcpip : ClientChannel, IChannelDirectTcpip
1818
{
19-
private readonly object _socketLock = new object();
19+
private readonly Lock _socketLock = new Lock();
2020
private readonly ILogger _logger;
21-
2221
private EventWaitHandle _channelOpen = new AutoResetEvent(initialState: false);
2322
private EventWaitHandle _channelData = new AutoResetEvent(initialState: false);
2423
private IForwardedPort _forwardedPort;

src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
22
using System.Net;
33
using System.Net.Sockets;
4+
#if NET9_0_OR_GREATER
5+
using System.Threading;
6+
#endif
47

58
using Microsoft.Extensions.Logging;
69

@@ -15,7 +18,7 @@ namespace Renci.SshNet.Channels
1518
/// </summary>
1619
internal sealed class ChannelForwardedTcpip : ServerChannel, IChannelForwardedTcpip
1720
{
18-
private readonly object _socketShutdownAndCloseLock = new object();
21+
private readonly Lock _socketShutdownAndCloseLock = new Lock();
1922
private readonly ILogger _logger;
2023
private Socket _socket;
2124
private IForwardedPort _forwardedPort;

src/Renci.SshNet/Common/Lock.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#if !NET9_0_OR_GREATER
2+
using System.Threading;
3+
4+
namespace Renci.SshNet.Common
5+
{
6+
internal sealed class Lock
7+
{
8+
public bool TryEnter()
9+
{
10+
return Monitor.TryEnter(this);
11+
}
12+
13+
public void Exit()
14+
{
15+
Monitor.Exit(this);
16+
}
17+
}
18+
}
19+
#endif

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;net6.0;net7.0;net8.0</TargetFrameworks>
7+
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
88
</PropertyGroup>
99

1010
<PropertyGroup>

src/Renci.SshNet/Session.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class Session : ISession
8585
/// Holds an object that is used to ensure only a single thread can read from
8686
/// <see cref="_socket"/> at any given time.
8787
/// </summary>
88-
private readonly object _socketReadLock = new object();
88+
private readonly Lock _socketReadLock = new Lock();
8989

9090
/// <summary>
9191
/// Holds an object that is used to ensure only a single thread can write to
@@ -95,7 +95,7 @@ public class Session : ISession
9595
/// This is also used to ensure that <see cref="_outboundPacketSequence"/> is
9696
/// incremented atomatically.
9797
/// </remarks>
98-
private readonly object _socketWriteLock = new object();
98+
private readonly Lock _socketWriteLock = new Lock();
9999

100100
/// <summary>
101101
/// Holds an object that is used to ensure only a single thread can dispose
@@ -1911,7 +1911,7 @@ private bool IsSocketConnected()
19111911
return false;
19121912
}
19131913

1914-
if (!Monitor.TryEnter(_socketReadLock))
1914+
if (!_socketReadLock.TryEnter())
19151915
{
19161916
return true;
19171917
}
@@ -1923,7 +1923,7 @@ private bool IsSocketConnected()
19231923
}
19241924
finally
19251925
{
1926-
Monitor.Exit(_socketReadLock);
1926+
_socketReadLock.Exit();
19271927
}
19281928
}
19291929
finally

src/Renci.SshNet/Sftp/SftpFileStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Renci.SshNet.Sftp
1818
#pragma warning restore IDE0079
1919
public class SftpFileStream : Stream
2020
{
21-
private readonly object _lock = new object();
21+
private readonly Lock _lock = new Lock();
2222
private readonly int _readBufferSize;
2323
private readonly int _writeBufferSize;
2424

0 commit comments

Comments
 (0)