Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Cleanup System.Linq.AsyncEnumerable

Replace custom IAsyncEnumerable extensions with System.Linq.AsyncEnumerable from .NET 10.

Plan:

  • Explore repository and identify custom async enumerable extensions
  • Verify System.Linq.AsyncEnumerable availability in .NET 10
  • Add System.Linq.AsyncEnumerable package reference for older target frameworks
  • Remove custom IAsyncEnumerableExtensions.cs from DataIngestion.Tests
  • Remove custom ToAsyncEnumerable methods from AI.Tests files
  • Remove custom Chunk implementation from Batching.cs
  • Update all files to use System.Linq namespace
  • Build and test affected projects
  • Address review feedback
  • Update template files
  • Run security checks

Changes Made:

  • Added System.Linq.AsyncEnumerable v10.0.0 package to eng/packages/General.props
  • Added conditional package references to projects targeting frameworks older than net10.0:
    • Microsoft.Extensions.DataIngestion (src)
    • Microsoft.Extensions.AI.Tests (test)
  • Removed package reference from DataIngestion.Tests (inherited from DataIngestion project)
  • Removed custom IAsyncEnumerableExtensions.cs from DataIngestion.Tests (63 lines deleted)
  • Removed custom Chunk implementation from Batching.cs (38 lines deleted)
  • Replaced calls to ToAsyncEnumerableAsync with direct ToAsyncEnumerable() in DistributedCachingChatClientTest.cs
  • Removed unused ToAsyncEnumerableAsync(IEnumerable<T>) helper method
  • Removed custom ToAsyncEnumerable method from ReducingChatClientTests.cs
  • Added using System.Linq; to test files:
    • VectorStoreWriterTests.cs
    • HeaderChunkerTests.cs
    • DocumentChunkerTests.cs
  • Updated template files to use System.Linq.AsyncEnumerable:
    • Updated GeneratedContent.targets to define TemplatePackageVersion_SystemLinqAsyncEnumerable with version 10.0.0
    • Updated ChatWithCustomData-CSharp.Web.csproj.in to reference System.Linq.AsyncEnumerable instead of System.Linq.Async

Verification:

  • ✅ All DataIngestion tests pass (89 passed, 11 skipped)
  • ✅ All AI tests pass (368 passed)
  • ✅ No vulnerabilities in System.Linq.AsyncEnumerable package
  • ✅ Build succeeds for all target frameworks (net8.0, net9.0, net10.0, netstandard2.0, net462)

Security Summary:

No security vulnerabilities introduced by this change. The System.Linq.AsyncEnumerable package v10.0.0 has no known vulnerabilities.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cleanup System.Linq.AsyncEnumerable</issue_title>
<issue_description>Each project that uses any kind of custom IAsyncEnumerable extensions that are going to be available in 10, should switch to the new .NET 10 package once it gets published on Tuesday.

Samples:

internal static async IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IEnumerable<T> source)

private static async IAsyncEnumerable<T> ToAsyncEnumerable<T>(IEnumerable<T> items)

private static IAsyncEnumerable<TSource[]> Chunk<TSource>(this IAsyncEnumerable<TSource> source, int count)

cc @stephentoub
</issue_description>

<agent_instructions>Use System.Linq.AsyncEnumerable for all target framework versions, remove copies of the extension methods provided in the library.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Microsoft Reviewers: Open in CodeFlow

…erable

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot AI changed the title [WIP] Cleanup System.Linq.AsyncEnumerable usage in projects Replace custom IAsyncEnumerable extensions with System.Linq.AsyncEnumerable Nov 12, 2025
Copilot finished work on behalf of adamsitnik November 12, 2025 09:33
Copilot AI requested a review from adamsitnik November 12, 2025 09:33
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@copilot Please address my feedback.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot Please address my feedback.

All feedback addressed in commit 83b9f5d:

  • Changed from System.Linq.Async to System.Linq.AsyncEnumerable v10.0.0
  • Removed package reference from DataIngestion.Tests (inherited via project reference)
  • Replaced ToAsyncEnumerableAsync calls with direct ToAsyncEnumerable() calls
  • Removed unused helper method

Copilot finished work on behalf of adamsitnik November 12, 2025 09:59
Copilot AI requested a review from adamsitnik November 12, 2025 09:59
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@copilot please solve the following build error:

dotnet build --no-restore

