[Mono-bugs] [Bug 43431][Nor] Changed - StringWriter .ctor(CultureInfo) does not create a new StringBuilder ()

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 21 May 2003 08:38:29 -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 bmaurer@users.sf.net.

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

--- shadow/43431	Tue May 20 23:26:22 2003
+++ shadow/43431.tmp.22913	Wed May 21 08:38:29 2003
@@ -2,22 +2,22 @@
 Product: Mono/Class Libraries
 Version: unspecified
 OS: All
 OS Details: behaviour observed on windows and gentoo linux
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: 001 One hour
 Priority: Normal
 Component: CORLIB
-AssignedTo: mono-bugs@ximian.com                            
+AssignedTo: bmaurer@users.sf.net                            
 ReportedBy: ianm@activestate.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: StringWriter fails if CultureInfo passed to its constructor
+Summary: StringWriter .ctor(CultureInfo) does not create a new StringBuilder ()
 
 The stringWriter class has a constructor that takes a 
 System.IFormatProvider  argument. If an instance is created passing
 CultureInfo.InvariantCulture then the write methods of the stringWriter
 will fail with :
 Unhandled Exception: System.NullReferenceException: A null value was found
@@ -39,6 +39,43 @@
 StringWriter(CultureInfo.InvariantCulture); //        
         bodyWriter.Write("foo");
         bodyWriter.WriteLine("foo bar");
         Console.WriteLine(bodyWriter.ToString());       
     }
 }
+
+------- Additional Comments From bmaurer@users.sf.net  2003-05-21 08:38 -------
+Ok, here is the problem:
+
+This is part of the StringWriter code:
+
+                public StringWriter() {
+                        internalString = new StringBuilder();
+                }
+
+                public StringWriter( IFormatProvider formatProvider ) 
+{
+                        internalFormatProvider = formatProvider;
+                }
+
+                public StringWriter( StringBuilder sb ) : this (sb, 
+null) {
+
+                }
+
+                public StringWriter( StringBuilder sb, 
+IFormatProvider formatProvider ) {
+                        
+                        if (sb == null)
+                                throw new ArgumentNullException ();
+
+                        internalString = sb;
+                        internalFormatProvider = formatProvider;
+                }
+
+As you can see, with your constructor, the StringBuilder is null. We 
+need to change it to a call to the other constructor. I will fix this 
+tonight, unless someone gets to it first.
+
+It would be great if you (or someone else) would make a test case.
+
+