Skip to content

Proposal: Implement resolution of IReadOnlyCollection[T] and IReadOnlyList[T]  #282

@BryantL

Description

@BryantL

With the change in resolution behaviour of IEnumerable[T] (switching to deferred resolution of items) the only "built-in" "up front" resolution of collections is via an Array (strictly speaking knowing that IEnumerable is deferred or not is an implementation detail, however it is a detail that some come to rely upon, especially if there is a desire to avoid concrete types... see below).

Using an array is effective however in many scenarios its preferable to use an interface rather than a concrete type.

IReadOnlyCollection[T] and IReadOnlyList[T] were introduced in .Net 4.5.

The proposal is to implement resolution of these interfaces as an alternative to resolving an array.
As an implementation detail, the logic for resolving an array would be used and then "cast" to the interface.
This ability would not be available on .net 4.0 due to the interfaces not being present. This would not impact these users as the interface is unavailable to them regardless.

As with the array, any existing registrations of the interface would override this "default" resolution mechanism.

Assuming agreement I'm happy to provide a PR for this.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions