Author: calberto
Date: 2005-04-08 00:51:53 -0400 (Fri, 08 Apr 2005)
New Revision: 42673
Modified:
trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
trunk/mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
Log:
2005-04-08 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* AssemblyTest.cs: Added tests for ReflectionOnly support.
* MethodInfoTest.cs: Added test for Reflection Only support.
* FieldInfoTest.cs: Added tests for ReflectionOnly support.
Modified: trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
2005-04-08 00:32:15 UTC (rev 42672)
+++ trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
2005-04-08 04:51:53 UTC (rev 42673)
@@ -188,6 +188,36 @@
Assembly corlib2 = Assembly.LoadWithPartialName
("corlib_plattest");
Assert.IsTrue (corlib != null || corlib2 != null);
}
+
+#if NET_2_0
+ [Test]
+ public void ReflectionOnlyLoad ()
+ {
+ Assembly assembly = Assembly.ReflectionOnlyLoad (typeof
(AssemblyTest).Assembly.FullName);
+
+ Assert.IsNotNull (assembly);
+ Assert.IsTrue (assembly.ReflectionOnly);
+ }
+
+ [Test]
+ public void ReflectionOnlyLoadFrom ()
+ {
+ string loc = typeof (AssemblyTest).Assembly.Location;
+ string filename = Path.GetFileName (loc);
+ Assembly assembly = Assembly.ReflectionOnlyLoadFrom
(filename);
+
+ Assert.IsNotNull (assembly);
+ Assert.IsTrue (assembly.ReflectionOnly);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void CreateInstanceOnRefOnly ()
+ {
+ Assembly assembly = Assembly.ReflectionOnlyLoad (typeof
(AssemblyTest).Assembly.FullName);
+ assembly.CreateInstance
("MonoTests.System.Reflection.AssemblyTest");
+ }
+#endif
}
}
Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog 2005-04-08
00:32:15 UTC (rev 42672)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog 2005-04-08
04:51:53 UTC (rev 42673)
@@ -1,3 +1,9 @@
+2005-04-08 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * AssemblyTest.cs: Added tests for ReflectionOnly support.
+ * MethodInfoTest.cs: Added test for Reflection Only support.
+ * FieldInfoTest.cs: Added tests for ReflectionOnly support.
+
2005-04-04 Sebastien Pouliot <[EMAIL PROTECTED]>
* AssemblyNameTest.cs: Added tests for Clone and serialization without
Modified: trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
2005-04-08 00:32:15 UTC (rev 42672)
+++ trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
2005-04-08 04:51:53 UTC (rev 42673)
@@ -95,6 +95,37 @@
AssertEquals (typeof (Marshal1), Type.GetType
(attr.MarshalType));
*/
}
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void GetValueOnRefOnlyAssembly ()
+ {
+ Assembly assembly = Assembly.ReflectionOnlyLoad (typeof
(FieldInfoTest).Assembly.FullName);
+ Type t = assembly.GetType (typeof (RefOnlyClass).FullName);
+ FieldInfo f = t.GetField ("RefOnlyField", BindingFlags.Static |
BindingFlags.NonPublic);
+
+ f.GetValue (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void SetValueOnRefOnlyAssembly ()
+ {
+ Assembly assembly = Assembly.ReflectionOnlyLoad (typeof
(FieldInfoTest).Assembly.FullName);
+ Type t = assembly.GetType (typeof (RefOnlyClass).FullName);
+ FieldInfo f = t.GetField ("RefOnlyField", BindingFlags.Static |
BindingFlags.NonPublic);
+
+ f.SetValue (null, 8);
+ }
+
#endif
}
+#if NET_2_0
+// Helper class
+class RefOnlyClass
+{
+ // Helper property
+ static int RefOnlyField;
}
+#endif
+}
Modified: trunk/mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
2005-04-08 00:32:15 UTC (rev 42672)
+++ trunk/mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
2005-04-08 04:51:53 UTC (rev 42673)
@@ -153,7 +153,30 @@
else
AssertEquals (false, locals [1].IsPinned);
}
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void InvokeOnRefOnlyAssembly ()
+ {
+ Assembly a = Assembly.ReflectionOnlyLoad (typeof
(MethodInfoTest).Assembly.FullName);
+ Type t = a.GetType (typeof (RefOnlyClass).FullName);
+ MethodInfo m = t.GetMethod ("RefOnlyMethod",
BindingFlags.Static | BindingFlags.NonPublic);
+
+ m.Invoke (null, new object [0]);
+ }
+
#endif
}
+
+#if NET_2_0
+ // Helper class
+ class RefOnlyClass
+ {
+ // Helper static method
+ static void RefOnlyMethod ()
+ {
+ }
+ }
+#endif
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches