Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IReadOnlyCollection<T> does not implement ICollection<T> #33245

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libraries/System.Linq/src/System/Linq/AnyAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static bool Any<TSource>(this IEnumerable<TSource> source)
{
return collectionoft.Count != 0;
}

if (source is IReadOnlyCollection<TSource> readOnlyCollection)
return readOnlyCollection.Count != 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use curly braces


else if (source is IIListProvider<TSource> listProv)
{
// Note that this check differs from the corresponding check in
Expand All @@ -38,6 +42,7 @@ public static bool Any<TSource>(this IEnumerable<TSource> source)
{
return collection.Count != 0;
}


using (IEnumerator<TSource> e = source.GetEnumerator())
{
Expand Down