Skip to content

Commit 2e6a245

Browse files
committed
Merge branch 'upstream-develop' into pr
2 parents 83adee1 + 4577899 commit 2e6a245

File tree

414 files changed

+5820
-4862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

414 files changed

+5820
-4862
lines changed

.editorconfig_soon renamed to .editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,11 @@ dotnet_diagnostic.IDE0045.severity = none
535535
# Configured using 'dotnet_style_prefer_conditional_expression_over_return'
536536
dotnet_diagnostic.IDE0046.severity = suggestion
537537

538+
# IDE0047: Remove unnecessary parentheses
539+
#
540+
# Removing "unnecessary" parentheses is not always a clear win for readability.
541+
dotnet_diagnostic.IDE0047.severity = suggestion
542+
538543
# IDE0055: Fix formatting
539544
#
540545
# When enabled, diagnostics are reported for indented object initializers.
@@ -547,6 +552,12 @@ dotnet_diagnostic.IDE0046.severity = suggestion
547552
# There are no settings to configure this correctly, unless https://github.com/dotnet/roslyn/issues/63256 (or similar) is ever implemented.
548553
dotnet_diagnostic.IDE0055.severity = none
549554

555+
# IDE0130: Namespace does not match folder structure
556+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
557+
#
558+
# TODO: Remove when https://github.com/sshnet/SSH.NET/issues/1129 is fixed
559+
dotnet_diagnostic.IDE0130.severity = none
560+
550561
# IDE0270: Null check can be simplified
551562
#
552563
# var inputPath = originalDossierPathList.Find(x => x.id == updatedPath.id);

Directory.Build.props

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)src\Renci.SshNet.snk</AssemblyOriginatorKeyFile>
1010
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1111
<LangVersion>latest</LangVersion>
12-
<!--
1312
<WarningLevel>9999</WarningLevel>
1413
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
15-
-->
1614
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
1715
</PropertyGroup>
1816

@@ -39,10 +37,8 @@
3937
<!--
4038
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview1.23165.1" PrivateAssets="all" />
4139
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all" />
42-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.52" PrivateAssets="all" />
43-
-->
44-
<!--
40+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.54" PrivateAssets="all" />
4541
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544" PrivateAssets="all" />
46-
-->
42+
-->
4743
</ItemGroup>
4844
</Project>

src/Renci.SshNet.Tests/.editorconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[*.cs]
2+
3+
#### SYSLIB diagnostics ####
4+
5+
# SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time
6+
#
7+
# TODO: Remove this when https://github.com/sshnet/SSH.NET/issues/1131 is implemented.
8+
dotnet_diagnostic.SYSLIB1045.severity = none
9+
10+
### StyleCop Analyzers rules ###
11+
12+
#### .NET Compiler Platform analysers rules ####
13+
14+
# IDE0007: Use var instead of explicit type
15+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0007
16+
dotnet_diagnostic.IDE0007.severity = suggestion
17+
18+
# IDE0028: Use collection initializers
19+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0028
20+
dotnet_diagnostic.IDE0028.severity = suggestion
21+
22+
# IDE0058: Remove unnecessary expression value
23+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058
24+
dotnet_diagnostic.IDE0058.severity = suggestion
25+
26+
# IDE0059: Remove unnecessary value assignment
27+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059
28+
dotnet_diagnostic.IDE0059.severity = suggestion
29+
30+
# IDE0230: Use UTF-8 string literal
31+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0230
32+
dotnet_diagnostic.IDE0230.severity = suggestion

