/// <summary>
            /// Serializes the exception metadata and SerializedExceptionData
            /// </summary>
            public unsafe byte[] Serialize()
            {
                checked
                {
                    byte[] serializedData = new byte[sizeof(ExceptionMetadataStruct) + SerializedExceptionData.Length];
                    fixed(byte *pSerializedData = serializedData)
                    {
                        ExceptionMetadataStruct *pMetadata = (ExceptionMetadataStruct *)pSerializedData;

                        pMetadata->ExceptionId      = ExceptionMetadata.ExceptionId;
                        pMetadata->InnerExceptionId = ExceptionMetadata.InnerExceptionId;
                        pMetadata->ThreadId         = ExceptionMetadata.ThreadId;
                        pMetadata->NestingLevel     = ExceptionMetadata.NestingLevel;
                        pMetadata->ExceptionCCWPtr  = ExceptionMetadata.ExceptionCCWPtr;

                        Array.CopyToNative(SerializedExceptionData, 0, (IntPtr)(pSerializedData + sizeof(ExceptionMetadataStruct)), SerializedExceptionData.Length);
                    }

                    return(serializedData);
                }
            }
Exemple #2
0
            /// <summary>
            /// Serializes the exception metadata and SerializedExceptionData
            /// </summary>
            public unsafe byte[] Serialize()
            {
                checked
                {
                    byte[] serializedData = new byte[sizeof(ExceptionMetadataStruct) + SerializedExceptionData.Length];
                    fixed(byte *pSerializedData = &serializedData[0])
                    {
                        ExceptionMetadataStruct *pMetadata = (ExceptionMetadataStruct *)pSerializedData;

                        pMetadata->ExceptionId      = ExceptionMetadata.ExceptionId;
                        pMetadata->InnerExceptionId = ExceptionMetadata.InnerExceptionId;
                        pMetadata->ThreadId         = ExceptionMetadata.ThreadId;
                        pMetadata->NestingLevel     = ExceptionMetadata.NestingLevel;
                        pMetadata->ExceptionCCWPtr  = ExceptionMetadata.ExceptionCCWPtr;

                        SerializedExceptionData.AsSpan().CopyTo(new Span <byte>(pSerializedData + sizeof(ExceptionMetadataStruct), SerializedExceptionData.Length));
                    }

                    return(serializedData);
                }
            }