园子的博客系统从 .NET 9 升级到 .NET 10 后,下面的代码
return await blogStreams
.Aggregate((acc, list) => acc.Concat(list))
.OrderByDescending(p => p.DatePublished)
.ToListAsync();
编译是报错
The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Concat<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Collections.Generic.IAsyncEnumerable<TSource>)' and 'System.Linq.AsyncEnumerable.Concat<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Collections.Generic.IAsyncEnumerable<TSource>)'
是 Breaking change - System.Linq.AsyncEnumerable in .NET 10 引起的
.NET 10 introduces the AsyncEnumerable class, which provides a full set of LINQ extension methods for the IAsyncEnumerable<T> type. This class replaces the community-maintained System.Linq.Async NuGet library, potentially causing compilation errors due to ambiguities.
移除 nuget 包 System.Interactive.Async 解决了
dotnet package remove System.Interactive.Async
移除 System.Interactive.Async 后,项目中使用 ForEachAwaitAsync 的地方需要改回使用 await foreach