Repository: dotnet/runtime
File: src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/OpenNullHandle.cs (C#)

Code before:
        public void OpenNullHandle_SyncWriteSpan_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write);
            
            byte[] buffer = new byte[100];
            // Should not throw
            stream.Write(buffer.AsSpan());
        }

        [Fact]
        public async Task OpenNullHandle_AsyncWrite_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write, 4096, true);
            
            byte[] buffer = new byte[100];
            // Should not throw
            await stream.WriteAsync(buffer, 0, buffer.Length);
        }

        [Fact]
        public async Task OpenNullHandle_AsyncWriteMemory_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write, 4096, true);
            
            byte[] buffer = new byte[100];
            // Should not throw
            await stream.WriteAsync(buffer.AsMemory());
        }

        [Fact]
        public void OpenNullHandle_MultipleReads_AlwaysReturnZero()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Read);
            
            byte[] buffer = new byte[100];
            for (int i = 0; i < 10; i++)
            {
                int bytesRead = stream.Read(buffer, 0, buffer.Length);
                Assert.Equal(0, bytesRead);
            }
        }

        [Fact]
        public void OpenNullHandle_MultipleWrites_AllSucceed()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write);

Review comment (suggestion):
```suggestion
            using FileStream stream = new FileStream(handle, FileAccess.Write);
```

Code after:
        [Fact]
        public void OpenNullHandle_SyncWriteSpan_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write);
            
            byte[] buffer = new byte[100];
            // Should not throw
            stream.Write(buffer.AsSpan());
        }

        [Fact]
        public async Task OpenNullHandle_AsyncWrite_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write);
            
            byte[] buffer = new byte[100];
            // Should not throw
            await stream.WriteAsync(buffer, 0, buffer.Length);
        }

        [Fact]
        public async Task OpenNullHandle_AsyncWriteMemory_Succeeds()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.Write);
            
            byte[] buffer = new byte[100];
            // Should not throw
            await stream.WriteAsync(buffer.AsMemory());
        }

        [Fact]
        public void OpenNullHandle_ReadWriteAccess_BothWork()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.ReadWrite);
            
            byte[] writeBuffer = new byte[100];
            byte[] readBuffer = new byte[100];
            
            // Write should succeed
            stream.Write(writeBuffer, 0, writeBuffer.Length);
            
            // Read should return 0
            int bytesRead = stream.Read(readBuffer, 0, readBuffer.Length);
            Assert.Equal(0, bytesRead);
        }

        [Fact]