[Mono-bugs] [Bug 30159][Maj] New - System.Delegate.CreateDelegate() is not testing the type of the first parameter (it must be son of Delegate)

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
10 Sep 2002 21:08:33 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kiwnix@yahoo.es.

http://bugzilla.ximian.com/show_bug.cgi?id=30159

--- shadow/30159	Tue Sep 10 17:08:33 2002
+++ shadow/30159.tmp.29675	Tue Sep 10 17:08:33 2002
@@ -0,0 +1,72 @@
+Bug#: 30159
+Product: Mono/Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: kiwnix@yahoo.es               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.Delegate.CreateDelegate() is not testing the type of the first parameter (it must be son of Delegate)
+
+Description of Problem:
+
+If you give a Incorrect type to System Delegate.CreateDelegate() it fais
+with the incorrect exception (an assertion failed) and it should with a
+incorrect type one
+
+Actual Results:
+
+Unhandled Exception: System.ExecutionEngineException: file icall.c: line
+2141 (ves_icall_System_Delegate_CreateDelegate_internal): assertion failed:
+(delegate_class->parent == mono_defaults.multicastdelegate_class)
+in (unmanaged) 06 System.Delegate:CreateDelegate_internal
+(System.Type,object,System.Reflection.MethodInfo)
+in <0x00004> 06 System.Delegate:CreateDelegate_internal
+(System.Type,object,System.Reflection.MethodInfo)
+in <0x00082> 00 System.Delegate:CreateDelegate
+(System.Type,System.Reflection.MethodInfo)
+in <0x00056> 00 .ComprobacionDelegados:Main ()
+
+Expected Results:
+
+Unhandled Exception: System.ArgumentException: Type must derive from Delegate.
+Parameter name: type
+   at System.Delegate.CreateDelegate(Type type, MethodInfo method)
+   at ComprobacionDelegados.Main()
+
+Additional Information:
+
+It should test if the type passed is subclass of Delegate. If it's not, it
+must throw the exception
+
+Test:
+using System;
+using System.Reflection;
+
+public delegate void D();
+
+public class ComprobacionDelegados	
+{
+  public static void Main ()
+  {
+    Type t = typeof(ComprobacionDelegados);
+    MethodInfo m = t.GetMethod("Metodo1");
+    D obj  = (D) Delegate.CreateDelegate(typeof(Object),m);
+    obj();
+  } 
+
+  public static void Metodo1 (string s)
+  {
+    Console.WriteLine("Mostrando"); //if S is not used, 
+                                    //the problem doesnt appear
+                                    //But a exception should be thrown
+  }
+}