* Comparer.cs: Renamed IComparableOfTComparer<T> to GenericComparer<T>
authorGert Driesen <drieseng@users.sourceforge.net>
Thu, 8 Mar 2007 20:22:06 +0000 (20:22 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Thu, 8 Mar 2007 20:22:06 +0000 (20:22 -0000)
to fix binary serialization compatibility with MS.
* ComparerTest.cs: Added test for bug #80929. Added tests to verify
binary serialization compatibility.
* IListTest.cs: Fixed header.
* corlib_test.dll.sources: Added ComparerTest.cs.

svn path=/trunk/mcs/; revision=73964

mcs/class/corlib/ChangeLog
mcs/class/corlib/System.Collections.Generic/ChangeLog
mcs/class/corlib/System.Collections.Generic/Comparer.cs
mcs/class/corlib/Test/System.Collections.Generic/ChangeLog
mcs/class/corlib/Test/System.Collections.Generic/ComparerTest.cs [new file with mode: 0644]
mcs/class/corlib/Test/System.Collections.Generic/IListTest.cs
mcs/class/corlib/corlib_test.dll.sources

index 9afc98b633235ec54434b3fc6ce6f15cb70f3048..dc4132c959f5cd478350cce5923f3138b00dfc81 100644 (file)
@@ -1,3 +1,7 @@
+2007-03-08  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * corlib_test.dll.sources: Added ComparerTest.cs.
+
 2007-03-07  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * corlib_test.dll.sources: Added IListTest.cs.
index 3b5d5d7f05888d47b5a49d74a7b57780c5e84777..7d9f70dce307f2bdbdc46dfc2d7c6d884d81f4ab 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-08  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * Comparer.cs: Renamed IComparableOfTComparer<T> to GenericComparer<T>
+       to fix binary serialization compatibility with MS.
+
 2007-03-05  David Mitchell <dmitchell@logos.com>
 
        * Dictionary.cs: An instance of Dictionary<TKey,TValue> is
index bd490b3d59d7f97efd0b688d76148300ee460231..75da08f54ecbb294d2794ee9b522b36906d62e23 100644 (file)
@@ -37,12 +37,11 @@ namespace System.Collections.Generic {
                static Comparer ()
                {
                        if (typeof (IComparable<T>).IsAssignableFrom (typeof (T)))
-                               _default = (Comparer<T>) Activator.CreateInstance (typeof (IComparableOfTComparer <>).MakeGenericType (typeof (T)));
+                               _default = (Comparer<T>) Activator.CreateInstance (typeof (GenericComparer <>).MakeGenericType (typeof (T)));
                        else
                                _default = new DefaultComparer ();
                }
                
-               
                public abstract int Compare (T x, T y);
        
                static readonly Comparer <T> _default;
@@ -88,7 +87,7 @@ namespace System.Collections.Generic {
        }
        
        [Serializable]
-       class IComparableOfTComparer <T> : Comparer <T> where T : IComparable<T> {
+       class GenericComparer <T> : Comparer <T> where T : IComparable<T> {
                public override int Compare (T x, T y)
                {
                        // `null' is less than any other ref type
index 56d345d3e586a4f94db55a75c683014c9f0cbee2..b82b4ebf360b83f20d245226d9cc712195a6258c 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-08  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * ComparerTest.cs: Added test for bug #80929. Added tests to verify
+       binary serialization compatibility.
+       * IListTest.cs: Fixed header.
+
 2007-03-07  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * IListTest.cs: Added test for bug #80260.
diff --git a/mcs/class/corlib/Test/System.Collections.Generic/ComparerTest.cs b/mcs/class/corlib/Test/System.Collections.Generic/ComparerTest.cs
new file mode 100644 (file)
index 0000000..2491120
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// MonoTests.System.Collections.Generic.Test.ComparerTest
+//
+// Authors:
+//      Gert Driesen (drieseng@users.sourceforge.net)
+//
+// Copyright (C) 2007 Gert Driesen
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Collections.Generic
+{
+       [TestFixture]
+       public class ComparerTest
+       {
+               [Test] // bug #80929
+               public void SerializeDefault ()
+               {
+                       Comparer<int> c = Comparer<int>.Default;
+
+                       BinaryFormatter bf = new BinaryFormatter ();
+                       MemoryStream ms = new MemoryStream ();
+                       bf.Serialize (ms, c);
+
+                       byte [] buffer = new byte [ms.Length];
+                       ms.Position = 0;
+                       ms.Read (buffer, 0, buffer.Length);
+
+                       Assert.AreEqual (_serializedDefault, buffer);
+               }
+
+               [Test]
+               public void DeserializeDefault ()
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       ms.Write (_serializedDefault, 0, _serializedDefault.Length);
+                       ms.Position = 0;
+
+                       BinaryFormatter bf = new BinaryFormatter ();
+                       Comparer<int> c = (Comparer<int>) bf.Deserialize (ms);
+                       Assert.IsNotNull (c);
+               }
+
+               private static readonly byte [] _serializedDefault = new byte [] {
+                       0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
+                       0x89, 0x01, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x6f,
+                       0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x47,
+                       0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x2e, 0x47, 0x65, 0x6e, 0x65,
+                       0x72, 0x69, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x72,
+                       0x60, 0x31, 0x5b, 0x5b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e,
+                       0x49, 0x6e, 0x74, 0x33, 0x32, 0x2c, 0x20, 0x6d, 0x73, 0x63, 0x6f,
+                       0x72, 0x6c, 0x69, 0x62, 0x2c, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69,
+                       0x6f, 0x6e, 0x3d, 0x32, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2c,
+                       0x20, 0x43, 0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x6e, 0x65,
+                       0x75, 0x74, 0x72, 0x61, 0x6c, 0x2c, 0x20, 0x50, 0x75, 0x62, 0x6c,
+                       0x69, 0x63, 0x4b, 0x65, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3d,
+                       0x62, 0x37, 0x37, 0x61, 0x35, 0x63, 0x35, 0x36, 0x31, 0x39, 0x33,
+                       0x34, 0x65, 0x30, 0x38, 0x39, 0x5d, 0x5d, 0x00, 0x00, 0x00, 0x00,
+                       0x0b };
+       }
+}
+
+#endif
+
index 38340a365a270091579f600ec690ab0eda3a5977..695e16b57fd3433ccd71128ea5c99e84f9ea0f3d 100644 (file)
@@ -1,5 +1,5 @@
 //
-// MonoTests.System.Collections.Generic.Test.DictionaryTest
+// MonoTests.System.Collections.Generic.Test.IListTest
 //
 // Authors:
 //      Gert Driesen (drieseng@users.sourceforge.net)
index 773daca050dad622a9c194ecd5fa2f42a1203d2e..f101be14c07ed196e2b1b883be1083e4bd53bde4 100644 (file)
@@ -31,6 +31,7 @@ System.Collections/QueueTest.cs
 System.Collections/ReadOnlyCollectionBaseTest.cs
 System.Collections/SortedListTest.cs
 System.Collections/StackTest.cs
+System.Collections.Generic/ComparerTest.cs
 System.Collections.Generic/DictionaryTest.cs
 System.Collections.Generic/IListTest.cs
 System.Collections.Generic/ListTest.cs