2004-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 5 Jun 2004 06:36:12 +0000 (06:36 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 5 Jun 2004 06:36:12 +0000 (06:36 -0000)
* Binder.cs: don't crash when we have a 'null' argument Type array.
Allow it for non-value types. Fixed for both, methods and properties.
Closes bug #58846.

svn path=/trunk/mcs/; revision=28859

mcs/class/corlib/System.Reflection/Binder.cs
mcs/class/corlib/System.Reflection/ChangeLog

index 6cef7944f78cc3d520bfbe9dc8b6635228f02be6..01fcfff813927e6f2ee0543013814cca995ffeb1 100644 (file)
@@ -167,6 +167,10 @@ namespace System.Reflection
                        private static bool check_type (Type from, Type to) {
                                if (from == to)
                                        return true;
+
+                               if (from == null)
+                                       return !to.IsValueType;
+
                                TypeCode fromt = Type.GetTypeCode (from);
                                TypeCode tot = Type.GetTypeCode (to);
 
@@ -385,13 +389,16 @@ namespace System.Reflection
                                return worst;
                        }
 
-                       // 0 -> same type
+                       // 0 -> same type or null and !valuetype
                        // 1 -> to == Enum
                        // 2 -> value type that don't lose data
                        // 3 -> to == IsAssignableFrom
                        // 4 -> to == object
                        static int check_type_with_score (Type from, Type to)
                        {
+                               if (from == null)
+                                       return to.IsValueType ? -1 : 0;
+
                                if (from == to)
                                        return 0;
 
index 55f00a5b49814751dc69cb9a7bf2268ddc187cfb..15195e35d609a752606c1308167b7a141aadb5cc 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-05  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * Binder.cs: don't crash when we have a 'null' argument Type array.
+       Allow it for non-value types. Fixed for both, methods and properties.
+       Closes bug #58846.
+
 2004-06-02  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Binder.cs: default score must be lower than fail_score or we'll get