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

Code before:
                {
                    return methods;
                }
            }

            return GetMethodsSlow(addressFamily, socketType, protocolType);
        }

        private static DynamicWinsockMethods GetMethodsSlow(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
        {
            lock (s_methodTableLock)
            {
                DynamicWinsockMethods[] methodTable = s_methodTable;
                foreach (DynamicWinsockMethods methods in methodTable)
                {
                    if (methods.Matches(addressFamily, socketType, protocolType))
                    {
                        return methods;
                    }
                }

                var newMethods = new DynamicWinsockMethods(addressFamily, socketType, protocolType);
                var newTable = new DynamicWinsockMethods[methodTable.Length + 1];
                Array.Copy(methodTable, newTable, methodTable.Length);
                newTable[methodTable.Length] = newMethods;
                s_methodTable = newTable;

                return newMethods;
            }
        }

        private readonly AddressFamily _addressFamily;
        private readonly SocketType _socketType;
        private readonly ProtocolType _protocolType;

        private AcceptExDelegate? _acceptEx;
        private GetAcceptExSockaddrsDelegate? _getAcceptExSockaddrs;
        private ConnectExDelegate? _connectEx;
        private TransmitPacketsDelegate? _transmitPackets;
        private DisconnectExDelegate? _disconnectEx;
        private WSARecvMsgDelegate? _recvMsg;

        private DynamicWinsockMethods(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
        {
            _addressFamily = addressFamily;
            _socketType = socketType;
            _protocolType = protocolType;
        }

        private static T CreateDelegate<T>(Func<IntPtr, T> functionPointerWrapper, [NotNull] ref T? cache, SafeSocketHandle socketHandle, string guidString) where T : Delegate
        {

Review comment (suggestion):
```suggestion
                s_methodTable = [.. methodTable, newMethods];
```

Code after:
                {
                    return methods;
                }
            }

            return GetMethodsSlow(addressFamily, socketType, protocolType);
        }

        private static DynamicWinsockMethods GetMethodsSlow(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
        {
            lock (s_methodTableLock)
            {
                DynamicWinsockMethods[] methodTable = s_methodTable;
                foreach (DynamicWinsockMethods methods in methodTable)
                {
                    if (methods.Matches(addressFamily, socketType, protocolType))
                    {
                        return methods;
                    }
                }

                var newMethods = new DynamicWinsockMethods(addressFamily, socketType, protocolType);
                s_methodTable = [.. methodTable, newMethods];

                return newMethods;
            }
        }

        private readonly AddressFamily _addressFamily;
        private readonly SocketType _socketType;
        private readonly ProtocolType _protocolType;

        private AcceptExDelegate? _acceptEx;
        private GetAcceptExSockaddrsDelegate? _getAcceptExSockaddrs;
        private ConnectExDelegate? _connectEx;
        private TransmitPacketsDelegate? _transmitPackets;
        private DisconnectExDelegate? _disconnectEx;
        private WSARecvMsgDelegate? _recvMsg;

        private DynamicWinsockMethods(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
        {
            _addressFamily = addressFamily;
            _socketType = socketType;
            _protocolType = protocolType;
        }

        private static T CreateDelegate<T>(Func<IntPtr, T> functionPointerWrapper, [NotNull] ref T? cache, SafeSocketHandle socketHandle, string guidString) where T : Delegate
        {
            Guid guid = new Guid(guidString);
            IntPtr ptr;
            SocketError errorCode;