Skip to content

Add Linq method for getting value and index. - #95947

Merged
eiriktsarpalis merged 5 commits into
dotnet:mainfrom
RaymondHuy:issue-95563
Dec 13, 2023
Merged

eiriktsarpalis merged 5 commits into
dotnet:mainfrom
RaymondHuy:issue-95563

Conversation

@RaymondHuy

Copy link
Copy Markdown
Contributor

Resolve #95563

@ghost

ghost commented Dec 13, 2023

Copy link
Copy Markdown

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 13, 2023
@ghost

ghost commented Dec 13, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-linq
See info in area-owners.md if you want to be subscribed.

Issue Details

Resolve #95563

Author: RaymondHuy
Assignees: -
Labels:

area-System.Linq, new-api-needs-documentation

Milestone: -

@eiriktsarpalis eiriktsarpalis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There seem to be test failures in CI related to this change.

@RaymondHuy

Copy link
Copy Markdown
Contributor Author

@eiriktsarpalis Thanks, I have updated my PR.

@eiriktsarpalis eiriktsarpalis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

{
public static partial class Enumerable
{
/// <summary>Return index and the associated item.</summary>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't an ideal description of what the method does: the method doesn't return an index and an associated item.

/// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
/// <param name="source">An <see cref="IEnumerable{T}" /> to return an element from.</param>
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
public static IEnumerable<(int Index, TSource Item)> Index<TSource>(this IEnumerable<TSource> source)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@eiriktsarpalis / @terrajobst, I see ~40 uses in source.dot.net of the Enumerable.Select overload that incorporates an index, 0 of which could switch to use this new method. Why do we believe it's valuable enough to ship?

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Linq community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Linq method for getting value and index

3 participants