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

Code before:
        }

        [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);
        }

        [Theory]
        [InlineData(false)]
        [InlineData(true)]
        public async Task OpenNullHandle_WithExplicitIsAsync_WorksCorrectly(bool isAsync)
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.ReadWrite, bufferSize: 4096, isAsync: isAsync);
            
            byte[] writeBuffer = new byte[100];
            byte[] readBuffer = new byte[100];
            
            // Write should succeed
            await stream.WriteAsync(writeBuffer, 0, writeBuffer.Length);
            
            // Read should return 0
            int bytesRead = await stream.ReadAsync(readBuffer, 0, readBuffer.Length);
            Assert.Equal(0, bytesRead);
        }

        [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
        public void OpenNullHandle_DoesNotLockNullDevice()
        {
            // Keep a handle open in the current process
            using SafeFileHandle handle1 = File.OpenNullHandle();
            using FileStream stream1 = new FileStream(handle1, FileAccess.ReadWrite);
            
            // Start a new process that also opens the null device
            RemoteExecutor.Invoke(() =>
            {
                using SafeFileHandle handle2 = File.OpenNullHandle();
                using FileStream stream2 = new FileStream(handle2, FileAccess.ReadWrite);
                

Review comment (suggestion):
Let's revert the last change, as for the reasons described in https://github.com/dotnet/runtime/pull/123483/files#r2727966267 it's not going to work.

```suggestion
        [Fact]
        public async Task OpenNullHandle_ReadWriteAccess_BothAsyncOperationsWork()
        {
            using SafeFileHandle handle = File.OpenNullHandle();
            using FileStream stream = new FileStream(handle, FileAccess.ReadWrite);
```

Code after:
        }

        [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]
        public async Task OpenNullHandle_ReadWriteAccess_BothAsyncOperationsWork()
        {
            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
            await stream.WriteAsync(writeBuffer, 0, writeBuffer.Length);
            
            // Read should return 0
            int bytesRead = await stream.ReadAsync(readBuffer, 0, readBuffer.Length);
            Assert.Equal(0, bytesRead);
        }

        [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
        public void OpenNullHandle_DoesNotLockNullDevice()
        {
            // Keep a handle open in the current process
            using SafeFileHandle handle1 = File.OpenNullHandle();
            using FileStream stream1 = new FileStream(handle1, FileAccess.ReadWrite);
            
            // Start a new process that also opens the null device
            RemoteExecutor.Invoke(() =>
            {
                using SafeFileHandle handle2 = File.OpenNullHandle();
                using FileStream stream2 = new FileStream(handle2, FileAccess.ReadWrite);
                
                byte[] buffer = new byte[100];