[Mono-bugs] [Bug 41085][Nor] New - Convert.ToXXX(null) bug

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 10 Apr 2003 04:52:28 -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 tam@siulung.com.


--- shadow/41085	Thu Apr 10 04:52:28 2003
+++ shadow/41085.tmp.12901	Thu Apr 10 04:52:28 2003
@@ -0,0 +1,60 @@
+Bug#: 41085
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: Tam@SiuLung.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Convert.ToXXX(null) bug
+Description of Problem:
+System.Convert.ToXXX(object|string[, IFormatProvider])
+XXX = Boolean,Char,Int16,Int32,Int64,UInt16,UInt32,UInt64,Single,Double
+methods may have the first argument null.
+Spec said it should return false/0/0.0f/0.0d for those object overloads
+and throw ArgumentNullException for those string overloads (except 
+Convert.ToXXX(string, int) where the int param is a base).
+Mono throws in all these methods, so something is wrong.
+However, MS Implementation does not throw for ALL these methods, so it is 
+also wrong. But I think many implementations are depending on this 
+behavior, so we should follow.
+using System;
+class Test {
+  public static void Main() {
+    object o = null;
+    string s = null;
+    Console.WriteLine(Convert.ToInt32(o));
+    Console.WriteLine(Convert.ToInt32(s));
+  }
+MS Results:
+Mono Results:
+Both throws ArgumentNullException
+Spec Results:
+How often does this happen? 
+Additional Information:
+Will come with a patch.