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

Code before:
                    //
                    if (listenSocketHandle__addRefd)
                        listenSocketHandle.DangerousRelease();
                    if (acceptSocketHandle__addRefd)
                        acceptSocketHandle.DangerousRelease();
                }

                return __retVal;
            }
            internal unsafe void GetAcceptExSockaddrs(IntPtr buffer, int receiveDataLength, int localAddressLength, int remoteAddressLength, out IntPtr localSocketAddress, out int localSocketAddressLength, out IntPtr remoteSocketAddress, out int remoteSocketAddressLength)
            {
                localSocketAddress = default;
                localSocketAddressLength = default;
                remoteSocketAddress = default;
                remoteSocketAddressLength = default;
                fixed (IntPtr* __localSocketAddress_gen_native = &localSocketAddress)
                fixed (int* __localSocketAddressLength_gen_native = &localSocketAddressLength)
                fixed (IntPtr* __remoteSocketAddress_gen_native = &remoteSocketAddress)
                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
                    //

Review comment (suggestion):
Ditto
```suggestion
            internal unsafe bool ConnectEx(SafeSocketHandle socketHandle, ReadOnlySpan<byte> socketAddress, IntPtr buffer, int dataLength, out int bytesSent, NativeOverlapped* overlapped)

```

Code after:
                    //
                    if (listenSocketHandle__addRefd)
                        listenSocketHandle.DangerousRelease();
                    if (acceptSocketHandle__addRefd)
                        acceptSocketHandle.DangerousRelease();
                }

                return __retVal;
            }
            internal unsafe void GetAcceptExSockaddrs(IntPtr buffer, int receiveDataLength, int localAddressLength, int remoteAddressLength, out IntPtr localSocketAddress, out int localSocketAddressLength, out IntPtr remoteSocketAddress, out int remoteSocketAddressLength)
            {
                localSocketAddress = default;
                localSocketAddressLength = default;
                remoteSocketAddress = default;
                remoteSocketAddressLength = default;
                fixed (IntPtr* __localSocketAddress_gen_native = &localSocketAddress)
                fixed (int* __localSocketAddressLength_gen_native = &localSocketAddressLength)
                fixed (IntPtr* __remoteSocketAddress_gen_native = &remoteSocketAddress)
                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
                    //