Dnia środa, 8 czerwca 2005 22:40, Martin Baulig napisał:
> Hello,
>
> I'll commit it tomorrow morning.
>
> Don't worry, we're waiting with the release to get a few more of my
> fixes in, so this'll definitely go in :-)
>

Sorry you had problems merging this patch. It was created against 45614.
Seems like Zoltan was faster in adding some of the similar API:
http://galactus.ximian.com/pipermail/mono-patches/2005-June/059635.html
in 45626

I'm attaching the new patch, against 45700. Hope the will be no more problems 
(there are still some more 2.0 API additions there, so more conflicts are 
possible).

-- 
Kamil Skalski
http://nazgul.omega.pl
Index: class/corlib/System/Type.cs
===================================================================
--- class/corlib/System/Type.cs	(wersja 45700)
+++ class/corlib/System/Type.cs	(kopia robocza)
@@ -760,6 +760,22 @@
 			return GetMethodImpl (name, bindingAttr, binder, callConvention, types, modifiers);
 		}
 
+		internal virtual MethodInfo GetMethod (MethodInfo fromNoninstanciated)
+                {
+			throw new System.InvalidOperationException ("can only be called in generic type");
+                }
+
+		internal virtual ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
+                {
+			throw new System.InvalidOperationException ("can only be called in generic type");
+                }
+
+		internal virtual FieldInfo GetField (FieldInfo fromNoninstanciated)
+                {
+			throw new System.InvalidOperationException ("can only be called in generic type");
+                }
+
+		
 		public MethodInfo[] GetMethods ()
 		{
 			return GetMethods (DefaultBindingFlags);
@@ -1110,6 +1126,11 @@
 			return res;
 		}
 
+                public Type MakeGenericType (Type[] types)
+                {
+			return BindGenericParameters (types);
+                }
+
 		public abstract bool IsGenericParameter {
 			get;
 		}
Index: class/corlib/System/ChangeLog
===================================================================
--- class/corlib/System/ChangeLog	(wersja 45700)
+++ class/corlib/System/ChangeLog	(kopia robocza)
@@ -1,3 +1,9 @@
+2005-06-09  Kamil Skalski <[EMAIL PROTECTED]>
+	* Type.cs: Add MakeGenericType method form .NET 2.0 beta 2 API
+
+	* Type.cs MonoType.cs: Add internal virtual Get{Method,Constructor,Field} 
+	for obtaining instanciated *Info objects from non-instanciated counterparts
+
 2005-06-09  Zoltan Varga  <[EMAIL PROTECTED]>
 
 	* ModuleHandle RuntimeMethodHandle.cs RuntimeTypeHandle.cs RuntimeFieldHandle.cs RuntimeArgumentHandle.cs: Add missing 2.0 attributes.
