Example #1
0
        void DefineAsyncCustomMetadata(MethodDebugInformation info)
        {
            if (!info.HasCustomDebugInformations)
            {
                return;
            }

            foreach (var custom_info in info.CustomDebugInformations)
            {
                var async_debug_info = custom_info as AsyncMethodBodyDebugInformation;
                if (async_debug_info == null)
                {
                    continue;
                }

                using (var stream = new MemoryStream()) {
                    var async_metadata = new BinaryStreamWriter(stream);
                    async_metadata.WriteUInt32(info.StateMachineKickOffMethod != null ? info.StateMachineKickOffMethod.MetadataToken.ToUInt32() : 0);
                    async_metadata.WriteUInt32((uint)async_debug_info.CatchHandler.Offset);
                    async_metadata.WriteUInt32((uint)async_debug_info.Resumes.Count);
                    for (int i = 0; i < async_debug_info.Resumes.Count; ++i)
                    {
                        async_metadata.WriteUInt32((uint)async_debug_info.Yields [i].Offset);
                        async_metadata.WriteUInt32(async_debug_info.resume_methods [i].MetadataToken.ToUInt32());
                        async_metadata.WriteUInt32((uint)async_debug_info.Resumes [i].Offset);
                    }

                    writer.DefineCustomMetadata("asyncMethodInfo", stream.ToArray());
                }
            }
        }
Example #2
0
        public void WriteCustomMetadata()
        {
            if (count == 0)
            {
                return;
            }

            writer.BaseStream.Position = 1;
            writer.WriteByte((byte)count);
            writer.Flush();

            sym_writer.DefineCustomMetadata("MD2", stream.ToArray());
        }