CA1002: Do not expose generic lists







Breaking Change



A type contains an externally visible member that is a System.Collections.GenericListT type, returns a System.Collections.GenericListT type, or whose signature includes a System.Collections.GenericListT parameter.

Rule Description

System.Collections.GenericListT is a generic collection that is designed for performance and not inheritance. System.Collections.GenericListT does not contain virtual members that make it easier to change the behavior of an inherited class. The following generic collections are designed for inheritance and should be exposed instead of System.Collections.GenericListT.

How to Fix Violations

To fix a violation of this rule, change the System.Collections.GenericListT type to one of the generic collections that is designed for inheritance.

When to Suppress Warnings

Do not suppress a warning from this rule unless the assembly that raises this warning is not meant to be a reusable library. For example, it would be safe to suppress this warning in a performance tuned application where a performance benefit was gained from the use of generic lists.