Working Directory: D:\a_work\1\s\test\ProjectTemplates\Microsoft.Extensions.AI.Templates.IntegrationTests\ExecutionTestSandbox\AIChatWeb_ed87416b84\BasicApp_a14d7ae760

Command failed with non-zero exit code: 1

Standard Output:
D:\a_work\1\s.dotnet\sdk\10.0.100-rc.1.25451.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(345,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [D:\a_work\1\s\test\ProjectTemplates\Microsoft.Extensions.AI.Templates.IntegrationTests\ExecutionTestSandbox\AIChatWeb_ed87416b84\BasicApp_a14d7ae760\BasicApp.csproj]
D:\a_work\1\s\test\ProjectTemplates\Microsoft.Extensions.AI.Templates.IntegrationTests\ExecutionTestSandbox\AIChatWeb_ed87416b84\BasicApp_a14d7ae760\Services\SemanticSearch.cs(25,30): error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Select<TSource, TResult>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, TResult>)' and 'System.Linq.AsyncEnumerable.Select<TSource, TResult>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, TResult>)' [D:\a_work\1\s\test\ProjectTemplates\Microsoft.Extensions.AI.Templates.IntegrationTests\ExecutionTestSandbox\AIChatWeb_ed87416b84\BasicApp_a14d7ae760\BasicApp.csproj]

You probably just need to update the following package reference:

<PackageReference Include="System.Linq.Async" Version="${TemplatePackageVersion_SystemLinqAsync}" />

and use System.Linq.AsyncEnumerable there as well.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot please solve the following build error:

Fixed in commit b75fa75. Updated the template files to use System.Linq.AsyncEnumerable v10.0.0 instead of System.Linq.Async v6.0.3:

  • Updated GeneratedContent.targets to define TemplatePackageVersion_SystemLinqAsyncEnumerable
  • Updated ChatWithCustomData-CSharp.Web.csproj.in template to reference the new package

Copilot AI requested a review from adamsitnik November 12, 2025 12:01
Copilot finished work on behalf of adamsitnik November 12, 2025 12:01
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM!

@adamsitnik adamsitnik marked this pull request as ready for review November 12, 2025 14:05
@adamsitnik adamsitnik requested review from a team as code owners November 12, 2025 14:05
Copilot finished reviewing on behalf of adamsitnik November 12, 2025 14:08
@adamsitnik adamsitnik merged commit 47a225b into main Nov 12, 2025
9 of 10 checks passed
@adamsitnik adamsitnik deleted the copilot/cleanup-system-linq-asyncenumerable branch November 12, 2025 14:13
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 replaces custom IAsyncEnumerable extension method implementations with the new System.Linq.AsyncEnumerable package from .NET 10, addressing technical debt and standardizing on the official implementation.

Key changes:

  • Adds System.Linq.AsyncEnumerable v10.0.0 package with conditional references for pre-.NET 10 frameworks
  • Removes 101 lines of custom async enumerable extension methods across multiple files
  • Updates project templates to reference the new package

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
eng/packages/General.props Adds System.Linq.AsyncEnumerable v10.0.0 package version definition
src/Libraries/Microsoft.Extensions.DataIngestion/Microsoft.Extensions.DataIngestion.csproj Adds conditional package reference for frameworks older than net10.0
test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj Adds conditional package reference for frameworks older than net10.0
src/Libraries/Microsoft.Extensions.DataIngestion/Utils/Batching.cs Removes custom Chunk implementation (38 lines) and conditional compilation directives
test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Utils/IAsyncEnumerableExtensions.cs Removes entire file with custom extension methods (63 lines)
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/ReducingChatClientTests.cs Removes custom ToAsyncEnumerable method and updates usage
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/DistributedCachingChatClientTest.cs Updates method calls and removes unused ToAsyncEnumerableAsync helper
test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Writers/VectorStoreWriterTests.cs Adds using System.Linq statement for ToAsyncEnumerable extension method
test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Chunkers/HeaderChunkerTests.cs Adds using System.Linq statement for ToAsyncEnumerable extension method
test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Chunkers/DocumentChunkerTests.cs Adds using System.Linq statement for ToAsyncEnumerable extension method
src/ProjectTemplates/GeneratedContent.targets Updates template variable from SystemLinqAsync to SystemLinqAsyncEnumerable with v10.0.0
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/ChatWithCustomData-CSharp.Web.csproj.in Updates package reference from System.Linq.Async to System.Linq.AsyncEnumerable

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup System.Linq.AsyncEnumerable

3 participants