From 7bc3a8fc207561348d0c6a98381610b5909dae4e Mon Sep 17 00:00:00 2001 From: jbevain Date: Fri, 23 Apr 2010 12:59:05 +0000 Subject: [PATCH] 2010-04-23 Jb Evain * Mono.Cecil/ReflectionWriter.cs: fix writing of exported types. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@156005 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- class/Mono.Cecil/ChangeLog | 4 ++++ class/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/class/Mono.Cecil/ChangeLog b/class/Mono.Cecil/ChangeLog index 27ffdbb704..140b0ea129 100644 --- a/class/Mono.Cecil/ChangeLog +++ b/class/Mono.Cecil/ChangeLog @@ -1,3 +1,7 @@ +2010-04-23 Jb Evain + + * Mono.Cecil/ReflectionWriter.cs: fix writing of exported types. + 2010-04-19 Sebastien Pouliot * Mono.Cecil/ReflectionWriter.cs: Partial (forwarders) fix for diff --git a/class/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs b/class/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs index df38fe3156..418b8941c7 100644 --- a/class/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs +++ b/class/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs @@ -433,23 +433,32 @@ namespace Mono.Cecil { TypeDefinition td = ext.Resolve (); if (td == null) continue; - // FIXME: nested types are not treated correctly - if ((td.Attributes & TypeAttributes.Forwarder) == 0) - continue; + + MetadataToken scope = GetExportedTypeScope (td); + ExportedTypeRow etRow = m_rowWriter.CreateExportedTypeRow ( td.Attributes, - td.MetadataToken.RID, + 0, m_mdWriter.AddString (td.Name), m_mdWriter.AddString (td.Namespace), - new MetadataToken (TokenType.AssemblyRef, - GetRidFor ((AssemblyNameReference) td.Scope))); + scope); + etTable.Rows.Add (etRow); + ext.MetadataToken = new MetadataToken (TokenType.ExportedType, (uint) etTable.Rows.Count); } -// VisitCollection (externs); } - public override void VisitExternType (TypeReference externType) + MetadataToken GetExportedTypeScope (TypeDefinition t) { + if (t.DeclaringType != null) + return t.DeclaringType.MetadataToken; + + if (t.Scope is AssemblyNameReference) + return new MetadataToken (TokenType.AssemblyRef, GetRidFor ((AssemblyNameReference) t.Scope)); + + if (t.Scope is ModuleDefinition) + return new MetadataToken (TokenType.Module, GetRidFor ((ModuleDefinition) t.Scope)); + throw new NotImplementedException (); } -- 2.11.4.GIT