2010-01-24 Robert Jordan <[email protected]>
* Dictionary.cs: Fix deserialization compatibility with MS.NET.
Fixes bug #474009.
In Test/System.Collections.Generic:
2010-01-24 Robert Jordan <[email protected]>
* DictionaryTest.cs: Add test case for bug #474009.
svn path=/trunk/mcs/; revision=150089
* System.Collections.Generic/Dictionary.cs (CopyToCheck, Do_CopyTo):
Carve out of ...
(CopyTo): ... this.
(Do_ICollectionCopyTo): Carve out of ICollection.CopyTo. Convert
type-cast exceptions to ArgumentExceptions.
(KeyCollection.CopyTo): Use them.
(ValueCollection.CopyTo): Use them.
* Test/System.Collections.Generic/DictionaryTest.cs (ICollectionCopyTo):
Test various odd scenarios where .NET CopyTo does _not_ throw an exception.
(ICollectionCopyTo_ex1..4): Ensure that ArgumentExceptions are
thrown in appropriate cases.
svn path=/trunk/mcs/; revision=142427
* List.cs (IList.this.set): Convert NullReference and InvalidCast
exceptions into ArgumentExceptions.
(IList.Add, IList.Contains, IList.IndexOf, IList.Insert, IList.Remove):
Convert NullReferenceException to ArgumentException.
* ListTest.cs: Add a few testcases for IList interface, using null
values with a List<int>.
svn path=/trunk/mcs/; revision=139159
* DictionaryTest.cs (KeyEnumerator_Current): New test. Test the
Keys slice enumerator.
(ValueEnumerator_Current): Likewise, for the Values slice.
svn path=/trunk/mcs/; revision=139117
* System.Collections.Generic/List.cs (Enumerator.current): New.
(Enumerator.MoveNext): Update it.
(Enumerator.Current): Don't verify any invariants.
(Enumerator.Dispose): Set 'l' to null.
* Test/System.Collections.Generic/ListTest.cs (Enumerator_Current):
New test, includes relevant parts of #491858 and #517415.
svn path=/trunk/mcs/; revision=139087
* System.Collections.Generic/Dictionary.cs (Enumerator.current): New.
(Enumerator.MoveNext): Update it.
(Enumerator.Current): Don't verify any invariants.
* Test/System.Collections.Generic/DictionaryTest.cs (Enumerator_Current):
New test, includes relevant parts of #491858 and #517415.
svn path=/trunk/mcs/; revision=139082
Increment version whenever _items is modified; this fixes version
checks in Enumerator.
* ListTest.cs: Added tests for binary serialization, and Enumerator
version checks.
svn path=/trunk/mcs/; revision=66698
* ArrayTest.cs : use proper comparer in IndexOf() and LastIndexOf().
Patch by Kazuki Oikawa. Fixed bug #77277.
* List.cs : use proper comparer in Contains(), IndexOf() and
LastIndexOf(). Patch by Kazuki Oikawa. Fixed bug #77277.
* ArrayTest.cs : test for bug #77277 by Kazuki Oikawa.
* ListTest.cs : test for bug #77277 by Kazuki Oikawa.
svn path=/trunk/mcs/; revision=60396
* List.cs (CheckIndex): Check for -ve indices and allow index == size.
(Insert): Use CheckIndex.
In class/corlib/Test/System.Collections.Generic:
* ListTest.cs: Add some tests for InsertRange.
svn path=/trunk/mcs/; revision=58069
Speed up remove. Use 'dict[k]=v' as a self-tuning hint.
* Dictionary.cs (GetSlot): Move data-structure traversal to ...
(GetPrev): ... this. Returns the slot prior to the place we're
looking for, or null if that place is the head of the chain.
(Remove): Use it.
(this.set): Use it. Implement move-to-front on set.
* Dictionary.cs (ToTKey, ToTValue): New helpers to convert from
type 'object'.
(IDictionary.this, IDictionary.Add): Use them.
(IDictionary.Contains, IDictionary.Remove): If the types don't
match, do nothing.
In Test/System.Collections.Generic:
* DictionaryTest.cs (IDictionary_*): Add a few tests for the
IDictionary explicit implementation.
svn path=/trunk/mcs/; revision=55946
Fix to pass new nunit tests.
* Dictionary.cs (ShimEnumerator): New class. Implement the
requirement that ((IDictionary) foo).GetEnumerator ().Current has
type DictionaryEntry.
(IDictionary.GetEnumerator): Use ShimEnumerator.
(Enumerator.Current): Now has type KeyValuePair<TKey, TValue>.
(Enumerator.MoveNext): Use VerifyState.
(Enumerator.VerifyState): Move validation of 'current' field to ...
(Enumerator.CurrentSlot): ... this.
(Enumerator.Current, Enumerator.IDictionaryEnumerator.Entry):
Use CurrentSlot.
(CopyTo, ICollection.CopyTo): Use subtle reasoning to replace a
'>=' with a '>'. Don't throw an ArgumentException when
index==array.Length && Count==0.
(KeyCollection.CopyTo, ValueCollection.CopyTo): Likewise, and thus
obviate the need to check (dictionary.Count == 0).
In Test/System.Collections.Generic:
* DictionaryTest.cs: Remove NotWorking annotations.
(Empty_CopyTo, Empty_Values_CopyTo): Fix tests to check that
CopyTo from an empty dictionary does not throw an exception when
'index==array.Length'.
(PlainEnumeratorReturnTest): Check the type of 'Entry' property too.
svn path=/trunk/mcs/; revision=55781
* DictionaryTest.cs : fixed several tests to not fail under .NET 2.0
and thus marked some as NotWorking. Numbered some assertions.
svn path=/trunk/mcs/; revision=55774
* ListTest.cs: Added test cases for #77039 for sorting a list with
IComparable (generic or not) and without IComparable (exception).
svn path=/trunk/mcs/; revision=54697
DictionaryEntry.
* ListTest.cs: Added test case for #77019 when copying from an empty
dictionary.
2005-12-19 Sebastien Pouliot <[email protected]>
svn path=/trunk/mcs/; revision=54615
* ListTest.cs: Added test case for a binary search with an empty list
(bug #77030). Removed IsReadOnly test case as this isn't part of the
public API anymore.
svn path=/trunk/mcs/; revision=54609
Introduce some thread-safety by removing the modify-on-read
move-to-front heuristic.
* Dictionary.cs (_enumeratorGeneration, _enumerators): Remove.
(Count): Add internal property set. Invalidate enumerators when
Count is changed. Change all references of _usedSlots to Count.
(this): Invalidate enumerators when the value of some slot is
changed, even if the layout of the data-structure isn't modified.
(DoHash): Remove null-key check. All codepaths leading to this
function already have the check.
(GetSlot): Remove move-to-front heuristic.
(Remove): Update.
In Test/System.Collections.Generic:
* DictionaryTest.cs (FailFastTest1, FailFastTest2, FailFastTest3):
New tests to ensure that enumerators are invalidated on
modifications to the dictionary.
svn path=/trunk/mcs/; revision=46538
* Dictionary.cs (_generation, _enumeratorGeneration, _enumerators):
New fields to implement fail-fast semantics. All code that
modifies the table increment _generation.
(GetSlot): Use _hcp to compare keys. Return the slot containing
the key, rather than the index. Avoid move-to-front heuristic
when there's an enumerator coursing through the table.
(this, Add, TryGetValue, ContainsKey, Remove): Update to change.
(Enumerator.Enumerator): Save the generation of the dictionary.
(Enumerator.Dispose): Inform dictionary that the enumerator is no more.
(Enumerator.MoveNext, Enumerator.VerifyState): Fail if the
dictionary has been modified.
In Test/System.Collections.Generic:
* DictionaryTest.cs (KeyValueEnumeratorTest): Add test for infloop
if dictionary is read while it's being enumerated.
svn path=/trunk/mcs/; revision=46370
* List.cs : substantial changes and optimizations
(AddCollection, AddEnumerable): new internal specializations of AddRange
(AsReadOnly): returns specific IList<T> to match ms.net 2.0b2 api.
(Clear): reset size to zero on clear
(ConvertAll): catch null converter, use Add to prevent OutOfBounds
exception
(FindAll, FindIndex, FindLast, FindLastIndex, RemoveAll, TrueForAll):
check for null match
(FindLastIndex): correct index parameters based on ms.net 2005b2 behavior
(ForEach): catch null action
(CheckIndex): new internal function similar to CheckRange for functions
which only provide a starting index
(InsertCollection, InsertEnumerable): new internal specializations of
InsertRange
(ReadOnlyList): removed, ReadOnlyCollection in
System.Collections.ObjectModel is used instead now
* ListTest.cs: Substantial new tests
svn path=/trunk/mcs/; revision=46283
* Dictionary.cs (EnumerationMode): Remove.
(Enumerator): Remove return type flag - legacy return is expected to
always return a DictionaryEntry
(Enumerator): Make constructor internal, it is not public on ms.net
beta 2
(Enumerator.MoveNext): Fix endless loop on enumerator use
(VerifyState): Added method to check state preconditions and throw
appropriate exceptions.
(KeyCollection,ValueCollection): Mark sealed to match ms.net beta 2
(KeyCollection.Enumerator._hostEnumerator): make exact struct type,
rather than boxing and using by interface
(KeyCollection.Enumerator.Dispose): use default to clear Enumerator
(ValueCollection.Enumerator._hostEnumerator): make exact struct type,
rather than boxing and using by interface
(ValueCollection.Enumerator.Dispose): use default to clear Enumerator
* EqualityComparer.cs (DefaultComparer, IEquatableOfTEqualityComparer):
Mark as serializable.
* DictionaryTest.cs (AddTest3): Added test of simple interaction with
struct dictionary
(AddDuplicateTest,IndexerGetNullTest,IndexerSetNullTest): Added tests
for exceptional cases to verify correct exceptions
(TryGetValueTest): check return value from TryGetValue
(KeyValueEnumeratorTest): Added test from verification of ms.net beta2
behavior for non-generic IEnumerator/IDictionaryEnumerator behavior
against Dictionary<>
(SerializationTest): Added test to utilize serialization routines.
svn path=/trunk/mcs/; revision=46200
* Dictionary.cs (GetKeys, GetValues): Remove.
(SetThreshold): New function to calculate the resize threshold.
(CopyTo): Don't use foreach syntax.
(ContainsValue): Likewise. Use default equality comparer of the
value type.
(GetObjectData): Use CopyTo to copy into temporary array. Don't
save redundant _usedSlots and _threshold.
(OnDeserialization): Rewrite.
(ICollection<>.CopyTo): Forward to CopyTo.
(Enumerator._nextIndex): Rename to from _index.
(Enumerator._next, Enumerator.FixNext): Remove.
(Enumerator.Current): Rewrite to avoid need for _next.
(Enumerator.IEnumerator.Reset): Update.
(KeyCollection): Is also IEnumerable<TKey> and IEnumerable.
Update methods to conform to standard.
(KeyCollection.GetEnumerator): Restore. Return the correct type.
(KeyCollection.Enumerator): Rename from KeyEnumerator. Simple
wrapper that forwards to Dictionary<,>.Enumerator.
(ValueCollection): Likewise.
In Test/System.Collections.Generic:
* DictionaryTest.cs (SliceCollectionsEnumeratorTest): New test
based on #75053.
svn path=/trunk/mcs/; revision=46087
* corlib_test.dll.sources,
corlib.dll.sources: generic Queue.cs and Stack.cs are now in System.
* System_test.dll.sources,
System.dll.sources: generic Queue.cs and Stack.cs are now in System.
* Queue.cs, Stack.cs: moved to System.dll
* QueueTest.cs, StackTest.cs: They are now in System.dll
svn path=/trunk/mcs/; revision=44484
* Dictionary.cs: Update to draft of Feb 27. Add some argument checks.
(GetSlot): Don't throw KeyNotFoundException. Unify all list
traversals in here. Move found key to head of chain, and return
the index of the chain suitable for/containing the key.
(Item, Add, Remove): Simplify, and remove FIXMEs.
(Resize): Reuse linked list nodes from old table.
In Test/System.Collections.Generic:
* DictionaryTest.cs: Update.
svn path=/trunk/mcs/; revision=42508
2005-04-02 Ben Maurer <[email protected]>
* corlib_test.dll.sources: Add new test.
In Test/System.Collections.Generic:
2005-04-02 Ben Maurer <[email protected]>
* DictionaryTest.cs: new test.
svn path=/trunk/mcs/; revision=42491
2004-12-27 Ben Maurer <[email protected]>
* corlib_test.dll.sources: Add s.col.gen.stack test
In Test/System.Collections.Generic:
2004-12-27 Ben Maurer <[email protected]>
* StackTest.cs: new Test.
svn path=/trunk/mcs/; revision=38124