I've been doing a lot of migration work on a .NET v1.1 code base to .NET 2.0 recently. I just ran into a (gnarly) documented change in the implementation of ArrayList.Contains(object item) that was causing a unit test to fail....here's the relevant extract from the remarks section towards the end of the document [1] (http://msdn2.microsoft.com/en-us/library/system.collections.arraylist.contains.aspx)
In our case we were passing in items that had overidden Object.Equals. Since this method is now invoked by ArrayList.Contains() in .NET v2.0 but was not previously in .NET v1.1, our implementation of Object.Equals was incorrect for this scenario.
[1]
"Starting with the .NET Framework 2.0, this method uses the collection’s objects’ Equals and CompareTo methods on item to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the item parameter on the objects in the collection"
Wednesday, March 28, 2007
Subscribe to:
Posts (Atom)