Skip to content

Collections in the framework are defined in such a way that when enumerating their items, we end up with ... objects. #134282

Description

@iphonec32144-cmyk

Collections in the framework are defined in such a way that when enumerating their items, we end up with ... objects.
An example of that is the PropertyDescriptorCollection which (I am pretty sure of) will never contain anything else than a PropertyDescriptor but yet we are forced to cast or define the type explicitly.
Either those collections should be removed from the framework as they do not bring anything more than troubles, and return IEnumerable<T> would be more constructive; or they should implement the proper interfaces.
PropertyDescriptorCollection is defined as ICollection, IList, IDictionary, this does not make any sense, PropertyDescriptor does not appear anywhere.
Many collections in the framework are like that. I don't know whether this is a required pattern, but if it is, it is wrong.
PropertyDescriptorCollection should be ICollection<PropertyDescriptor> and when you enumerate it, you get PropertyDescriptor and not an object.

Originally posted by @Scal-Human in dotnet/sdk#55773

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.ComponentModeluntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions