Repository: dotnet/runtime
File: src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.Adapters.cs (C#)

Code before:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using System.Threading.Tasks;

namespace System.Net.Security
{
    // This contains adapters to allow a single code path for sync/async logic
    public partial class SslStream
    {
        private interface ISslIOAdapter
        {
            ValueTask<int> ReadAsync(Memory<byte> buffer);
            ValueTask WriteAsync(byte[] buffer, int offset, int count);
            ValueTask LockAsync(TaskCompletionSource<bool> waiter);
            CancellationToken CancellationToken { get; }
        }

        private readonly struct AsyncSslIOAdapter : ISslIOAdapter
        {
            private readonly SslStream _sslStream;
            private readonly CancellationToken _cancellationToken;

            public AsyncSslIOAdapter(SslStream sslStream, CancellationToken cancellationToken)
            {
                _cancellationToken = cancellationToken;
                _sslStream = sslStream;
            }

            public ValueTask<int> ReadAsync(Memory<byte> buffer) => _sslStream.InnerStream.ReadAsync(buffer, _cancellationToken);

            public ValueTask WriteAsync(byte[] buffer, int offset, int count) => _sslStream.InnerStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), _cancellationToken);

            public async ValueTask LockAsync(TaskCompletionSource<bool> waiter)
            {
                await waiter.Task.ConfigureAwait(false);
            }

            public CancellationToken CancellationToken => _cancellationToken;
        }

Review comment (suggestion):
```suggestion
            Task LockAsync(TaskCompletionSource<bool> waiter);
```
See below explanation....

Code after:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using System.Threading.Tasks;

namespace System.Net.Security
{
    // This contains adapters to allow a single code path for sync/async logic
    public partial class SslStream
    {
        private interface ISslIOAdapter
        {
            ValueTask<int> ReadAsync(Memory<byte> buffer);
            ValueTask WriteAsync(byte[] buffer, int offset, int count);
            Task WaitAsync(TaskCompletionSource<bool> waiter);
            CancellationToken CancellationToken { get; }
        }

        private readonly struct AsyncSslIOAdapter : ISslIOAdapter
        {
            private readonly SslStream _sslStream;
            private readonly CancellationToken _cancellationToken;

            public AsyncSslIOAdapter(SslStream sslStream, CancellationToken cancellationToken)
            {
                _cancellationToken = cancellationToken;
                _sslStream = sslStream;
            }

            public ValueTask<int> ReadAsync(Memory<byte> buffer) => _sslStream.InnerStream.ReadAsync(buffer, _cancellationToken);

            public ValueTask WriteAsync(byte[] buffer, int offset, int count) => _sslStream.InnerStream.WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), _cancellationToken);

            public Task WaitAsync(TaskCompletionSource<bool> waiter) => waiter.Task;

            public CancellationToken CancellationToken => _cancellationToken;
        }

        private readonly struct SyncSslIOAdapter : ISslIOAdapter
        {