Skip to content

Commit e024a02

Browse files
committed
fix Build with newer .NET 10 SDKs
The IDE0370 are a mess since they only affect certain target frameworks. Maybe we should disable this one completely instead? Also set a fixed SDK Version in CI so this doesn't randomly break again.
1 parent 4a6f7fd commit e024a02

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616

1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v5
19+
with:
20+
dotnet-version: '10.0.201'
1921

2022
- name: Build Unit Tests .NET
2123
run: dotnet build -f net10.0 test/Renci.SshNet.Tests/
@@ -63,6 +65,8 @@ jobs:
6365

6466
- name: Setup .NET
6567
uses: actions/setup-dotnet@v5
68+
with:
69+
dotnet-version: '10.0.201'
6670

6771
- name: Build Solution
6872
run: dotnet build Renci.SshNet.slnx
@@ -114,6 +118,8 @@ jobs:
114118

115119
- name: Setup .NET
116120
uses: actions/setup-dotnet@v5
121+
with:
122+
dotnet-version: '10.0.201'
117123

118124
- name: Setup WSL2
119125
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0
@@ -156,6 +162,8 @@ jobs:
156162

157163
- name: Setup .NET
158164
uses: actions/setup-dotnet@v5
165+
with:
166+
dotnet-version: '10.0.201'
159167

160168
- name: Setup WSL2
161169
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0

src/Renci.SshNet/ForwardedPort.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ protected virtual void StopPort(TimeSpan timeout)
105105
RaiseClosing();
106106

107107
var session = Session;
108-
if (session is not null)
109-
{
110-
session.ErrorOccured -= Session_ErrorOccurred;
111-
}
108+
session?.ErrorOccured -= Session_ErrorOccurred;
112109
}
113110

114111
/// <summary>

src/Renci.SshNet/OrderedDictionary.netstandard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public bool Remove(TKey key, [MaybeNullWhen(false)] out TValue value)
234234
}
235235

236236
AssertConsistency();
237-
value = default!;
237+
value = default;
238238
return false;
239239
}
240240

src/Renci.SshNet/ScpClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ public void Upload(Stream source, string path)
254254
using (var input = ServiceFactory.CreatePipeStream())
255255
using (var channel = Session.CreateChannelSession())
256256
{
257+
#pragma warning disable IDE0370 // Remove unnecessary suppression
257258
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
259+
#pragma warning restore IDE0370 // Remove unnecessary suppression
258260
channel.Closed += (sender, e) => input.Dispose();
259261
channel.Open();
260262

@@ -297,7 +299,9 @@ public void Upload(FileInfo fileInfo, string path)
297299
using (var input = ServiceFactory.CreatePipeStream())
298300
using (var channel = Session.CreateChannelSession())
299301
{
302+
#pragma warning disable IDE0370 // Remove unnecessary suppression
300303
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
304+
#pragma warning restore IDE0370 // Remove unnecessary suppression
301305
channel.Closed += (sender, e) => input.Dispose();
302306
channel.Open();
303307

@@ -343,7 +347,9 @@ public void Upload(DirectoryInfo directoryInfo, string path)
343347
using (var input = ServiceFactory.CreatePipeStream())
344348
using (var channel = Session.CreateChannelSession())
345349
{
350+
#pragma warning disable IDE0370 // Remove unnecessary suppression
346351
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
352+
#pragma warning restore IDE0370 // Remove unnecessary suppression
347353
channel.Closed += (sender, e) => input.Dispose();
348354
channel.Open();
349355

@@ -386,7 +392,9 @@ public void Download(string filename, FileInfo fileInfo)
386392
using (var input = ServiceFactory.CreatePipeStream())
387393
using (var channel = Session.CreateChannelSession())
388394
{
395+
#pragma warning disable IDE0370 // Remove unnecessary suppression
389396
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
397+
#pragma warning restore IDE0370 // Remove unnecessary suppression
390398
channel.Closed += (sender, e) => input.Dispose();
391399
channel.Open();
392400

@@ -426,7 +434,9 @@ public void Download(string directoryName, DirectoryInfo directoryInfo)
426434
using (var input = ServiceFactory.CreatePipeStream())
427435
using (var channel = Session.CreateChannelSession())
428436
{
437+
#pragma warning disable IDE0370 // Remove unnecessary suppression
429438
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
439+
#pragma warning restore IDE0370 // Remove unnecessary suppression
430440
channel.Closed += (sender, e) => input.Dispose();
431441
channel.Open();
432442

@@ -466,7 +476,9 @@ public void Download(string filename, Stream destination)
466476
using (var input = ServiceFactory.CreatePipeStream())
467477
using (var channel = Session.CreateChannelSession())
468478
{
479+
#pragma warning disable IDE0370 // Remove unnecessary suppression
469480
channel.DataReceived += (sender, e) => input.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
481+
#pragma warning restore IDE0370 // Remove unnecessary suppression
470482
channel.Closed += (sender, e) => input.Dispose();
471483
channel.Open();
472484

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ public override bool Verify(byte[] input, byte[] signature)
6565
public override void Export(out byte[] qx, out byte[] qy)
6666
{
6767
var parameter = Ecdsa.ExportParameters(includePrivateParameters: false);
68+
#pragma warning disable IDE0370 // Remove unnecessary suppression
6869
qx = parameter.Q.X!;
6970
qy = parameter.Q.Y!;
71+
#pragma warning restore IDE0370 // Remove unnecessary suppression
7072
}
7173

7274
protected override void Dispose(bool disposing)

src/Renci.SshNet/SshCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ public Task ExecuteAsync(CancellationToken cancellationToken = default)
307307
{
308308
try
309309
{
310+
#pragma warning disable IDE0370 // Remove unnecessary suppression
310311
((SshCommand)cmd!).CancelAsync();
312+
#pragma warning restore IDE0370 // Remove unnecessary suppression
311313
}
312314
catch
313315
{
@@ -583,7 +585,9 @@ private void Channel_RequestReceived(object? sender, ChannelRequestEventArgs e)
583585

584586
private void Channel_ExtendedDataReceived(object? sender, ChannelExtendedDataEventArgs e)
585587
{
588+
#pragma warning disable IDE0370 // Remove unnecessary suppression
586589
ExtendedOutputStream.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
590+
#pragma warning restore IDE0370 // Remove unnecessary suppression
587591

588592
if (e.DataTypeCode == 1)
589593
{
@@ -593,7 +597,9 @@ private void Channel_ExtendedDataReceived(object? sender, ChannelExtendedDataEve
593597

594598
private void Channel_DataReceived(object? sender, ChannelDataEventArgs e)
595599
{
600+
#pragma warning disable IDE0370 // Remove unnecessary suppression
596601
OutputStream.Write(e.Data.Array!, e.Data.Offset, e.Data.Count);
602+
#pragma warning restore IDE0370 // Remove unnecessary suppression
597603
}
598604

599605
/// <summary>

test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using Renci.SshNet.Abstractions;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
3+
using Renci.SshNet.Abstractions;
4+
35
using System;
46
using System.Threading;
57
using System.Security.Cryptography;

0 commit comments

Comments
 (0)