[Mono-bugs] [Bug 74935][Min] New - improved MonoField exception detail

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 13 May 2005 06:41:31 -0400 (EDT)


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 michael@ximian.com.

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

--- shadow/74935	2005-05-13 06:41:31.000000000 -0400
+++ shadow/74935.tmp.14805	2005-05-13 06:41:31.000000000 -0400
@@ -0,0 +1,43 @@
+Bug#: 74935
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: michael@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: improved MonoField exception detail
+
+This patch helped me track down a problem more quickly:
+
+--- class/corlib/System.Reflection/MonoField.cs (revision 44492)
++++ class/corlib/System.Reflection/MonoField.cs (working copy)
+@@ -118,9 +118,11 @@
+                        if (binder == null)
+                                binder = Binder.DefaultBinder;
+                        if (val != null) {
+-                               val = binder.ChangeType (val, type, culture);
+-                               if (val == null)
+-                                       throw new ArgumentException
+("Object type cannot be converted to target type.", "val");
++                               object newVal;
++                               newVal = binder.ChangeType (val, type,
+culture);
++                               if (newVal == null)
++                                       throw new ArgumentException
+("Object type " + val.GetType() + " cannot be converted to target type: " +
+type, "val");
++                               val = newVal;
+                        }
+                        SetValueInternal (this, obj, val);
+                }
+
+Possibly of dubious value but ...