src/Renci.SshNet.Tests/Classes/BaseClientTestBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace Renci.SshNet.Tests.Classes
66
{
77
public abstract class BaseClientTestBase : TripleATestBase
88
{
9-
internal Mock<IServiceFactory> _serviceFactoryMock { get; private set; }
10-
internal Mock<ISocketFactory> _socketFactoryMock { get; private set; }
11-
internal Mock<ISession> _sessionMock { get; private set; }
9+
internal Mock<IServiceFactory> ServiceFactoryMock { get; private set; }
10+
internal Mock<ISocketFactory> SocketFactoryMock { get; private set; }
11+
internal Mock<ISession> SessionMock { get; private set; }
1212

1313
protected virtual void CreateMocks()
1414
{
15-
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
16-
_socketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
17-
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
15+
ServiceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
16+
SocketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
17+
SessionMock = new Mock<ISession>(MockBehavior.Strict);
1818
}
1919

2020
protected virtual void SetupData()

src/Renci.SshNet.Tests/Classes/BaseClientTest_Connect_OnConnectedThrowsException.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ protected override void SetupData()
2424

2525
protected override void SetupMocks()
2626
{
27-
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
28-
.Returns(_socketFactoryMock.Object);
29-
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
30-
.Returns(_sessionMock.Object);
31-
_sessionMock.Setup(p => p.Connect());
32-
_sessionMock.Setup(p => p.Dispose());
27+
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
28+
.Returns(SocketFactoryMock.Object);
29+
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
30+
.Returns(SessionMock.Object);
31+
SessionMock.Setup(p => p.Connect());
32+
SessionMock.Setup(p => p.Dispose());
3333
}
3434

3535
protected override void TearDown()
3636
{
3737
if (_client != null)
3838
{
39-
_sessionMock.Setup(p => p.OnDisconnecting());
40-
_sessionMock.Setup(p => p.Dispose());
39+
SessionMock.Setup(p => p.OnDisconnecting());
40+
SessionMock.Setup(p => p.Dispose());
4141
_client.Dispose();
4242
}
4343
}
@@ -46,7 +46,7 @@ protected override void Arrange()
4646
{
4747
base.Arrange();
4848

49-
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object)
49+
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object)
5050
{
5151
OnConnectedException = _onConnectException
5252
};
@@ -75,26 +75,26 @@ public void ConnectShouldRethrowExceptionThrownByOnConnect()
7575
[TestMethod]
7676
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
7777
{
78-
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
78+
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
7979
}
8080

8181
[TestMethod]
8282
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
8383
{
84-
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
84+
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
8585
Times.Once);
8686
}
8787

8888
[TestMethod]
8989
public void ConnectOnSessionShouldBeInvokedOnce()
9090
{
91-
_sessionMock.Verify(p => p.Connect(), Times.Once);
91+
SessionMock.Verify(p => p.Connect(), Times.Once);
9292
}
9393

9494
[TestMethod]
9595
public void DisposeOnSessionShouldBeInvokedOnce()
9696
{
97-
_sessionMock.Verify(p => p.Dispose(), Times.Once);
97+
SessionMock.Verify(p => p.Dispose(), Times.Once);
9898
}
9999

100100
[TestMethod]
@@ -104,7 +104,7 @@ public void ErrorOccuredOnSessionShouldNoLongerBeSignaledViaErrorOccurredOnBaseC
104104

105105
_client.ErrorOccurred += (sender, args) => Interlocked.Increment(ref errorOccurredSignalCount);
106106

107-
_sessionMock.Raise(p => p.ErrorOccured += null, new ExceptionEventArgs(new Exception()));
107+
SessionMock.Raise(p => p.ErrorOccured += null, new ExceptionEventArgs(new Exception()));
108108

109109
Assert.AreEqual(0, errorOccurredSignalCount);
110110
}
@@ -116,7 +116,7 @@ public void HostKeyReceivedOnSessionShouldNoLongerBeSignaledViaHostKeyReceivedOn
116116

117117
_client.HostKeyReceived += (sender, args) => Interlocked.Increment(ref hostKeyReceivedSignalCount);
118118

119-
_sessionMock.Raise(p => p.HostKeyReceived += null, new HostKeyEventArgs(GetKeyHostAlgorithm()));
119+
SessionMock.Raise(p => p.HostKeyReceived += null, new HostKeyEventArgs(GetKeyHostAlgorithm()));
120120

121121
Assert.AreEqual(0, hostKeyReceivedSignalCount);
122122
}

src/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NegativeOne.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Threading;
3+
34
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
46
using Moq;
5-
using Renci.SshNet.Connection;
7+
68
using Renci.SshNet.Messages.Transport;
79

810
namespace Renci.SshNet.Tests.Classes
@@ -24,22 +26,23 @@ protected override void SetupData()
2426

2527
protected override void SetupMocks()
2628
{
27-
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
28-
.Returns(_socketFactoryMock.Object);
29-
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
30-
.Returns(_sessionMock.Object);
31-
_sessionMock.Setup(p => p.Connect());
32-
_sessionMock.Setup(p => p.IsConnected).Returns(true);
33-
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
34-
.Returns(true)
35-
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
29+
_ = ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
30+
.Returns(SocketFactoryMock.Object);
31+
_ = ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
32+
.Returns(SessionMock.Object);
33+
_ = SessionMock.Setup(p => p.Connect());
34+
_ = SessionMock.Setup(p => p.IsConnected)
35+
.Returns(true);
36+
_ = SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
37+
.Returns(true)
38+
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
3639
}
3740

