-
Notifications
You must be signed in to change notification settings - Fork 841
Replace custom IAsyncEnumerable extensions with System.Linq.AsyncEnumerable #7039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…erable Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
adamsitnik
left a comment
There was a problem hiding this 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.
src/Libraries/Microsoft.Extensions.DataIngestion/Microsoft.Extensions.DataIngestion.csproj
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/DistributedCachingChatClientTest.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj
Outdated
Show resolved
Hide resolved
...ies/Microsoft.Extensions.DataIngestion.Tests/Microsoft.Extensions.DataIngestion.Tests.csproj
Outdated
Show resolved
Hide resolved
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
All feedback addressed in commit 83b9f5d:
|
adamsitnik
left a comment
There was a problem hiding this 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:
Line 43 in 30d910f
| <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>
Fixed in commit b75fa75. Updated the template files to use System.Linq.AsyncEnumerable v10.0.0 instead of System.Linq.Async v6.0.3:
|
adamsitnik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this 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.AsyncEnumerablev10.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 |
Cleanup System.Linq.AsyncEnumerable
Replace custom IAsyncEnumerable extensions with System.Linq.AsyncEnumerable from .NET 10.
Plan:
Changes Made:
System.Linq.AsyncEnumerablev10.0.0 package toeng/packages/General.propsIAsyncEnumerableExtensions.csfrom DataIngestion.Tests (63 lines deleted)Chunkimplementation from Batching.cs (38 lines deleted)ToAsyncEnumerableAsyncwith directToAsyncEnumerable()in DistributedCachingChatClientTest.csToAsyncEnumerableAsync(IEnumerable<T>)helper methodToAsyncEnumerablemethod from ReducingChatClientTests.csusing System.Linq;to test files:GeneratedContent.targetsto defineTemplatePackageVersion_SystemLinqAsyncEnumerablewith version 10.0.0ChatWithCustomData-CSharp.Web.csproj.into referenceSystem.Linq.AsyncEnumerableinstead ofSystem.Linq.AsyncVerification:
Security Summary:
No security vulnerabilities introduced by this change. The System.Linq.AsyncEnumerable package v10.0.0 has no known vulnerabilities.
Original prompt
✨ 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