Skip to content

Add RemoveAll extension for ICollection<T>#16

Merged
Tyrrrz merged 4 commits intoprimefrom
copilot/add-collection-extension
Apr 12, 2026
Merged

Add RemoveAll extension for ICollection<T>#16
Tyrrrz merged 4 commits intoprimefrom
copilot/add-collection-extension

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

ICollection<T> has no RemoveAll — only List<T> does. This adds the missing extension so any ICollection<T> implementation can remove elements by predicate.

Changes

  • CollectionExtensions.csRemoveAll(Func<T, bool> predicate) on ICollection<T>: snapshots via ToArray() then removes matched items
  • CollectionExtensionsTests.cs — basic coverage
ICollection<int> collection = new List<int> { 1, 2, 3, 4, 5 };
collection.RemoveAll(x => x % 2 == 0);
// collection == [1, 3, 5]

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 12, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 12, 2026 20:02
Copilot AI review requested due to automatic review settings April 12, 2026 20:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a missing RemoveAll convenience for ICollection<T> so callers aren’t forced to cast to List<T> (or re-implement the pattern) when removing items by predicate.

Changes:

  • Introduces ICollection<T>.RemoveAll(Func<T, bool>) extension that snapshots the collection and removes matching elements.
  • Adds an initial unit test covering basic predicate-based removal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
PowerKit/Extensions/CollectionExtensions.cs Adds the new RemoveAll extension for ICollection<T>.
PowerKit.Tests/CollectionExtensionsTests.cs Adds basic test coverage for the new extension.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/CollectionExtensions.cs Outdated
Comment thread PowerKit/Extensions/CollectionExtensions.cs
Comment thread PowerKit/Extensions/CollectionExtensions.cs
Comment thread PowerKit.Tests/CollectionExtensionsTests.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 12, 2026

@copilot add test assert for RemoveAll return value

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/2fd16fda-aa81-44f2-8c88-084a881dd7bc

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 12, 2026

@copilot add test assert for RemoveAll return value

Done in aac5c5d — the test now captures the return value and asserts it equals 2.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants