Skip to content

Commit a49a135

Browse files
authored
Remove unnecessary CA2022 suppressions (#48766)
1 parent f98b22c commit a49a135

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/RazorSdk/Tool/Client.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation
171171
try
172172
{
173173
ServerLogger.Log($"Before poking pipe {Identifier}.");
174-
#pragma warning disable CA2022 // Avoid inexact read
175-
await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
176-
#pragma warning restore CA2022
174+
// Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe.
175+
// We need to trigger a state update without actually reading the data.
176+
_ = await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
177177
ServerLogger.Log($"After poking pipe {Identifier}.");
178178
}
179179
catch (OperationCanceledException)

src/RazorSdk/Tool/ConnectionHost.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation
107107
try
108108
{
109109
ServerLogger.Log($"Before poking pipe {Identifier}.");
110-
#pragma warning disable CA2022 // Avoid inexact read
111-
await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
112-
#pragma warning restore CA2022
110+
// Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe.
111+
// We need to trigger a state update without actually reading the data.
112+
_ = await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
113113
ServerLogger.Log($"After poking pipe {Identifier}.");
114114
}
115115
catch (OperationCanceledException)

0 commit comments

Comments
 (0)