소스 검색

2004-02-11 Zoltan Varga <[email protected]>

	* MethodBuilderTest.cs: Add tests for parameter info.

svn path=/trunk/mcs/; revision=22970
Zoltan Varga 22 년 전
부모
커밋
b2a4f152ab
2개의 변경된 파일32개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
  2. 28 0
      mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs

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

@@ -1,3 +1,7 @@
+2004-02-11  Zoltan Varga  <[email protected]>
+
+	* MethodBuilderTest.cs: Add tests for parameter info.
+
 2004-01-27  Zoltan Varga  <[email protected]>
 
 	* AssemblyBuilderTest.cs (TestCustomAttributes): Remove 

+ 28 - 0
mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs

@@ -497,5 +497,33 @@ public class MethodBuilderTest : Assertion
 		mb.AddDeclarativeSecurity (SecurityAction.Demand, set);
 		mb.AddDeclarativeSecurity (SecurityAction.Demand, set);
 	}
+
+	[AttributeUsage (AttributeTargets.Parameter)]
+	class ParamAttribute : Attribute {
+
+		public ParamAttribute () {
+		}
+	}
+
+	[Test]
+	public void TestDynamicParams () {
+		string mname = genMethodName ();
+
+		MethodBuilder mb = genClass.DefineMethod (
+			mname, MethodAttributes.Public, typeof (void), 
+			new Type [] { typeof (string) });
+		ParameterBuilder pb = mb.DefineParameter (1, 0, "foo");
+		pb.SetCustomAttribute (new CustomAttributeBuilder (typeof (ParamAttribute).GetConstructors () [0], new object [] { }));
+
+		Type t = genClass.CreateType ();
+		MethodInfo m = t.GetMethod (mname);
+		ParameterInfo pi = m.GetParameters ()[0];
+
+		AssertEquals ("foo", pi.Name);
+
+		object[] cattrs = pi.GetCustomAttributes (true);
+		AssertEquals (1, cattrs.Length);
+		AssertEquals (typeof (ParamAttribute), cattrs [0].GetType ());
+	}
 }
 }