[Mono-list] Re: Small patch for Delegate.cs

Ricardo Fernández Pascual rfp1@ono.com
03 Sep 2002 16:11:19 +0200


--=-J+bPA4sjHzN7npFOJMFz
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable


Sorry for replying to myself, but this new patch (which obsoletes the
previous one) fixes the same problem in all the overloaded versions of
Delegate.CreateDelegate.

El mar, 03-09-2002 a las 15:52, Ricardo Fern=E1ndez Pascual escribi=F3:
>=20
> Hi,
>     The following patch fixes a crash in mono when invoking
> Delegate.Createdelegate(Type,object,string) with a wrong method name
> string. Also, I think this is what the docs say that should be done.
>=20
> The doc that I used is:
> http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/cpref/=
html/frlrfsystemdelegateclasscreatedelegatetopic2.asp
>=20
> Greetings,
> Ricardo


--=20
Ricardo Fern=E1ndez Pascual
ric@users.sourceforge.net
Murcia. Espa=F1a.

--=-J+bPA4sjHzN7npFOJMFz
Content-Disposition: attachment; filename=Delegate.cs.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=Delegate.cs.diff; charset=ISO-8859-15

Index: class/corlib/System/Delegate.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/mcs/class/corlib/System/Delegate.cs,v
retrieving revision 1.19
diff -u -r1.19 Delegate.cs
--- class/corlib/System/Delegate.cs	19 Aug 2002 13:27:58 -0000	1.19
+++ class/corlib/System/Delegate.cs	3 Sep 2002 13:58:39 -0000
@@ -98,6 +98,11 @@
=20
 			BindingFlags flags =3D  BindingFlags.Public | BindingFlags.Instance;
 			MethodInfo info =3D target.GetType ().GetMethod (method, flags);
+		=09
+			if (info =3D=3D null)
+				throw new ArgumentException=20
+					(Locale.GetText ("method string is not an instance method name"));
+
 			return CreateDelegate_internal (type, target, info);
 		}
=20
@@ -114,6 +119,11 @@
=20
 			BindingFlags flags =3D  BindingFlags.Public | BindingFlags.Static;
 			MethodInfo info =3D target.GetMethod (method, flags);
+
+			if (info =3D=3D null)
+				throw new ArgumentException=20
+					(Locale.GetText ("method string is not a static method name"));
+
 			return CreateDelegate_internal (type, null, info);
 		}
=20
@@ -131,6 +141,11 @@
 			Type target_type =3D target.GetType ();
 			BindingFlags flags =3D  BindingFlags.Public | BindingFlags.Instance | B=
indingFlags.IgnoreCase;
 			MethodInfo info =3D target_type.GetMethod (method, flags);
+
+			if (info =3D=3D null)
+				throw new ArgumentException=20
+					(Locale.GetText ("method string is not an instance method name"));
+
 			return CreateDelegate_internal (type, target, info);		=09
 		}
=20

--=-J+bPA4sjHzN7npFOJMFz--