Description
Application Name: Smartstore, blog, nopCommerceNetCore
OS: Windows 10 22H2
CPU: X64
.NET Build Number: dotnet-sdk-10.0.100-preview.1.25103.13
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2379210
Github Link:
https://github.com/smartstore/Smartstore
https://github.com/sagebind/blog
https://github.com/nopSolutions/nopCommerce
Verify Scenarios:
1). Windows10 21h2 x64 + dotnet-sdk-8.0.405 + default target 8.0: Pass
2). Windows10 21h2 x64 + dotnet-sdk-9.0.102 + retarget 9.0: Pass
3). Windows10 21h2 x64 + dotnet-sdk-10.0.100-preview.1.25103.13 + default 8.0: Pass
4). Windows10 21h2 x64 + dotnet-sdk-10.0.100-preview.1.25103.13-win-x64 + retarget10.0: Fail
Description :
When retargeting Smartstore app to .NET 10, it is built failed with CS0212 and CS0428 errors:
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)' and 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Where<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)' and 'System.Linq.AsyncEnumerable.Where<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToListAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.ToListAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToArrayAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.ToArrayAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToDictionaryAsync<TSource, TKey, TElement>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, TKey>, System.Func<TSource, TElement>, System.Collections.Generic.IEqualityComparer<TKey>?, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.ToDictionaryAsync<TSource, TKey, TElement>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, TKey>, System.Func<TSource, TElement>, System.Collections.Generic.IEqualityComparer<TKey>?, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.CountAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.CountAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
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>)'
error CS0428: Cannot convert method group 'Count' to non-delegate type 'int'. Did you intend to invoke the method?
Minimal Repro Steps:(Demo attached: AmbiguousCallDemo.zip)
Make sure the machine has dotnet-sdk-dotnet-sdk-10.0.100-preview.1.25103.13 installed.
- Create a .NET 9 Console project.
- Install latest version of System.Linq.Async nuget package.
- Add a Test.cs class file with below code:
public interface ITestInterface
{
IEnumerable<string> EnumerateFiles(string? pattern = "*", bool deep = false)
=> throw new NotImplementedException();
IAsyncEnumerable<string> EnumerateFilesAsync(string? pattern = "*", bool deep = false, CancellationToken cancelToken = default)
=> EnumerateFiles(pattern, deep).ToAsyncEnumerable();
//IAsyncEnumerable<string> EnumerateFilesAsync(string? pattern = "*", bool deep = false, CancellationToken cancelToken = default)
// => EnumerateFiles(pattern, deep).ToAsyncEnumerable();
async ValueTask<int> CountFilesAsync(string? pattern = "*", bool deep = true, CancellationToken cancelToken = default)
=> await EnumerateFilesAsync(pattern, deep, cancelToken).CountAsync(cancellationToken: cancelToken);
}
public partial interface IRuleService
{
Task<ITestInterface> CreateExpressionGroupAsync(int ruleSetId, bool includeHidden = false);
}
public static class TestStaticClass
{
private static readonly IRuleService _ruleService;
public static IAsyncEnumerable<TResult> SelectAwait<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
{
return source.ToAsyncEnumerable().SelectAwait(x => new ValueTask<TResult>(selector(x)));
}
public static void TestMethod()
{
int[] ruleSetIds = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var expressions = ruleSetIds
.SelectAwait(id => _ruleService.CreateExpressionGroupAsync(id))
.Where(x => x != null);
var expressions2 = ruleSetIds
.SelectAwait(id => _ruleService.CreateExpressionGroupAsync(id))
.ToArrayAsync();
var expressions3 = ruleSetIds
.SelectAwait(id => _ruleService.CreateExpressionGroupAsync(id))
.Take(1);
var expressions4 = ruleSetIds
.SelectAwait(id => _ruleService.CreateExpressionGroupAsync(id))
.Select(i => i != null);
var expressions5 = ruleSetIds
.SelectAwait(id => _ruleService.CreateExpressionGroupAsync(id))
.AnyAsync();
}
}
internal class CachingResult<TResult, TEntity>
{
public async Task<(object Value, int Count)> ConvertQueryAsyncResult(TResult queryResult)
{
object result = queryResult;
var list = await ((IAsyncEnumerable<TEntity>)result).ToListAsync();
return (list, list.Count);
}
}
- Retarget the project to .NET 10:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
- Build the project.
Expected Result:
Build successful.
Actual Result:
Build Failed with below errors:
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToListAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.ToListAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
error CS0428: Cannot convert method group 'Count' to non-delegate type 'int'. Did you intend to invoke the method?
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)' and 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.CountAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.CountAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)' and 'System.Linq.AsyncEnumerable.ToAsyncEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Where<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)' and 'System.Linq.AsyncEnumerable.Where<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.ToArrayAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.ToArrayAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Take<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, int)' and 'System.Linq.AsyncEnumerable.Take<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, int)'
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>)'
error CS0121: The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)' and 'System.Linq.AsyncEnumerable.AnyAsync<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Threading.CancellationToken)'
DotNet Info:
.NET SDK:
Version: 10.0.100-preview.1.25103.13
Commit: 9035d02b05
Workload version: 10.0.100-manifests.bf5105ba
MSBuild version: 17.14.0-preview-25073-02+291a81087
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-preview.1.25103.13\
Host:
Version: 10.0.0-preview.1.25080.5
Architecture: x64
Commit: b98cabca12
.NET SDKs installed:
10.0.100-preview.1.25103.13 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.0-preview.1.25103.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.0-preview.1.25080.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.0-preview.1.25080.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Findings:
After investigating, we found all the methods or properties thrown from errors come from System.Linq.Async
nuget package.
@dotnet-actwx-bot @dotnet/compat