Author: atsushi
Date: 2007-05-23 06:40:09 -0400 (Wed, 23 May 2007)
New Revision: 77828

Modified:
   trunk/mcs/class/corlib/System/Array.cs
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/Convert.cs
   trunk/mcs/class/corlib/System/DataMisalignedException.cs
   trunk/mcs/class/corlib/System/String.cs
Log:
2007-05-22  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * Convert.cs : completed 2.0 (ToBase64CharArray).
        * String.cs : removed MonoTODO.
        * DataMisalignedException.cs : removed extra .ctor().
        * Array.cs : internalize extra members. Fixed reliability contract.



Modified: trunk/mcs/class/corlib/System/Array.cs
===================================================================
--- trunk/mcs/class/corlib/System/Array.cs      2007-05-23 10:38:52 UTC (rev 
77827)
+++ trunk/mcs/class/corlib/System/Array.cs      2007-05-23 10:40:09 UTC (rev 
77828)
@@ -43,6 +43,9 @@
 namespace System
 {
        [Serializable]
+#if NET_2_0
+       [ComVisible (true)]
+#endif
        // FIXME: We are doing way to many double/triple exception checks for 
the overloaded functions"
        // FIXME: Sort overloads parameter checks are VERY inconsistent"
        public abstract class Array : ICloneable, ICollection, IList, 
IEnumerable
@@ -53,32 +56,32 @@
                }
 
 #if NET_2_0
-               protected int InternalArray__ICollection_get_Count<T> ()
+               internal int InternalArray__ICollection_get_Count<T> ()
                {
                        return Length;
                }
 
-               protected IEnumerator<T> 
InternalArray__IEnumerable_GetEnumerator<T> ()
+               internal IEnumerator<T> 
InternalArray__IEnumerable_GetEnumerator<T> ()
                {
                        return new InternalEnumerator<T> (this);
                }
 
-               protected void InternalArray__ICollection_Clear<T> ()
+               internal void InternalArray__ICollection_Clear<T> ()
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
 
-               protected void InternalArray__ICollection_Add<T> (T item)
+               internal void InternalArray__ICollection_Add<T> (T item)
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
 
-               protected bool InternalArray__ICollection_Remove<T> (T item)
+               internal bool InternalArray__ICollection_Remove<T> (T item)
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
 
