public override void VisitMetadataRoot(MetadataRoot root) { WriteMemStream(m_cilWriter); WriteMemStream(m_fieldDataWriter); m_resStart = (uint)m_binaryWriter.BaseStream.Position; WriteMemStream(m_resWriter); m_resSize = (uint)(m_binaryWriter.BaseStream.Position - m_resStart); // for now, we only reserve the place for the strong name signature if ((m_assembly.Name.Flags & AssemblyFlags.PublicKey) > 0) { m_snsStart = (uint)m_binaryWriter.BaseStream.Position; m_snsSize = GetStrongNameSignatureSize(); m_binaryWriter.Write(new byte [m_snsSize]); m_binaryWriter.QuadAlign(); } // save place for debug header if (m_imgWriter.GetImage().DebugHeader != null) { m_debugHeaderStart = (uint)m_binaryWriter.BaseStream.Position; m_binaryWriter.Write(new byte [m_imgWriter.GetImage().DebugHeader.GetSize()]); m_binaryWriter.QuadAlign(); } m_mdStart = (uint)m_binaryWriter.BaseStream.Position; if (m_stringWriter.BaseStream.Length > 1) { CreateStream(MetadataStream.Strings); SetHeapSize(root.Streams.StringsHeap, m_stringWriter, 0x01); m_stringWriter.QuadAlign(); } if (m_guidWriter.BaseStream.Length > 0) { CreateStream(MetadataStream.GUID); SetHeapSize(root.Streams.GuidHeap, m_guidWriter, 0x02); } if (m_blobWriter.BaseStream.Length > 1) { CreateStream(MetadataStream.Blob); SetHeapSize(root.Streams.BlobHeap, m_blobWriter, 0x04); m_blobWriter.QuadAlign(); } if (m_usWriter.BaseStream.Length > 2) { CreateStream(MetadataStream.UserStrings); m_usWriter.QuadAlign(); } m_root.Header.MajorVersion = 1; m_root.Header.MinorVersion = 1; switch (m_runtime) { case TargetRuntime.NET_1_0: m_root.Header.Version = "v1.0.3705"; break; case TargetRuntime.NET_1_1: m_root.Header.Version = "v1.1.4322"; break; case TargetRuntime.NET_2_0: m_root.Header.Version = "v2.0.50727"; break; case TargetRuntime.NET_4_0: m_root.Header.Version = "v4.0.30319"; break; } m_root.Streams.TablesHeap.Tables.Accept(m_tableWriter); if (m_tWriter.BaseStream.Length == 0) { m_root.Streams.Remove(m_root.Streams.TablesHeap.GetStream()); } }