diff options
-rw-r--r-- | mcs/class/corlib/System.Reflection/MonoMethod.cs | 1 | ||||
-rw-r--r-- | mcs/class/corlib/Test/System/AppDomainTest.cs | 73 |
2 files changed, 74 insertions, 0 deletions
diff --git a/mcs/class/corlib/System.Reflection/MonoMethod.cs b/mcs/class/corlib/System.Reflection/MonoMethod.cs index f46c01a226d..b6a119e3208 100644 --- a/mcs/class/corlib/System.Reflection/MonoMethod.cs +++ b/mcs/class/corlib/System.Reflection/MonoMethod.cs @@ -464,6 +464,7 @@ namespace System.Reflection { #endif } + [Serializable()] [StructLayout (LayoutKind.Sequential)] internal class MonoCMethod : ConstructorInfo, ISerializable { diff --git a/mcs/class/corlib/Test/System/AppDomainTest.cs b/mcs/class/corlib/Test/System/AppDomainTest.cs index 54ba7cef2a8..1d88666538f 100644 --- a/mcs/class/corlib/Test/System/AppDomainTest.cs +++ b/mcs/class/corlib/Test/System/AppDomainTest.cs @@ -3261,6 +3261,74 @@ namespace MonoTests.System } #endif + public class StuffToPick + { + public StuffToPick () {} + public void Method () {} + public int Property { get; set; } + public event Action Event; + public int Field; + public void GenericMethod<T> () {} + } + + public class StuffToPick<T> + { + public StuffToPick () {} + public void Method () {} + public int Property { get; set; } + public event Action Event; + public int Field; + public void GenericMethod<T> () {} + } + + static void TestSerialization (CrossDomainTester tester, object o) + { + Assert.AreSame (o, tester.ReturnArg0 (o), "serializing_type_" + o.GetType ()); + } + + [Test] //BXC #12611 + public void ReflectionObjectsAreSerializableTest () + { + ad = CreateTestDomain (tempDir, true); + CrossDomainTester tester = CreateCrossDomainTester (ad); + + TestSerialization (tester, typeof (StuffToPick)); + TestSerialization (tester, typeof (StuffToPick).GetConstructor(new Type [0])); + TestSerialization (tester, typeof (StuffToPick).GetMethod ("Method")); + TestSerialization (tester, typeof (StuffToPick).GetProperty ("Property")); + TestSerialization (tester, typeof (StuffToPick).GetEvent ("Event")); + TestSerialization (tester, typeof (StuffToPick).GetField ("Field")); + TestSerialization (tester, typeof (StuffToPick).GetMethod ("GenericMethod")); + + TestSerialization (tester, typeof (StuffToPick<>)); + TestSerialization (tester, typeof (StuffToPick<>).GetConstructor(new Type [0])); + TestSerialization (tester, typeof (StuffToPick<>).GetMethod ("Method")); + TestSerialization (tester, typeof (StuffToPick<>).GetProperty ("Property")); + TestSerialization (tester, typeof (StuffToPick<>).GetEvent ("Event")); + TestSerialization (tester, typeof (StuffToPick<>).GetField ("Field")); + TestSerialization (tester, typeof (StuffToPick<>).GetMethod ("GenericMethod")); + + TestSerialization (tester, typeof (StuffToPick<int>)); + TestSerialization (tester, typeof (StuffToPick<int>).GetConstructor(new Type [0])); + TestSerialization (tester, typeof (StuffToPick<int>).GetMethod ("Method")); + TestSerialization (tester, typeof (StuffToPick<int>).GetProperty ("Property")); + TestSerialization (tester, typeof (StuffToPick<int>).GetEvent ("Event")); + TestSerialization (tester, typeof (StuffToPick<int>).GetField ("Field")); + TestSerialization (tester, typeof (StuffToPick<int>).GetMethod ("GenericMethod")); + } + + [Test] //BXC #12611 + [Category ("NotWorking")] // Serialization can't handle generic methods + public void GenericReflectionObjectsAreSerializableTest () + { + ad = CreateTestDomain (tempDir, true); + CrossDomainTester tester = CreateCrossDomainTester (ad); + + TestSerialization (tester, typeof (StuffToPick).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int))); + TestSerialization (tester, typeof (StuffToPick<>).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int))); + TestSerialization (tester, typeof (StuffToPick<int>).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int))); + } + private static AppDomain CreateTestDomain (string baseDirectory, bool assemblyResolver) { AppDomainSetup setup = new AppDomainSetup (); @@ -3395,6 +3463,11 @@ namespace MonoTests.System return true; } } + + public object ReturnArg0 (object obj) + { + return obj; + } } [Serializable ()] |