Index: class/corlib/System/MonoType.cs
===================================================================
--- class/corlib/System/MonoType.cs	(wersja 45700)
+++ class/corlib/System/MonoType.cs	(kopia robocza)
@@ -224,6 +224,31 @@
 		}
 
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern MethodInfo GetCorrespondingInflatedMethod (IntPtr generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern ConstructorInfo GetCorrespondingInflatedConstructor (IntPtr generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern FieldInfo GetCorrespondingInflatedField (IntPtr generic);
+
+
+		internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
+                {
+                        return GetCorrespondingInflatedMethod (fromNoninstanciated.MethodHandle.Value);
+                }
+
+		internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
+		{
+                        return GetCorrespondingInflatedConstructor (fromNoninstanciated.MethodHandle.Value);
+		}
+
+		internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
+		{
+                        return GetCorrespondingInflatedField (fromNoninstanciated.FieldHandle.Value);
+		}
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
 		public extern override Type GetNestedType (string name, BindingFlags bindingAttr);
 
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
Index: class/corlib/System.Reflection.Emit/FieldBuilder.cs
===================================================================
--- class/corlib/System.Reflection.Emit/FieldBuilder.cs	(wersja 45700)
+++ class/corlib/System.Reflection.Emit/FieldBuilder.cs	(kopia robocza)
@@ -80,7 +80,7 @@
 
 		public override RuntimeFieldHandle FieldHandle {
 			get {
-				throw CreateNotSupportedException ();
+				return handle;
 			}
 		}
 
Index: class/corlib/System.Reflection.Emit/ChangeLog
===================================================================
--- class/corlib/System.Reflection.Emit/ChangeLog	(wersja 45700)
+++ class/corlib/System.Reflection.Emit/ChangeLog	(kopia robocza)
@@ -1,3 +1,11 @@
+2005-06-09  Kamil Skalski <[EMAIL PROTECTED]>
+	* ConstructorBuilder.cs FieldBuilders.cs MethodBuilder.cs: Return
+	RuntimeHandles when requested
+	
+	* TypeBuilder.cs: Add static Get{Method,Constructor,Field} methods
+	from .NET 2.0 beta 2 API for obtaining instanciated *Info objects
+	from non-instanciated counterparts 
+
 2005-06-08  Zoltan Varga  <[EMAIL PROTECTED]>
 
 	* ConstructorBuilder.cs FieldBuilder.cs MethodBuilder.cs PropertyBuilder.cs:
Index: class/corlib/System.Reflection.Emit/MethodBuilder.cs
===================================================================
--- class/corlib/System.Reflection.Emit/MethodBuilder.cs	(wersja 45700)
+++ class/corlib/System.Reflection.Emit/MethodBuilder.cs	(kopia robocza)
@@ -126,7 +126,7 @@
 
 		public override RuntimeMethodHandle MethodHandle {
 			get {
-				throw NotSupported ();
+				return mhandle;
 			}
 		}
 
Index: class/corlib/System.Reflection.Emit/TypeBuilder.cs
===================================================================
--- class/corlib/System.Reflection.Emit/TypeBuilder.cs	(wersja 45700)
+++ class/corlib/System.Reflection.Emit/TypeBuilder.cs	(kopia robocza)
@@ -1468,7 +1468,7 @@
 
 		public override bool HasGenericArguments {
 			get {
-				throw new NotImplementedException ();
+				return generic_params != null;
 			}
 		}
 
@@ -1511,6 +1511,33 @@
 		{
 			return DefineMethod (name, attributes, CallingConventions.Standard, null, null);
 		}
+
+                public static ConstructorInfo GetConstructor (Type instanciated, ConstructorInfo ctor)
+                {
+			ConstructorInfo res = instanciated.GetConstructor (ctor);
+			if (res == null)
+				throw new System.Exception ("constructor not found");
+			else
+				return res;
+                }
+
+                public static MethodInfo GetMethod (Type instanciated, MethodInfo meth)
+                {
+			MethodInfo res = instanciated.GetMethod (meth);
+			if (res == null)
+				throw new System.Exception ("method not found");
+			else
+				return res;
+                }
+
+                public static FieldInfo GetField (Type instanciated, FieldInfo fld)
+                {
+			FieldInfo res = instanciated.GetField (fld);
+			if (res == null)
+				throw new System.Exception ("field not found");
+			else
+				return res;
+                }
 #endif
 	}
 }
Index: class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
===================================================================
--- class/corlib/System.Reflection.Emit/ConstructorBuilder.cs	(wersja 45700)
+++ class/corlib/System.Reflection.Emit/ConstructorBuilder.cs	(kopia robocza)
@@ -120,7 +120,7 @@
 
 		public override RuntimeMethodHandle MethodHandle { 
 			get {
-				throw not_supported ();
+				return mhandle;
 			}
 		}
 
Index: class/corlib/System.Reflection/ChangeLog
===================================================================
--- class/corlib/System.Reflection/ChangeLog	(wersja 45700)
+++ class/corlib/System.Reflection/ChangeLog	(kopia robocza)
@@ -1,3 +1,8 @@
+2005-06-09  Kamil Skalski <[EMAIL PROTECTED]>
+	* MonoGenericClass.cs: Add overrides of Get{Method,Constructor,Field} 
+	for obtaining instanciated *Info objects from non-instanciated counterparts
+
+
 2005-06-09  Zoltan Varga  <[EMAIL PROTECTED]>
 
 	* CustomAttributeData.cs EventInfo.cs Assembly.cs: Updates for net 2.0 beta 2.
Index: class/corlib/System.Reflection/MonoGenericClass.cs
===================================================================
--- class/corlib/System.Reflection/MonoGenericClass.cs	(wersja 45700)
+++ class/corlib/System.Reflection/MonoGenericClass.cs	(kopia robocza)
@@ -57,6 +57,15 @@
 		protected extern void initialize (MethodInfo[] methods, ConstructorInfo[] ctors, FieldInfo[] fields, PropertyInfo[] properties, EventInfo[] events);
 
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern MethodInfo GetCorrespondingInflatedMethod (IntPtr generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern ConstructorInfo GetCorrespondingInflatedConstructor (IntPtr generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern FieldInfo GetCorrespondingInflatedField (IntPtr generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
 		protected extern MethodInfo[] GetMethods_internal (Type reflected_type);
 
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -123,6 +132,27 @@
 			return generic_type.IsValueType;
 		}
 
+		internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
+		{
+			initialize ();
+
+			return GetCorrespondingInflatedMethod (fromNoninstanciated.MethodHandle.Value);
+		}
+
+		internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
+		{
+			initialize ();
+
+			return GetCorrespondingInflatedConstructor (fromNoninstanciated.MethodHandle.Value);
+		}
+
+		internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
+		{
+			initialize ();
+
+			return GetCorrespondingInflatedField (fromNoninstanciated.FieldHandle.Value);
+		}
+		
 		public override MethodInfo[] GetMethods (BindingFlags bf)
 		{
 			ArrayList l = new ArrayList ();
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to