Skip to content

Commit 8e5e1bd

Browse files
CopilotRob-Hague
andcommitted
Merge branch 'develop' into copilot/refactor-collection-assertions
Resolved conflicts by: - Adopting Assert.HasCount from develop (replacing Assert.AreEqual for length checks) - Keeping CollectionAssert.AreEqual for collection comparisons (our refactoring) Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com>
1 parent 2821526 commit 8e5e1bd

File tree

225 files changed

+642
-549
lines changed

Some content is hidden

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

225 files changed

+642
-549
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
test/Renci.SshNet.IntegrationTests/
4949
5050
- name: Archive Coverlet Results
51-
uses: actions/upload-artifact@v4
51+
uses: actions/upload-artifact@v5
5252
with:
5353
name: Coverlet Results Linux
5454
path: coverlet
@@ -74,7 +74,7 @@ jobs:
7474
run: dotnet pack
7575

7676
- name: Archive NuGet Package
77-
uses: actions/upload-artifact@v4
77+
uses: actions/upload-artifact@v5
7878
with:
7979
name: NuGet Package
8080
path: src/Renci.SshNet/bin/Release/*.*nupkg
@@ -140,7 +140,7 @@ jobs:
140140
test\Renci.SshNet.IntegrationTests\
141141

142142
- name: Archive Coverlet Results
143-
uses: actions/upload-artifact@v4
143+
uses: actions/upload-artifact@v5
144144
with:
145145
name: Coverlet Results Windows .NET Framework
146146
path: coverlet
@@ -182,7 +182,7 @@ jobs:
182182
test\Renci.SshNet.IntegrationTests\
183183

184184
- name: Archive Coverlet Results
185-
uses: actions/upload-artifact@v4
185+
uses: actions/upload-artifact@v5
186186
with:
187187
name: Coverlet Results Windows .NET
188188
path: coverlet
@@ -200,7 +200,7 @@ jobs:
200200
- Windows-Integration-Tests-Net
201201
steps:
202202
- name: Download NuGet Package
203-
uses: actions/download-artifact@v5
203+
uses: actions/download-artifact@v6
204204
with:
205205
name: NuGet Package
206206

@@ -229,7 +229,7 @@ jobs:
229229
- Windows-Integration-Tests-Net
230230
steps:
231231
- name: Download NuGet Package
232-
uses: actions/download-artifact@v5
232+
uses: actions/download-artifact@v6
233233
with:
234234
name: NuGet Package
235235

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
1212
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.220" />
1313
<!-- Should stay on LTS .NET releases. -->
14+
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="10.0.0" />
1415
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
1516
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
16-
<PackageVersion Include="MSTest" Version="3.9.3" />
17+
<PackageVersion Include="MSTest" Version="4.0.2" />
1718
<PackageVersion Include="Moq" Version="4.20.72" />
1819
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
1920
<PackageVersion Include="PolySharp" Version="1.15.0" />

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@
4949
</PackageReference>
5050
</ItemGroup>
5151

52-
<ItemGroup Condition=" !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0')) ">
52+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
53+
<PackageReference Include="Microsoft.Bcl.Cryptography" />
54+
</ItemGroup>
55+
56+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
5357
<PackageReference Include="System.Formats.Asn1" />
5458
</ItemGroup>
5559

src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET
1+
#if !NETSTANDARD
22
using System;
33
using System.Security.Cryptography;
44

src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal sealed partial class AesGcmCipher : SymmetricCipher, IDisposable
1515
private const int TagSizeInBytes = 16;
1616
private readonly byte[] _iv;
1717
private readonly int _aadLength;
18-
#if NET
18+
#if !NETSTANDARD
1919
private readonly Impl _impl;
2020
#else
2121
private readonly BouncyCastleImpl _impl;
@@ -62,7 +62,7 @@ public AesGcmCipher(byte[] key, byte[] iv, int aadLength)
6262
// SSH AES-GCM requires a 12-octet Initial IV
6363
_iv = iv.Take(12);
6464
_aadLength = aadLength;
65-
#if NET
65+
#if !NETSTANDARD
6666
if (System.Security.Cryptography.AesGcm.IsSupported)
6767
{
6868
_impl = new BclImpl(key, _iv);

test/.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ dotnet_diagnostic.SA1623.severity = none
102102
# For unit test projects, we do not care about documentation.
103103
dotnet_diagnostic.SA1629.severity = none
104104

105+
# Workaround https://github.com/SonarSource/sonar-dotnet/issues/9767
106+
dotnet_diagnostic.S1450.severity = none
107+
dotnet_diagnostic.S1764.severity = none
108+
dotnet_diagnostic.S3260.severity = none
109+
dotnet_diagnostic.S5445.severity = none
110+
105111
#### .NET Compiler Platform analysers rules ####
106112

107113
# CA1001: Types that own disposable fields should be disposable
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[assembly: DoNotParallelize]

test/Renci.SshNet.IntegrationTests/AuthenticationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public void KeyboardInteractive_NoResponseSet_ThrowsSshAuthenticationException()
436436
catch (SshAuthenticationException ex)
437437
{
438438
Assert.IsNull(ex.InnerException);
439-
Assert.IsTrue(ex.Message.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \""), $"Message was \"{ex.Message}\"");
439+
Assert.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \"", ex.Message);
440440
}
441441
}
442442
}

test/Renci.SshNet.IntegrationTests/ConnectivityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public void Common_HostKeyAlgorithms_NoMatch()
432432
var ex = Assert.Throws<SshConnectionException>(client.Connect);
433433

434434
Assert.AreEqual(DisconnectReason.KeyExchangeFailed, ex.DisconnectReason);
435-
Assert.IsTrue(ex.Message.StartsWith("No matching host key algorithm"), ex.Message);
435+
Assert.StartsWith("No matching host key algorithm", ex.Message);
436436
}
437437
}
438438

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#nullable enable
2+
using Microsoft.Extensions.Logging;
3+
4+
namespace Renci.SshNet.IntegrationTests.Logging
5+
{
6+
internal class TestConsoleLogger(string categoryName) : ILogger
7+
{
8+
public IDisposable? BeginScope<TState>(TState state)
9+
where TState : notnull
10+
{
11+
return null;
12+
}
13+
14+
public bool IsEnabled(LogLevel logLevel)
15+
{
16+
return true;
17+
}
18+
19+
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
20+
{
21+
StringBuilder sb = new StringBuilder();
22+
sb.Append(logLevel);
23+
sb.Append(": ");
24+
sb.Append(categoryName);
25+
sb.Append(": ");
26+
27+
string message = formatter(state, exception);
28+
sb.Append(message);
29+
30+
if (exception != null)
31+
{
32+
sb.Append(": ");
33+
sb.Append(exception);
34+
}
35+
36+
string line = sb.ToString();
37+
Console.WriteLine(line);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)