Skip to content
This repository has been archived by the owner. It is now read-only.
Switch branches/tags
Go to file
The idea here is to prevent false positives like issue #86.

A helper tool is being added to allow to quickly gather the methods that
should be targeted: constructors and static methods of the deprecated
type returning the type. This should be enough to raise warnings for
code creating new instances of the type while allowing usage of APIs
old APIs still returning the types.

Fixes #86
2 contributors

Users who have contributed to this file

@terrajobst @mairaw

DE0006: Non-generic collections shouldn't be used


When .NET was created, generic data types didn't exist, which is why the collection types in the System.Collections namespace are untyped. However, since then, generic data types were introduced and thus a new set of collections were made available in the System.Collections.Generic and System.Collections.ObjectModel namespaces.


For new code, you shouldn't use non-generic collections:

  • Error prone: since non-generic collections are untyped, it requires frequent casting between object and the actual type you're expecting. Since the compiler can't check that your types are consistent, it's easier to put the wrong type in the wrong collection.

  • Less performant: generic collections have the advantage that value types don't have to be boxed as object. For instance, a List<int> stores its data in an int[]. That's far better than storing the data in object[] as that requires boxing.

The following table shows how the non-generic collection types can be replaced by their generic counterparts from the System.Collections.Generic or System.Collections.ObjectModel namespaces:

Type Replacement
ArrayList List<T>
CaseInsensitiveComparer StringComparer.OrdinalIgnoreCase
CaseInsensitiveHashCodeProvider StringComparer.OrdinalIgnoreCase
CollectionBase Collection<T>
Comparer Comparer<T>
DictionaryBase Dictionary<TKey, TValue> or KeyedCollection<TKey, TItem>
DictionaryEntry KeyValuePair<TKey, TValue>
Hashtable Dictionary<TKey, TValue>
Queue Queue<T>
ReadOnlyCollectionBase ReadOnlyCollection<T>
SortedList SortedList<TKey, TValue>
Stack Stack<T>