Non-Generic Collections to be Removed from Silverlight [Inbar Gazit]
Those of you who are already using Silverlight 1.1 Alpha may
have seen that the familiar non-generic collections were all marked as
obsolete. This includes almost everything under the System.Collections
namespace. You shouldn’t be too surprised. We’ve been telling you for a while
that you should not be using these anymore and to instead use the generic
collections in the System.Collections.Generic namespace. See the following blog
post for more
details on how and why to convert your non-generic collections.
While you can technically use obsolete types and only get
warnings, we’re completely removing these types from Silverlight so we
seriously advise you against using them.
The following types will be completely removed:
- ArrayList
- BitArray
- CaseInsensitiveComparer
- CaseInsensitiveHashCodeProvider
- CollectionBase
- Comparer
- CompatibleComparer
- DictionaryBase
- EmptyReadOnlyDictionaryInternal
- Hashtable
- IHashCodeProvider
- KeyValuePairs
- ListDictionaryInternal
- Queue
- ReadOnlyCollectionBase
- SortedList
- Stack
On the other hand we decided to keep most of
the non-generic interfaces (including those who were previously marked as
obsolete):
- IEnumerator
- IEnumerable
- ICollection
- IComparer
- IDictionary
- IDictionaryEnumerator
- DictionaryEntry
- IEqualityComparer
- IList
The non-generic collection interfaces are required for
scenarios where you don’t know the type of T. Consider databinding as an
example. Databinding works using non-generic methods today, and can deal with
List<T> only because it implements the non-generic IList. There’s no
easy way to get an arbitrary T in a non-generic method & manipulate it
efficiently. While it may be possible to use Reflection to extract the T and
use the type in a very late-bound fashion, this approach incurs a significant
performance hit. We must continue to ship our non-generic collection interfaces.
Three other generic types were also removed. Queue<T>,
Stack<T> and LinkedList<T> were removed from Silverlight. In this
case it wasn’t because they were non-generic but because they are not
considered to be part of the core set of types that we deemed essential to be
provided with Silverlight. Remember that Silverlight is a very small download
and should only include the smallest set of APIs that will allow for useful
development. It’s very simple to implement Queue<T> and Stack<T> using
List<T> and LinkedList<T> is just a different implementation of
List<T> with different performance characteristics and so it’s not an
essential part of our core collections group.
Expect to see these changes in a future preview release of
Silverlight 1.1. Keep checking out our blog for the announcement about when and
where...