In System.Collections:
authorRobert Jordan <robertj@gmx.net>
Thu, 8 May 2008 20:57:15 +0000 (20:57 -0000)
committerRobert Jordan <robertj@gmx.net>
Thu, 8 May 2008 20:57:15 +0000 (20:57 -0000)
2008-05-08  Robert Jordan  <robertj@gmx.net>

* DictionaryEntry.cs: Rename fields for serialization
compatibility with MS. Accept null keys on 2.0 profile.
Fixes #381922.

In Test/System.Collections:
2008-05-08  Robert Jordan  <robertj@gmx.net>

* DictionaryEntryTest.cs: Add tests for key's argument validation.

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

mcs/class/corlib/System.Collections/ChangeLog
mcs/class/corlib/System.Collections/DictionaryEntry.cs
mcs/class/corlib/Test/System.Collections/ChangeLog
mcs/class/corlib/Test/System.Collections/DictionaryEntryTest.cs

index 5c75eb49f2826ffbbb375bd1f79e7fd4553ef9d2..45deb94bdb4a24ca685ba79c3cc42fb0a5df5b6c 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-08  Robert Jordan  <robertj@gmx.net>
+
+       * DictionaryEntry.cs: Rename fields for serialization
+       compatibility with MS. Accept null keys on 2.0 profile.
+       Fixes #381922.
+
 2008-04-13  Jb Evain  <jbevain@novell.com>
 
        * ArrayList.cs, BitArray.cs, CaseInsensitiveComparer.cs
index 86c8a29d47fbf7abeaea21bac0643886338613fe..1363a0eb06fa6fa9e48662bdd31e9dd3f741cb89 100644 (file)
@@ -41,29 +41,33 @@ namespace System.Collections {
 #endif
        [Serializable]
        public struct DictionaryEntry {
-               private object key;
-               private object val;
+               private object _key;
+               private object _value;
 
                public DictionaryEntry (object key, object value)
                {
+#if ONLY_1_1
                        if (key == null)
                                throw new ArgumentNullException ("key");
-                       
-                       this.key = key;
-                       val = value;
+#endif                 
+                       _key = key;
+                       _value = value;
                }
                
                public object Key {
-                       get {return key;}
+                       get {return _key;}
                        set {
+#if ONLY_1_1
                                if (value == null)
                                        throw new ArgumentNullException ("value");
-                               key = value;
+#endif                         
+                               _key = value;
                        }
                }
+
                public object Value {
-                       get {return val;}
-                       set {val = value;}
+                       get {return _value;}
+                       set {_value = value;}
                }
        }
 }
index 30f2a946d2f300427134593674830e89aa2a3e67..2b4b8f6c8e70b115134f38a47002651df19a7d7d 100644 (file)
@@ -1,3 +1,7 @@
+2008-05-08  Robert Jordan  <robertj@gmx.net>
+
+       * DictionaryEntryTest.cs: Add tests for key's argument validation.
+
 2008-03-24  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * DictionaryBaseTest.cs: Improved existing tests, and use Assert class
index fb36a06b5ded54607bfbc1171bd97fd93cb79bba..c90ff5de8dfdfc2c92b42f3d0db095b6d447cf7f 100644 (file)
@@ -30,5 +30,24 @@ namespace MonoTests.System.Collections {
                        d.Value = 'p';
                        AssertEquals ("#04", d.Value, 'p');
                }
+
+               [Test]
+#if ONLY_1_1
+               [ExpectedException (typeof (ArgumentNullException))]
+#endif                 
+               public void NullKeyCtor ()
+               {
+                       DictionaryEntry d = new DictionaryEntry (null, "bar");
+               }
+
+               [Test]
+#if ONLY_1_1
+               [ExpectedException (typeof (ArgumentNullException))]
+#endif                 
+               public void NullKeySetter ()
+               {
+                       DictionaryEntry d = new DictionaryEntry ("foo", "bar");
+                       d.Key = null;
+               }
        }
 }