-               protected bool InternalArray__ICollection_Contains<T> (T item)
+               internal bool InternalArray__ICollection_Contains<T> (T item)
                {
                        if (this.Rank > 1)
                                throw new RankException (Locale.GetText ("Only 
single dimension arrays are supported."));
@@ -101,7 +104,7 @@
                        return false;
                }
 
-               protected void InternalArray__ICollection_CopyTo<T> (T[] array, 
int index)
+               internal void InternalArray__ICollection_CopyTo<T> (T[] array, 
int index)
                {
                        if (array == null)
                                throw new ArgumentNullException ("array");
@@ -121,17 +124,17 @@
                        Copy (this, this.GetLowerBound (0), array, index, 
this.GetLength (0));
                }
 
-               protected void InternalArray__Insert<T> (int index, T item)
+               internal void InternalArray__Insert<T> (int index, T item)
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
 
-               protected void InternalArray__RemoveAt<T> (int index)
+               internal void InternalArray__RemoveAt<T> (int index)
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
 
-               protected int InternalArray__IndexOf<T> (T item)
+               internal int InternalArray__IndexOf<T> (T item)
                {
                        if (this.Rank > 1)
                                throw new RankException (Locale.GetText ("Only 
single dimension arrays are supported."));
@@ -164,7 +167,7 @@
                        return retVal;
                }
 
-               protected T InternalArray__get_Item<T> (int index)
+               internal T InternalArray__get_Item<T> (int index)
                {
                        if (unchecked ((uint) index) >= unchecked ((uint) 
Length))
                                throw new ArgumentOutOfRangeException ("index");
@@ -174,7 +177,7 @@
                        return value;
                }
 
-               protected void InternalArray__set_Item<T> (int index, T item)
+               internal void InternalArray__set_Item<T> (int index, T item)
                {
                        throw new NotSupportedException ("Collection is 
read-only");
                }
@@ -1501,7 +1504,7 @@
                }
        
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<T> (T [] array)
                {
                        if (array == null)
@@ -1510,7 +1513,7 @@
                        Sort<T, T> (array, null, 0, array.Length, null);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<TKey, TValue> (TKey [] keys, TValue [] 
items)
                {
                        if (keys == null)
@@ -1519,7 +1522,7 @@
                        Sort<TKey, TValue> (keys, items, 0, keys.Length, null);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<T> (T [] array, IComparer<T> comparer)
                {
                        if (array == null)
@@ -1528,7 +1531,7 @@
                        Sort<T, T> (array, null, 0, array.Length, comparer);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<TKey, TValue> (TKey [] keys, TValue [] 
items, IComparer<TKey> comparer)
                {
                        if (keys == null)
@@ -1537,7 +1540,7 @@
                        Sort<TKey, TValue> (keys, items, 0, keys.Length, 
comparer);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<T> (T [] array, int index, int length)
                {
                        if (array == null)
@@ -1546,13 +1549,13 @@
                        Sort<T, T> (array, null, index, length, null);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<TKey, TValue> (TKey [] keys, TValue [] 
items, int index, int length)
                {
                        Sort<TKey, TValue> (keys, items, index, length, null);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<T> (T [] array, int index, int length, 
IComparer<T> comparer)
                {
                        if (array == null)
@@ -1561,7 +1564,7 @@
                        Sort<T, T> (array, null, index, length, comparer);
                }
 
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, 
Cer.MayFail)]
+               [ReliabilityContractAttribute (Consistency.MayCorruptInstance, 
Cer.MayFail)]
                public static void Sort<TKey, TValue> (TKey [] keys, TValue [] 
items, int index, int length, IComparer<TKey> comparer)
                {
                        if (keys == null)

Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2007-05-23 10:38:52 UTC (rev 
77827)
+++ trunk/mcs/class/corlib/System/ChangeLog     2007-05-23 10:40:09 UTC (rev 
77828)
@@ -1,3 +1,10 @@
+2007-05-22  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * Convert.cs : completed 2.0 (ToBase64CharArray).
+       * String.cs : removed MonoTODO.
+       * DataMisalignedException.cs : removed extra .ctor().
+       * Array.cs : internalize extra members. Fixed reliability contract.
+
 2007-05-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * DateTime.cs : added support for 'K'.

Modified: trunk/mcs/class/corlib/System/Convert.cs
===================================================================
--- trunk/mcs/class/corlib/System/Convert.cs    2007-05-23 10:38:52 UTC (rev 
77827)
+++ trunk/mcs/class/corlib/System/Convert.cs    2007-05-23 10:40:09 UTC (rev 
77828)
@@ -95,6 +95,7 @@
 using System.Security.Cryptography;
 using System.Text;
 using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 
 namespace System {
   
@@ -217,6 +218,7 @@
                }
 
 #if NET_2_0
+               [ComVisible (true)]
                public static string ToBase64String (byte[] inArray, 
Base64FormattingOptions options)
                {
                        if (inArray == null)
@@ -224,6 +226,7 @@
                        return ToBase64String (inArray, 0, inArray.Length, 
options);
                }
 
+               [ComVisible (true)]
                public static string ToBase64String (byte[] inArray, int 
offset, int length, Base64FormattingOptions options)
                {
                        if (inArray == null)
@@ -234,23 +237,58 @@
                        if (offset > inArray.Length - length)
                                throw new ArgumentOutOfRangeException ("offset 
+ length > array.Length");
 
-                       Encoding encoding = new ASCIIEncoding ();
-                       BinaryReader reader = new BinaryReader (new 
MemoryStream (inArray, offset, length));
-                       byte[] b = null;
+                       if (options == Base64FormattingOptions.InsertLineBreaks)
+                               return ToBase64StringBuilderWithLine (inArray, 
offset, length).ToString ();
+                       else
+                               return Encoding.ASCII.GetString 
(toBase64Transform.InternalTransformFinalBlock (inArray, offset, length));
+               }
 
+               public static int ToBase64CharArray (byte[] inArray, int 
offsetIn, int length, 
+                                                   char[] outArray, int 
offsetOut, Base64FormattingOptions options)
+               {
+                       if (inArray == null)
+                               throw new ArgumentNullException ("inArray");
+                       if (outArray == null)
+                               throw new ArgumentNullException ("outArray");
+                       if (offsetIn < 0 || length < 0 || offsetOut < 0)
+                               throw new ArgumentOutOfRangeException 
("offsetIn, length, offsetOut < 0");
+                       // avoid integer overflow
+                       if (offsetIn > inArray.Length - length)
+                               throw new ArgumentOutOfRangeException 
("offsetIn + length > array.Length");
+
+                       // note: normally ToBase64Transform doesn't support 
multiple block processing
                        if (options == 
Base64FormattingOptions.InsertLineBreaks) {
-                               StringBuilder sb = new StringBuilder ();
-                               do {
-                                       // 54 bytes of input makes for 72 bytes 
of output.
-                                       b = reader.ReadBytes (54);
-                                       if (b.Length > 0)
-                                               sb.AppendLine 
(encoding.GetString (toBase64Transform.InternalTransformFinalBlock (b, 0, 
b.Length)));
-                               } while (b.Length > 0);
-                               return sb.ToString ();
+                               StringBuilder sb = 
ToBase64StringBuilderWithLine (inArray, offsetIn, length);
+                               sb.CopyTo (0, outArray, offsetOut, sb.Length);
+                               return sb.Length;
                        } else {
-                               return encoding.GetString 
(toBase64Transform.InternalTransformFinalBlock (inArray, offset, length));
+                               byte[] outArr = 
toBase64Transform.InternalTransformFinalBlock (inArray, offsetIn, length);
+                       
+                               char[] cOutArr = Encoding.ASCII.GetChars 
(outArr);
+                       
+                               // avoid integer overflow
+                               if (offsetOut > outArray.Length - 
cOutArr.Length)
+                                       throw new ArgumentOutOfRangeException 
("offsetOut + cOutArr.Length > outArray.Length");
+                       
+                               Array.Copy (cOutArr, 0, outArray, offsetOut, 
cOutArr.Length);
+                               return cOutArr.Length;
                        }
                }
+
+               static StringBuilder ToBase64StringBuilderWithLine (byte [] 
inArray, int offset, int length)
+               {
+                       BinaryReader reader = new BinaryReader (new 
MemoryStream (inArray, offset, length));
+                       byte[] b = null;
+
+                       StringBuilder sb = new StringBuilder ();
+                       do {
+                               // 54 bytes of input makes for 72 bytes of 
output.
+                               b = reader.ReadBytes (54);
+                               if (b.Length > 0)
+                                       sb.AppendLine (Encoding.ASCII.GetString 
(toBase64Transform.InternalTransformFinalBlock (b, 0, b.Length)));
+                       } while (b.Length > 0);
+                       return sb;
+               }
 #endif
 
 

Modified: trunk/mcs/class/corlib/System/DataMisalignedException.cs
===================================================================
--- trunk/mcs/class/corlib/System/DataMisalignedException.cs    2007-05-23 
10:38:52 UTC (rev 77827)
+++ trunk/mcs/class/corlib/System/DataMisalignedException.cs    2007-05-23 
10:40:09 UTC (rev 77828)
@@ -55,10 +55,12 @@
                        HResult = Result;
                }
 
+               /*
                protected DataMisalignedException (SerializationInfo info, 
StreamingContext context)
                        : base (info, context)
                {
                }
+               */
        }
 }
 

Modified: trunk/mcs/class/corlib/System/String.cs
===================================================================
--- trunk/mcs/class/corlib/System/String.cs     2007-05-23 10:38:52 UTC (rev 
77827)
+++ trunk/mcs/class/corlib/System/String.cs     2007-05-23 10:40:09 UTC (rev 
77828)
@@ -221,7 +221,7 @@
 
 #if NET_2_0
                [ComVisible (false)]
-               [MonoTODO]
+               [MonoDocumentationNote ("optimization")]
                public String[] Split (char[] separator, int count, 
StringSplitOptions options)
                {
                        if (separator == null || separator.Length == 0)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to