Repository: dotnet/runtime
File: src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs (C#)

Code before:
            {
                ObjectDisposedException.ThrowIf(_disposed, _innerStream);
                throw new NotSupportedException("Synchronous operations are not supported.");
            }

            public override ValueTask<int> ReadAsync(Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) => _innerStream.ReadAsync(buffer, cancellationToken);
            public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) => _innerStream.WriteAsync(buffer, cancellationToken);
            public override Task FlushAsync(System.Threading.CancellationToken cancellationToken = default) => _innerStream.FlushAsync(cancellationToken);

            protected override void Dispose(bool disposing)
            {
                if (_disposed) return;

                _disposed = true;
                _innerStream.Dispose();
            }

            public override ValueTask DisposeAsync()
            {
                if (_disposed) return default;

                _disposed = true;
                return _innerStream.DisposeAsync();
            }

            public override void Close() => _innerStream.Close();
        }
    }

    /// <summary>Provides a disposable, enumerable tuple of two streams.</summary>
    public class StreamPair : IDisposable, IAsyncDisposable, IEnumerable<Stream>
    {
        public readonly Stream Stream1, Stream2;

        public StreamPair(Stream stream1, Stream stream2)
        {
            Stream1 = stream1;
            Stream2 = stream2;
        }

        public StreamPair((Stream, Stream) streams)
        {
            Stream1 = streams.Item1;
            Stream2 = streams.Item2;
        }

        public static implicit operator StreamPair((Stream, Stream) streams) => new StreamPair(streams);
        public static implicit operator (Stream, Stream)(StreamPair streams) => (streams.Stream1, streams.Stream2);

        public virtual void Dispose()
        {

Review comment (suggestion):
The `Close()` method in `AsyncOnlyStream` may call synchronous `Dispose()` internally on the inner stream. This could result in blocking IO operations that this wrapper is designed to prevent. Consider throwing `NotSupportedException` for `Close()` similar to other sync methods, or override `Close()` to call `Dispose(false)` directly without calling the inner stream's `Close()`, since disposal is already handled in `Dispose(bool)` and `DisposeAsync()`.
```suggestion
            public override void Close()
            {
                throw new NotSupportedException("Synchronous operations are not supported.");
            }
```

Code after:
            {
                ObjectDisposedException.ThrowIf(_disposed, _innerStream);
                throw new NotSupportedException("Synchronous operations are not supported.");
            }

            public override ValueTask<int> ReadAsync(Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) => _innerStream.ReadAsync(buffer, cancellationToken);
            public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) => _innerStream.WriteAsync(buffer, cancellationToken);
            public override Task FlushAsync(System.Threading.CancellationToken cancellationToken = default) => _innerStream.FlushAsync(cancellationToken);

            protected override void Dispose(bool disposing)
            {
                if (_disposed) return;

                _disposed = true;
                if (disposing)
                {
                    _innerStream.Dispose();
                }
            }

            public override ValueTask DisposeAsync()
            {
                if (_disposed) return default;

                _disposed = true;
                return _innerStream.DisposeAsync();
            }

            public override void Close()
            {
                throw new NotSupportedException("Synchronous operations are not supported.");
            }
        }
    }

    /// <summary>Provides a disposable, enumerable tuple of two streams.</summary>
    public class StreamPair : IDisposable, IAsyncDisposable, IEnumerable<Stream>
    {
        public readonly Stream Stream1, Stream2;

        public StreamPair(Stream stream1, Stream stream2)
        {
            Stream1 = stream1;
            Stream2 = stream2;
        }

        public StreamPair((Stream, Stream) streams)
        {
            Stream1 = streams.Item1;
            Stream2 = streams.Item2;
        }