private unsafe void WriteEvent()

in src/Microsoft.Azure.Relay/WebSockets/NetEventSource.Common.cs [492:533]


        private unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg3, string arg4)
        {
            if (IsEnabled())
            {
                if (arg1 == null) arg1 = "";
                if (arg2 == null) arg2 = "";
                if (arg3 == null) arg3 = "";
                if (arg4 == null) arg4 = "";

                fixed (char* string1Bytes = arg1)
                fixed (char* string2Bytes = arg2)
                fixed (char* string3Bytes = arg3)
                fixed (char* string4Bytes = arg4)
                {
                    const int NumEventDatas = 4;
                    var descrs = stackalloc EventData[NumEventDatas];

                    descrs[0] = new EventData
                    {
                        DataPointer = (IntPtr)string1Bytes,
                        Size = ((arg1.Length + 1) * 2)
                    };
                    descrs[1] = new EventData
                    {
                        DataPointer = (IntPtr)string2Bytes,
                        Size = ((arg2.Length + 1) * 2)
                    };
                    descrs[2] = new EventData
                    {
                        DataPointer = (IntPtr)string3Bytes,
                        Size = ((arg3.Length + 1) * 2)
                    };
                    descrs[3] = new EventData
                    {
                        DataPointer = (IntPtr)string4Bytes,
                        Size = ((arg4.Length + 1) * 2)
                    };

                    WriteEventCore(eventId, NumEventDatas, descrs);
                }
            }
        }