[sre] Pass declaring type to GetMethodFromHandle in
[mono.git] / mcs / class / corlib / System.Reflection.Emit / GenericTypeParameterBuilder.cs
index a4cfc9ca4fdd2985fc620038b0d4e006580f3609..9bbe8d0d92b32f73ee8976d3aa23780a54250672 100644 (file)
@@ -43,11 +43,7 @@ namespace System.Reflection.Emit
        [ComVisible (true)]
        [StructLayout (LayoutKind.Sequential)]
        public sealed class GenericTypeParameterBuilder : 
-#if NET_4_5
                TypeInfo
-#else
-               Type
-#endif 
        {
        #region Sync with reflection.h
                private TypeBuilder tbuilder;
@@ -86,17 +82,21 @@ namespace System.Reflection.Emit
                        this.mbuilder = mbuilder;
                        this.name = name;
                        this.index = index;
-
-                       initialize ();
                }
 
                internal override Type InternalResolve ()
                {
-                       return tbuilder.InternalResolve ().GetGenericArguments () [index]; 
+                       if (mbuilder != null)
+                               return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal, mbuilder.TypeBuilder.InternalResolve ().TypeHandle).GetGenericArguments () [index];
+                       return tbuilder.InternalResolve ().GetGenericArguments () [index];
                }
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private extern void initialize ();
+               internal override Type RuntimeResolve ()
+               {
+                       if (mbuilder != null)
+                               return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal, mbuilder.TypeBuilder.RuntimeResolve ().TypeHandle).GetGenericArguments () [index];
+                       return tbuilder.RuntimeResolve ().GetGenericArguments () [index];
+               }
 
                [ComVisible (true)]
                public override bool IsSubclassOf (Type c)
@@ -106,11 +106,7 @@ namespace System.Reflection.Emit
 
                protected override TypeAttributes GetAttributeFlagsImpl ()
                {
-#if NET_4_0
                        return TypeAttributes.Public;
-#else
-                       throw not_supported ();
-#endif
                }
 
                protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
@@ -219,6 +215,14 @@ namespace System.Reflection.Emit
                        throw not_supported ();
                }
 
+               public override bool IsAssignableFrom (TypeInfo typeInfo)
+               {
+                       if (typeInfo == null)
+                               return false;
+
+                       return IsAssignableFrom (typeInfo.AsType ());
+               }
+
                public override bool IsInstanceOfType (object o)
                {
                        throw not_supported ();
@@ -444,10 +448,9 @@ namespace System.Reflection.Emit
                        return new ByRefType (this);
                }
 
-               [MonoTODO]
-               public override Type MakeGenericType (params Type [] typeArguments)
+               public override Type MakeGenericType (params Type[] typeArguments)
                {
-                       return base.MakeGenericType (typeArguments);
+                       throw new InvalidOperationException (Environment.GetResourceString ("Arg_NotGenericTypeDefinition"));
                }
 
                public override Type MakePointerType ()