Browse Source

2010-03-23 Rodrigo Kumpera <[email protected]>

	* MethodOnTypeBuilderInst.cs (ContainsGenericParameters): Check
	the base_method first.

2010-03-23 Rodrigo Kumpera  <[email protected]>

	* MethodOnTypeBuilderInstTest.cs: Add Test for
	* ContainsGenericParameters.

svn path=/trunk/mcs/; revision=154062
Rodrigo Kumpera 16 years ago
parent
commit
45562016b5

+ 5 - 0
mcs/class/corlib/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,8 @@
+2010-03-23 Rodrigo Kumpera  <[email protected]>
+
+	* MethodOnTypeBuilderInst.cs (ContainsGenericParameters): Check
+	the base_method first.
+
 2010-03-16  Jb Evain  <[email protected]>
 
 	* AssemblyBuilder.cs, ModuleBuilder.cs: use MOONLIGHT symbol to

+ 2 - 0
mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs

@@ -286,6 +286,8 @@ namespace System.Reflection.Emit
 
 		public override bool ContainsGenericParameters {
 			get {
+				if (base_method.ContainsGenericParameters)
+					return true;
 				if (!base_method.IsGenericMethodDefinition)
 					throw new NotSupportedException ();
 				if (method_arguments == null)

+ 4 - 0
mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,7 @@
+2010-03-23 Rodrigo Kumpera  <[email protected]>
+
+	* MethodOnTypeBuilderInstTest.cs: Add Test for ContainsGenericParameters.
+
 2010-03-11 Rodrigo Kumpera  <[email protected]>
 
 	* TypeBuilderTest.cs: New tests for GetMethod, GetConstructor and GetField.

+ 16 - 0
mcs/class/corlib/Test/System.Reflection.Emit/MethodOnTypeBuilderInstTest.cs

@@ -29,6 +29,7 @@
 #if NET_2_0
 
 using System;
+using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
 using System.Reflection;
@@ -684,6 +685,21 @@ namespace MonoTests.System.Reflection.Emit
 			Assert.AreEqual (typeof (int), minst.GetParameters ()[0].ParameterType, "#5");
 			Assert.AreEqual (typeof (int[]), minst.GetParameters ()[1].ParameterType, "#6");
 		}
+
+		[Test]
+		public void PropertiesOfANonGenericMethodOnGenericType ()
+		{
+			Type t = typeof (List<>);
+			Type a = t.GetGenericArguments () [0];
+			MethodInfo m = t.GetMethod ("IndexOf", new Type [] { a });
+	
+			var tb = module.DefineType ("foo.type");
+			Type ttt = t.MakeGenericType (tb);
+			MethodInfo mm = TypeBuilder.GetMethod (ttt, m);
+			Assert.IsTrue (mm.GetGenericMethodDefinition ().ContainsGenericParameters, "#1");
+			Assert.IsTrue (mm.ContainsGenericParameters, "#2");
+		}
+
 	}
 }