3841
protected override void Arrange()
3942
{
4043
base.Arrange();
4144

42-
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
45+
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
4346
_client.Connect();
4447
_client.KeepAliveInterval = _keepAliveInterval;
4548
}
@@ -48,8 +51,8 @@ protected override void TearDown()
4851
{
4952
if (_client != null)
5053
{
51-
_sessionMock.Setup(p => p.OnDisconnecting());
52-
_sessionMock.Setup(p => p.Dispose());
54+
SessionMock.Setup(p => p.OnDisconnecting());
55+
SessionMock.Setup(p => p.Dispose());
5356
_client.Dispose();
5457
}
5558
}
@@ -72,25 +75,25 @@ public void KeepAliveIntervalShouldReturnConfiguredValue()
7275
[TestMethod]
7376
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
7477
{
75-
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
78+
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
7679
}
7780

7881
[TestMethod]
7982
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
8083
{
81-
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object), Times.Once);
84+
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object), Times.Once);
8285
}
8386

8487
[TestMethod]
8588
public void ConnectOnSessionShouldBeInvokedOnce()
8689
{
87-
_sessionMock.Verify(p => p.Connect(), Times.Once);
90+
SessionMock.Verify(p => p.Connect(), Times.Once);
8891
}
8992

9093
[TestMethod]
9194
public void IsConnectedOnSessionShouldBeInvokedOnce()
9295
{
93-
_sessionMock.Verify(p => p.IsConnected, Times.Once);
96+
SessionMock.Verify(p => p.IsConnected, Times.Once);
9497
}
9598

9699
[TestMethod]
@@ -99,7 +102,7 @@ public void SendMessageOnSessionShouldBeInvokedOneTime()
99102
// allow keep-alive to be sent once
100103
Thread.Sleep(100);
101104

102-
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(1));
105+
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(1));
103106
}
104107

105108
private class MyClient : BaseClient

src/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NotNegativeOne.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ protected override void SetupData()
2323

2424
protected override void SetupMocks()
2525
{
26-
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
27-
.Returns(_socketFactoryMock.Object);
28-
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
29-
.Returns(_sessionMock.Object);
30-
_sessionMock.Setup(p => p.Connect());
31-
_sessionMock.Setup(p => p.IsConnected).Returns(true);
32-
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
26+
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
27+
.Returns(SocketFactoryMock.Object);
28+
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
29+
.Returns(SessionMock.Object);
30+
SessionMock.Setup(p => p.Connect());
31+
SessionMock.Setup(p => p.IsConnected).Returns(true);
32+
SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
3333
.Returns(true)
3434
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
3535
}
@@ -38,16 +38,16 @@ protected override void Arrange()
3838
{
3939
base.Arrange();
4040

41-
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
41+
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
4242
_client.Connect();
4343
}
4444

4545
protected override void TearDown()
4646
{
4747
if (_client != null)
4848
{
49-
_sessionMock.Setup(p => p.OnDisconnecting());
50-
_sessionMock.Setup(p => p.Dispose());
49+
SessionMock.Setup(p => p.OnDisconnecting());
50+
SessionMock.Setup(p => p.Dispose());
5151
_client.Dispose();
5252
}
5353
}
@@ -74,32 +74,32 @@ public void KeepAliveIntervalShouldReturnConfiguredValue()
7474
[TestMethod]
7575
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
7676
{
77-
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
77+
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
7878
}
7979

8080
[TestMethod]
8181
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
8282
{
83-
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
83+
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
8484
Times.Once);
8585
}
8686

8787
[TestMethod]
8888
public void ConnectOnSessionShouldBeInvokedOnce()
8989
{
90-
_sessionMock.Verify(p => p.Connect(), Times.Once);
90+
SessionMock.Verify(p => p.Connect(), Times.Once);
9191
}
9292

9393
[TestMethod]
9494
public void IsConnectedOnSessionShouldBeInvokedOnce()
9595
{
96-
_sessionMock.Verify(p => p.IsConnected, Times.Once);
96+
SessionMock.Verify(p => p.IsConnected, Times.Once);
9797
}
9898

9999
[TestMethod]
100100
public void SendMessageOnSessionShouldBeInvokedThreeTimes()
101101
{
102-
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3));
102+
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3));
103103
}
104104

105105
private class MyClient : BaseClient

0 commit comments

Comments
 (0)