Patch for #58844 approved by lupus
authorGeoff Norton <grompf@sublimeintervention.com>
Thu, 8 Jul 2004 14:28:30 +0000 (14:28 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Thu, 8 Jul 2004 14:28:30 +0000 (14:28 -0000)
svn path=/branches/mono-1-0/mcs/; revision=30873

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/MonoType.cs

index c60096103c195b61d0f426fdf219140b4f57350e..8e4560b1bea5b124cef14585c17f0a1eae819420 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-07  Geoff Norton <gnorton@customerdna.com>
+
+       * Monotype.cs: Patch for bug #58844.  Dont throw exceptions right away;
+         pass through all the possibly BindingInfo's and keep a bool value as to the type
+         of exception we might need to throw;
+
 2004-07-07  Geoff Norton <gnorton@customerdna.com>
 
         * Patch to fix bug #58973
index a04eeb93877541886ee3e61f263629dce567d1a1..395332cf4591f430e37a764ec487fd7f3bf8df7b 100644 (file)
@@ -340,22 +340,26 @@ namespace System
                                name = attr.MemberName;
                        }
                        bool ignoreCase = (invokeAttr & BindingFlags.IgnoreCase) != 0;
+                       bool throwMissingMethodException = false;
+                       bool throwMissingFieldException = false;
                        if ((invokeAttr & BindingFlags.InvokeMethod) != 0) {
                                MethodInfo[] methods = GetMethodsByName (name, invokeAttr, ignoreCase, this);
                                object state = null;
                                MethodBase m = binder.BindToMethod (invokeAttr, methods, ref args, modifiers, culture, namedParameters, out state);
-                               if (m == null)
-                                       throw new MissingMethodException ();
-                               object result = m.Invoke (target, invokeAttr, binder, args, culture);
-                               binder.ReorderArgumentArray (ref args, state);
-                               return result;
+                               if (m == null) {
+                                       throwMissingMethodException = true;
+                               } else {
+                                       object result = m.Invoke (target, invokeAttr, binder, args, culture);
+                                       binder.ReorderArgumentArray (ref args, state);
+                                       return result;
+                               }
                        }
                        if ((invokeAttr & BindingFlags.GetField) != 0) {
                                FieldInfo f = GetField (name, invokeAttr);
                                if (f != null) {
                                        return f.GetValue (target);
                                } else if ((invokeAttr & BindingFlags.GetProperty) == 0) {
-                                       throw new MissingFieldException ();
+                                       throwMissingFieldException = true;
                                }
                                /* try GetProperty */
                        } else if ((invokeAttr & BindingFlags.SetField) != 0) {
@@ -364,7 +368,7 @@ namespace System
                                        f.SetValue (target, args [0]);
                                        return null;
                                } else if ((invokeAttr & BindingFlags.SetProperty) == 0) {
-                                       throw new MissingFieldException ();
+                                       throwMissingFieldException = true;
                                }
                                /* try SetProperty */
                        }
@@ -384,11 +388,13 @@ namespace System
                                                smethods [count++] = mb;
                                }
                                MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state);
-                               if (m == null)
-                                       throw new MissingFieldException ();
-                               object result = m.Invoke (target, invokeAttr, binder, args, culture);
-                               binder.ReorderArgumentArray (ref args, state);
-                               return result;
+                               if (m == null) {
+                                       throwMissingFieldException = true;
+                               } else {
+                                       object result = m.Invoke (target, invokeAttr, binder, args, culture);
+                                       binder.ReorderArgumentArray (ref args, state);
+                                       return result;
+                               }
                        } else if ((invokeAttr & BindingFlags.SetProperty) != 0) {
                                PropertyInfo[] properties = GetPropertiesByName (name, invokeAttr, ignoreCase, this);
                                object state = null;
@@ -405,12 +411,19 @@ namespace System
                                                smethods [count++] = mb;
                                }
                                MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state);
-                               if (m == null)
-                                       throw new MissingFieldException ();
-                               object result = m.Invoke (target, invokeAttr, binder, args, culture);
-                               binder.ReorderArgumentArray (ref args, state);
-                               return result;
+                               if (m == null) {
+                                       throwMissingFieldException = true;
+                               } else {
+                                       object result = m.Invoke (target, invokeAttr, binder, args, culture);
+                                       binder.ReorderArgumentArray (ref args, state);
+                                       return result;
+                               }
                        }
+                       if (throwMissingMethodException)
+                               throw new MissingMethodException();
+                       if (throwMissingFieldException)
+                               throw new MissingFieldException();
+
                        return null;
                }