Repository: dotnet/runtime
File: src/libraries/System.Net.Sockets/src/System/Net/Sockets/DynamicWinsockMethods.cs (C#)

Code before:
                fixed (int* __remoteSocketAddressLength_gen_native = &remoteSocketAddressLength)
                {
                    ((delegate* unmanaged<IntPtr, int, int, int, IntPtr*, int*, IntPtr*, int*, void>)_target)(buffer, receiveDataLength, localAddressLength, remoteAddressLength, __localSocketAddress_gen_native, __localSocketAddressLength_gen_native, __remoteSocketAddress_gen_native, __remoteSocketAddressLength_gen_native);
                }
                Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());

            }
            internal unsafe bool ConnectEx(SafeSocketHandle socketHandle, Span<byte> socketAddress, IntPtr buffer, int dataLength, out int bytesSent, NativeOverlapped* overlapped)
            {
                IntPtr __socketHandle_gen_native = default;
                bytesSent = default;
                bool __retVal;
                int __retVal_gen_native = default;
                //
                // Setup
                //
                bool socketHandle__addRefd = false;
                try
                {
                    //
                    // Marshal
                    //
                    socketHandle.DangerousAddRef(ref socketHandle__addRefd);
                    __socketHandle_gen_native = socketHandle.DangerousGetHandle();
                    fixed (int* __bytesSent_gen_native = &bytesSent)
                    fixed (void* socketAddressPtr = socketAddress)
                    {
                        __retVal_gen_native = ((delegate* unmanaged<IntPtr, void*, int, IntPtr, int, int*, NativeOverlapped*, int>)_target)(__socketHandle_gen_native, socketAddressPtr, socketAddress.Length, buffer, dataLength, __bytesSent_gen_native, overlapped);
                    }
                    Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
                    //
                    // Unmarshal
                    //
                    __retVal = __retVal_gen_native != 0;
                }
                finally
                {
                    //
                    // Cleanup
                    //
                    if (socketHandle__addRefd)
                        socketHandle.DangerousRelease();
                }

                return __retVal;
            }
            internal unsafe bool DisconnectEx(SafeSocketHandle socketHandle, NativeOverlapped* overlapped, int flags, int reserved)
            {
                IntPtr __socketHandle_gen_native;
                bool __retVal;
                int __retVal_gen_native;

Review comment (suggestion):
Ever so slightly cheaper:
```suggestion
                    fixed (void* socketAddressPtr = &MemoryMarshal.GetReference(socketAddress))
```

Code after:
                fixed (int* __remoteSocketAddressLength_gen_native = &remoteSocketAddressLength)
                {
                    ((delegate* unmanaged<IntPtr, int, int, int, IntPtr*, int*, IntPtr*, int*, void>)_target)(buffer, receiveDataLength, localAddressLength, remoteAddressLength, __localSocketAddress_gen_native, __localSocketAddressLength_gen_native, __remoteSocketAddress_gen_native, __remoteSocketAddressLength_gen_native);
                }
                Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());

            }
            internal unsafe bool ConnectEx(SafeSocketHandle socketHandle, ReadOnlySpan<byte> socketAddress, IntPtr buffer, int dataLength, out int bytesSent, NativeOverlapped* overlapped)
            {
                IntPtr __socketHandle_gen_native = default;
                bytesSent = default;
                bool __retVal;
                int __retVal_gen_native = default;
                //
                // Setup
                //
                bool socketHandle__addRefd = false;
                try
                {
                    //
                    // Marshal
                    //
                    socketHandle.DangerousAddRef(ref socketHandle__addRefd);
                    __socketHandle_gen_native = socketHandle.DangerousGetHandle();
                    fixed (int* __bytesSent_gen_native = &bytesSent)
                    fixed (void* socketAddressPtr = &MemoryMarshal.GetReference(socketAddress))
                    {
                        __retVal_gen_native = ((delegate* unmanaged<IntPtr, void*, int, IntPtr, int, int*, NativeOverlapped*, int>)_target)(__socketHandle_gen_native, socketAddressPtr, socketAddress.Length, buffer, dataLength, __bytesSent_gen_native, overlapped);
                    }
                    Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
                    //
                    // Unmarshal
                    //
                    __retVal = __retVal_gen_native != 0;
                }
                finally
                {
                    //
                    // Cleanup
                    //
                    if (socketHandle__addRefd)
                        socketHandle.DangerousRelease();
                }

                return __retVal;
            }
            internal unsafe bool DisconnectEx(SafeSocketHandle socketHandle, NativeOverlapped* overlapped, int flags, int reserved)
            {
                IntPtr __socketHandle_gen_native;
                bool __retVal;
                int __retVal_gen_native;