From c0567c50b824e2ff58726bec627c3c270c576d61 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 14 Nov 2013 16:02:32 +0100 Subject: [PATCH] [ilasm] Fixes forwarded types namespace encoding --- mcs/class/PEAPI/PEAPI.cs | 4 ++-- mcs/ilasm/codegen/ExternTable.cs | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mcs/class/PEAPI/PEAPI.cs b/mcs/class/PEAPI/PEAPI.cs index ce259c0739b..46672255e04 100644 --- a/mcs/class/PEAPI/PEAPI.cs +++ b/mcs/class/PEAPI/PEAPI.cs @@ -753,9 +753,9 @@ namespace PEAPI { return modRef; } - public ClassRef AddExternClass(string name, TypeAttr attrs, MetaDataElement declRef) + public ClassRef AddExternClass(string ns, string name, TypeAttr attrs, MetaDataElement declRef) { - return new ExternClassRef (attrs, null, name, declRef, metaData); + return new ExternClassRef (attrs, ns, name, declRef, metaData); } /// diff --git a/mcs/ilasm/codegen/ExternTable.cs b/mcs/ilasm/codegen/ExternTable.cs index 25a46efbf31..1e41fe720c9 100644 --- a/mcs/ilasm/codegen/ExternTable.cs +++ b/mcs/ilasm/codegen/ExternTable.cs @@ -251,13 +251,13 @@ namespace Mono.ILASM { public class ExternClass { - string name; + string fullName; TypeAttr ta; string assemblyReference; - public ExternClass (string name, TypeAttr ta, string assemblyReference) + public ExternClass (string fullName, TypeAttr ta, string assemblyReference) { - this.name = name; + this.fullName = fullName; this.ta = ta; this.assemblyReference = assemblyReference; } @@ -265,8 +265,18 @@ namespace Mono.ILASM { public void Resolve (CodeGen code_gen, ExternTable table) { var ar = table.GetAssemblyRef (assemblyReference); - if (ar != null) - code_gen.PEFile.AddExternClass (name, ta, ar.AssemblyRef); + if (ar != null) { + string ns = null; + string name = fullName; + + int pos = name.LastIndexOf ('.'); + if (pos > 0) { + ns = name.Substring (0, pos); + name = name.Substring (pos + 1); + } + + code_gen.PEFile.AddExternClass (ns, name, ta, ar.AssemblyRef); + } } } -- 2.25.1