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

Code before:
            public NlEndPoint(int pid)
            {
                _pid = pid;
            }

            public override AddressFamily AddressFamily
            {
                get
                {
                    return AddressFamily.Unknown;
                }
            }

            public class NlSocketAddress : SocketAddress
            {
                // We need to create base from something known.
                public unsafe NlSocketAddress(int pid) : base(AddressFamily.Packet)
                {
                    sockaddr_nl addr = default;

                    addr.sin_family = PF_NETLINK;
                    addr.pid = pid;

                    var bytes = new ReadOnlySpan<byte>(&addr, sizeof(sockaddr_nl));

                    for (int i = 0; i< bytes.Length; i++)
                    {
                        this[i] = bytes[i];
                    }
                }
            }

            public override SocketAddress Serialize()
            {
                SocketAddress a = (SocketAddress)new NlSocketAddress(_pid);
                return a;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        internal struct nlmsghdr
        {
            internal int nlmsg_len;       /* Length of message including header */
            internal ushort nlmsg_type;   /* Type of message content */
            internal ushort nlmsg_flags;  /* Additional flags */
            internal int nlmsg_seq;       /* Sequence number */
            internal uint nlmsg_pid;      /* Sender port ID */
        };

        [StructLayout(LayoutKind.Sequential)]
        private struct nlmsgerr {

Review comment (suggestion):
```suggestion
                    for (int i = 0; i < bytes.Length; i++)
```

Code after:
            public NlEndPoint(int pid)
            {
                _pid = pid;
            }

            public override AddressFamily AddressFamily
            {
                get
                {
                    return AddressFamily.Unknown;
                }
            }

            public class NlSocketAddress : SocketAddress
            {
                // We need to create base from something known.
                public unsafe NlSocketAddress(int pid) : base(AddressFamily.Packet)
                {
                    sockaddr_nl addr = default;

                    addr.sin_family = PF_NETLINK;
                    addr.pid = pid;

                    var bytes = new ReadOnlySpan<byte>(&addr, sizeof(sockaddr_nl));

                    for (int i = 0; i < bytes.Length; i++)
                    {
                        this[i] = bytes[i];
                    }
                }
            }

            public override SocketAddress Serialize()
            {
                SocketAddress a = (SocketAddress)new NlSocketAddress(_pid);
                return a;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        internal struct nlmsghdr
        {
            internal int nlmsg_len;       /* Length of message including header */
            internal ushort nlmsg_type;   /* Type of message content */
            internal ushort nlmsg_flags;  /* Additional flags */
            internal int nlmsg_seq;       /* Sequence number */
            internal uint nlmsg_pid;      /* Sender port ID */
        };

        [StructLayout(LayoutKind.Sequential)]
        private struct nlmsgerr {