[Mono-bugs] [Bug 72244][Nor] New - StringBuilder.ToString() changes capacity of StringBuilder

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 5 Feb 2005 14:52:25 -0500 (EST)


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 gert.driesen@pandora.be.

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

--- shadow/72244	2005-02-05 14:52:25.000000000 -0500
+++ shadow/72244.tmp.13476	2005-02-05 14:52:25.000000000 -0500
@@ -0,0 +1,63 @@
+Bug#: 72244
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Windows XP SP2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gert.driesen@pandora.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: StringBuilder.ToString() changes capacity of StringBuilder
+
+Calling ToString() on a StringBuilder instance modifies the capacity of 
+that instance.
+
+To reproduce this issue, compile and execute the following code snippet :
+
+using System;
+using System.Text;
+
+public class EntryPoint {
+	public static void Main() {
+		StringBuilder sb = new StringBuilder(6, 6);
+		sb.Append('D');
+		sb.Append('A');
+		sb.Append('T');
+		sb.Append('E');
+		
+		Console.WriteLine("Capacity #1: " + sb.Capacity);
+		
+		sb.ToString();
+
+		Console.WriteLine("Capacity #2: " + sb.Capacity);
+
+		sb.Append(' ');
+
+		Console.WriteLine("Capacity #3: " + sb.Capacity);
+	}
+}
+
+Actual Results (using Mono built from SVN):
+
+Capacity #1: 6
+Capacity #2: 4
+
+Unhandled Exception: System.ArgumentOutOfRangeException: capacity was 
+less than the current size.
+Parameter name: size
+in <0x000d6> System.Text.StringBuilder:InternalEnsureCapacity (int)
+in <0x00028> System.Text.StringBuilder:Append (char)
+in <0x000c6> EntryPoint:Main ()
+
+Expect Results (using MS.NET):
+
+Capacity #1: 6
+Capacity #2: 6
+Capacity #3: 6