API Proposal: Expose a base collection that prevents null items #5509
Labels
api-suggestion
(1) Early API idea and discussion, it is NOT ready for implementation
Milestone
We have a number of collections in WinForms that are currently untyped but also attempt to disallow nulls (either in the collections themselves or in the consumers).
We have an internal base collection we're using that we should consider making public and consider deriving from in our public collections.
Any place we just implement
IList
would move to this collection (presuming they don't like nulls), such as the following:We should consider moving class that derive from
CollectionBase
to this. It is a breaking change if you're casting directly to CollectionBase. It is also a breaking change if you derive from these. We could mitigate the derivation case by providing the same virtualsCollectionBase
has.We can also consider introducing an adapter
CollectionBase
that would still allow casting the collections againstCollectionBase
. If we did that we'd depreciate the cast operator out of the gate to discourage using it (as it would have to copy the collection into theArrayList
inCollectionBase
and sync the two). I'm not fond of this and think we should just take the breaking change.One other possibility is to extend this proposal to include modifications to
CollectionBase
to allow providing your own backing collection, but as the current one is exposed viaprotected ArrayList CollectionBase.InnerList { get; }
that probably won't fly.For example:
This is just a start on this to get initial thoughts down and start gathering feedback.
The text was updated successfully, but these errors were encountered: