[API Proposal]: ExceptBy taking another collection of the source type

Open
#116,005 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
api

Research direction

Start by reading the existing Enumerable.ExceptBy overloads and related issue #115797 to understand the proposed API pattern. Verify the proposal's signature and expected behavior for two IEnumerable inputs using the same keySelector; done means the overload is implemented and its behavior is covered by tests.

Written by the indexing model from the issue text.

Description

api-suggestion area-System.Linq
Background and motivation

Please add an overload of ExceptBy that takes another collection of the source type (instead of TKey type). The same keySelector will then be used to obtain the keys from both collections.

Related #115797

API Proposal
namespace System.Collections.Generic;

public static class Enumerable
{
+    public static IEnumerable<TSource> ExceptBy<TSource, TKey>(
         this IEnumerable<TSource> first,
         IEnumerable<TSource> second,
         Func<TSource, TKey> keySelector);
}
API Usage
IEnumerable<Source> x = ...;
IEnumerable<Source> y = ...;

var excepted = x.ExceptBy(y, source => source.Key);
Alternative Designs

No response

Risks

No response

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.