From 1629a3d754ea0b44b673e4c2ccefaa02013a7941 Mon Sep 17 00:00:00 2001 From: jfrijters Date: Tue, 15 Jan 2013 15:31:16 +0000 Subject: [PATCH] Made EditorBrowsableAttribute construction fully symbolic, to avoid having to load System.dll. --- runtime/TypeWrapper.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index 04338ad9..e9a171aa 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -335,19 +335,20 @@ namespace IKVM.Internal } } - private static Assembly GetSystemAssembly() - { - AssemblyName name = Types.Object.Assembly.GetName(); - name.Name = "System"; - return StaticCompiler.Load(name.FullName); - } - private static CustomAttributeBuilder GetEditorBrowsableNever() { if (editorBrowsableNever == null) { - Assembly system = GetSystemAssembly(); - editorBrowsableNever = new CustomAttributeBuilder(system.GetType("System.ComponentModel.EditorBrowsableAttribute", true).GetConstructor(new Type[] { system.GetType("System.ComponentModel.EditorBrowsableState", true) }), new object[] { (int)System.ComponentModel.EditorBrowsableState.Never }); + // to avoid having to load (and find) System.dll, we construct a symbolic CustomAttributeBuilder + AssemblyName name = Types.Object.Assembly.GetName(); + name.Name = "System"; + Universe u = StaticCompiler.Universe; + Type typeofEditorBrowsableAttribute = u.ResolveType(Types.Object.Assembly, "System.ComponentModel.EditorBrowsableAttribute, " + name.FullName); + Type typeofEditorBrowsableState = u.ResolveType(Types.Object.Assembly, "System.ComponentModel.EditorBrowsableState, " + name.FullName); + u.MissingTypeIsValueType += delegate(Type type) { return type == typeofEditorBrowsableState; }; + ConstructorInfo ctor = (ConstructorInfo)typeofEditorBrowsableAttribute.__CreateMissingMethod(ConstructorInfo.ConstructorName, + CallingConventions.Standard | CallingConventions.HasThis, null, default(CustomModifiers), new Type[] { typeofEditorBrowsableState }, null); + editorBrowsableNever = CustomAttributeBuilder.__FromBlob(ctor, new byte[] { 01, 00, 01, 00, 00, 00, 00, 00 }); } return editorBrowsableNever; }