CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.99k stars 294 forks source link

.NET 8 source-broke ROSExtensions.Count<> #796

Open xparadoxical opened 10 months ago

xparadoxical commented 10 months ago

Describe the bug

Error

CS0121 The call is ambiguous between the following methods or properties: 'System.MemoryExtensions.Count(System.ReadOnlySpan, T)' and 'CommunityToolkit.HighPerformance.ReadOnlySpanExtensions.Count(System.ReadOnlySpan, T)'

after changing the TargetFramework to net8.0.

Regression

7.1.2, 8.2.2 - with .net 7

Steps to reproduce

  1. dotnet new console -f net8.0
  2. dotnet add package CommunityToolkit.HighPerformance
  3. Program.cs:
    using CommunityToolkit.HighPerformance;
    _ = default(ReadOnlySpan<byte>).Count((byte)0);
  4. dotnet build

Expected behavior

It should compile, just like with net7.0.

Screenshots

No response

IDE and version

VS 2022

IDE version

No response

Nuget packages

Nuget package version(s)

8.2.2

Additional context

No response

Help us help you

No, just wanted to report this

ovska commented 10 months ago

I've encountered this as well. I wonder if this API is needed in .NET 8+ anymore, and could be omitted from compile on that target altogether.