IPagedList<T> should implement IReadOnlyList<T>
Closed this issue · 0 comments
Is your feature request related to a problem? Please describe.
I, as (I believe) many other developers, am used to returning IReadOnlyList<T>
as a standard collection type produced by my methods (especially those contained in public API), as it's good at clearly and explicitly stating the developer's intent that a returned collection (1) can be enumerated, (2) is (probably) already stored in the memory and (3) should not be modified. IReadOnlyList<T>
is better than IEnumerable<T>
in this regard - IEnumerable<T>
states only (1) explicitly, and (3) only implicitly, while IReadOnlyCollection<T>
states all three explicitly, thus making the code easier to reason about. For more detailed explanation, check this post (I am in no way affiliated with the author, BTW).
Describe the solution you'd like
IPagedList<T>
already implements IEnumerable<T>
and provides Count
property and int
indexer, which is exactly what IReadOnlyList<T>
does. BasePagedList<T>
, which is used by the library as a default IPagedList<T>
implementation, also internally uses List<T>
, which itself implements IReadOnlyList<T>
. The only change required would be to add IReadOnlyList<T>
to IPagedList<T>
's implemented interfaces, with no change to the IPagedList<T>
interface or its implementing classes themselves.
Describe alternatives you've considered
There's no alternative solution I can think of other than hacking into IPagedList<T>
binary :)