Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning disables for the newly added CA2022 #4094

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ await Task.WhenAll(
// In Tls1.3 part of handshake happens with data exchange.
// To be consistent we do this extra step for all protocol versions
await sslClient.WriteAsync(_clientBuffer, default);
#pragma warning disable CA2022 // Avoid inexact read
await sslServer.ReadAsync(_serverBuffer, default);
await sslServer.WriteAsync(_serverBuffer, default);
await sslClient.ReadAsync(_clientBuffer, default);
#pragma warning restore CA2022
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ await Task.WhenAll(
{
// In Tls1.3 part of handshake happens with data exchange.
await sslClient.WriteAsync(_clientBuffer, cts.Token);
#pragma warning disable CA2022 // Avoid inexact read
await sslServer.ReadAsync(_serverBuffer, cts.Token);
await sslServer.WriteAsync(_serverBuffer, cts.Token);
await sslClient.ReadAsync(_clientBuffer, cts.Token);
#pragma warning restore CA2022
}
}
}
Expand Down Expand Up @@ -189,11 +191,12 @@ await Task.WhenAll(
sslServer.AuthenticateAsServerAsync(serverOptions, cts.Token));

byte[] clientBuffer = new byte[1], serverBuffer = new byte[1];

await sslClient.WriteAsync(clientBuffer, cts.Token);
#pragma warning disable CA2022 // Avoid inexact read
await sslServer.ReadAsync(serverBuffer, cts.Token);
await sslServer.WriteAsync(serverBuffer, cts.Token);
await sslClient.ReadAsync(clientBuffer, cts.Token);
#pragma warning restore CA2022
}
}

Expand All @@ -208,7 +211,9 @@ public async Task WriteReadAsync()
for (int i = 0; i < ReadWriteIterations; i++)
{
await _sslClient.WriteAsync(clientBuffer, default);
#pragma warning disable CA2022 // Avoid inexact read
await _sslServer.ReadAsync(serverBuffer, default);
#pragma warning restore CA2022
}
}

Expand All @@ -219,7 +224,9 @@ public async Task LargeWriteReadAsync()
Memory<byte> clientBuffer = _largeClientBuffer;
Memory<byte> serverBuffer = _largeServerBuffer;
await _sslClient.WriteAsync(clientBuffer, default);
#pragma warning disable CA2022 // Avoid inexact read
await _sslServer.ReadAsync(serverBuffer, default);
#pragma warning restore CA2022
}

[Benchmark(OperationsPerInvoke = ReadWriteIterations)]
Expand Down Expand Up @@ -256,6 +263,7 @@ public async Task ConcurrentReadWrite()
Memory<byte> buffer1 = _clientBuffer;
Memory<byte> buffer2 = _serverBuffer;

#pragma warning disable CA2022 // Avoid inexact read
Task other = Task.Run(async delegate
{
_twoParticipantBarrier.SignalAndWait();
Expand All @@ -272,6 +280,7 @@ public async Task ConcurrentReadWrite()
await _sslClient.WriteAsync(buffer2, default);
await _sslServer.ReadAsync(buffer2, default);
}
#pragma warning restore CA2022

await other;
}
Expand Down
Loading