Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Jun 11, 2025

Closes #97689

Copilot

This comment was marked as outdated.

@stephentoub stephentoub changed the title Add {Async}Enumerable.InfiniteSequence Add {Async}Enumerable.{Infinite}Sequence Jun 11, 2025
Copy link
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

This PR introduces new overloads for Enumerable.Sequence and Enumerable.InfiniteSequence, along with their asynchronous counterparts in AsyncEnumerable, to generate sequences based on a start, end (or infinite), and step value.

  • Implements new APIs in both System.Linq and System.Linq.AsyncEnumerable.
  • Adds comprehensive tests for various numeric types and edge cases.
  • Updates project files and ref files to include the new sequence functionality.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Linq/tests/SequenceTests.cs Adds tests validating correct behavior of Sequence for various numeric types.
src/libraries/System.Linq/tests/InfiniteSequenceTests.cs Introduces tests to verify infinite sequence generation and uniqueness of enumerators.
src/libraries/System.Linq/src/System/Linq/Sequence.cs Implements the new Sequence API with logic for incrementing and decrementing sequences.
src/libraries/System.Linq/src/System/Linq/InfiniteSequence.cs Adds InfiniteSequence API for generating unbounded sequences.
src/libraries/System.Linq.AsyncEnumerable/* Provides asynchronous versions of Sequence and InfiniteSequence along with corresponding tests and project file updates.

@stephentoub
Copy link
Member Author

/ba-g wasm crashes in unrelated test suites

@stephentoub stephentoub merged commit 960e063 into dotnet:main Jun 14, 2025
82 of 86 checks passed
@stephentoub stephentoub deleted the infinitesequence branch June 14, 2025 13:46

for (int i = 1; i < 3; i++)
{
Assert.NotNull(Enumerable.Sequence(T.CreateTruncating(123), T.CreateTruncating(122), T.CreateTruncating(-i)));
Copy link

Choose a reason for hiding this comment

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

Is this NotNull assertion working as expected?
It seems always pass tests because Enumerable.Sequence always returns non null value.

I though It seems Assert.Empty is expected to be used here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, these can be Assert.Empty instead of Assert.NotNull.

Copy link

Choose a reason for hiding this comment

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

My comment above was incorrect.,
These assertions seems expected Assert.NotEmpty not Assert.Empty

@github-actions github-actions bot locked and limited conversation to collaborators Aug 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Generic Enumerable.Sequence method

6 participants