Skip to content

Commit fdd1dac

Browse files
committed
reduce CA1849 suppressions
and disable duplicate S6966
1 parent 5e7d01d commit fdd1dac

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ dotnet_diagnostic.S5659.severity = none
344344
# https://rules.sonarsource.com/csharp/RSPEC-5773/
345345
dotnet_diagnostic.S4581.severity = none
346346

347+
# S6966: Awaitable method should be used
348+
# Duplicate of CA1849
349+
dotnet_diagnostic.S6966.severity = none
350+
347351
#### StyleCop rules ####
348352

349353
# SA1003: Symbols must be spaced correctly

src/Renci.SshNet/SftpClient.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ private List<ISftpFile> InternalListDirectory(string path, SftpListDirectoryAsyn
22692269
return result;
22702270
}
22712271

2272-
#pragma warning disable S6966 // Awaitable method should be used
2272+
#pragma warning disable CA1849 // Call async methods when in an async method
22732273
private async Task InternalDownloadFile(
22742274
string path,
22752275
Stream output,
@@ -2330,15 +2330,13 @@ private async Task InternalDownloadFile(
23302330
break;
23312331
}
23322332

2333-
#pragma warning disable CA1849 // Call async methods when in an async method
23342333
var bytesRead = isAsync
23352334
#if NET
23362335
? await sftpStream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)
23372336
#else
23382337
? await sftpStream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)
23392338
#endif
23402339
: sftpStream.Read(buffer, 0, buffer.Length);
2341-
#pragma warning restore CA1849 // Call async methods when in an async method
23422340

23432341
if (bytesRead == 0)
23442342
{
@@ -2355,9 +2353,7 @@ private async Task InternalDownloadFile(
23552353
}
23562354
else
23572355
{
2358-
#pragma warning disable CA1849 // Call async methods when in an async method
23592356
output.Write(buffer, 0, bytesRead);
2360-
#pragma warning restore CA1849 // Call async methods when in an async method
23612357
}
23622358

23632359
totalBytesRead += (ulong)bytesRead;
@@ -2384,15 +2380,11 @@ private async Task InternalDownloadFile(
23842380
}
23852381
else
23862382
{
2387-
#pragma warning disable CA1849 // Call async methods when in an async method
23882383
sftpStream.Dispose();
2389-
#pragma warning restore CA1849 // Call async methods when in an async method
23902384
}
23912385
}
23922386
}
2393-
#pragma warning restore S6966 // Awaitable method should be used
23942387

2395-
#pragma warning disable S6966 // Awaitable method should be used
23962388
private async Task InternalUploadFile(
23972389
Stream input,
23982390
string path,
@@ -2439,15 +2431,13 @@ private async Task InternalUploadFile(
24392431

24402432
while (true)
24412433
{
2442-
#pragma warning disable CA1849 // Call async methods when in an async method
24432434
var bytesRead = isAsync
24442435
#if NET
24452436
? await input.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)
24462437
#else
24472438
? await input.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)
24482439
#endif
24492440
: input.Read(buffer, 0, buffer.Length);
2450-
#pragma warning restore CA1849 // Call async methods when in an async method
24512441

24522442
if (bytesRead == 0)
24532443
{
@@ -2533,7 +2523,7 @@ private async Task InternalUploadFile(
25332523
_sftpSession.RequestClose(handle);
25342524
}
25352525
}
2536-
#pragma warning restore S6966 // Awaitable method should be used
2526+
#pragma warning restore CA1849 // Call async methods when in an async method
25372527

25382528
/// <summary>
25392529
/// Called when client is connected to the server.

test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public async Task DisposeAsync()
9191
{
9292
if (_sshServer != null)
9393
{
94-
#pragma warning disable S6966 // Awaitable method should be used
9594
//try
9695
//{
9796
// File.WriteAllBytes(@"C:\tmp\auth.log", await _sshServer.ReadFileAsync("/var/log/auth.log").ConfigureAwait(false));
@@ -100,7 +99,6 @@ public async Task DisposeAsync()
10099
//{
101100
// Console.Error.WriteLine(ex.ToString());
102101
//}
103-
#pragma warning restore S6966 // Awaitable method should be used
104102

105103
await _sshServer.DisposeAsync();
106104
}

0 commit comments

Comments
 (0)