Add all missing sequential layout directives to corlib and system.
[mono.git] / mcs / class / corlib / System.Text / StringBuilder.cs
index c642d8d21c5121792f457f7d00a4f5044b2fd4ee..bfc8a8925e5db98a753853492dbdb5598a6b0016 100644 (file)
@@ -16,6 +16,7 @@
 
 //
 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright 2011 Xamarin Inc
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -43,14 +44,10 @@ using System.Runtime.InteropServices;
 namespace System.Text {
        
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
-        [MonoTODO ("Serialization format not compatible with .NET")]
-       public sealed class StringBuilder
-#if NET_2_0
-               : ISerializable
-#endif
+        [MonoLimitation ("Serialization format not compatible with .NET")]
+       [StructLayout (LayoutKind.Sequential)]
+       public sealed class StringBuilder : ISerializable
        {
                private int _length;
                private string _str;
@@ -213,7 +210,7 @@ namespace System.Text {
                                return _cached_str;
 
                        // If we only have a half-full buffer we return a new string.
-                       if (_length < (_str.Length >> 1)
+                       if (_length < (_str.Length >> 1) || (_str.Length > string.LOS_limit && _length <= string.LOS_limit))
                        {
                                // use String.SubstringUnchecked instead of String.Substring
                                // as the former is guaranteed to create a new string object
@@ -508,10 +505,11 @@ namespace System.Text {
                        return this;
                }
 
-#if NET_4_0
-               public void Clear ()
+#if NET_4_0 || MOONLIGHT || MOBILE
+               public StringBuilder Clear ()
                {
-                       _length = 0;
+                       Length = 0;
+                       return this;
                }
 #endif
 
@@ -540,7 +538,7 @@ namespace System.Text {
                        return this;
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -550,7 +548,7 @@ namespace System.Text {
                        return AppendFormat (null, format, new object [] { arg0 });
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public
@@ -560,7 +558,7 @@ namespace System.Text {
                        return AppendFormat (null, format, new object [] { arg0, arg1 });
                }
 
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
                internal
 #else
                public