Description
Version Used: SDK 9.0.103 (not present in 9.0.200)
When a project targeting net9.0 calls an API declared in a class library targeting 8.0 and declaring an internal OverloadResolutionPriorityAttribute, and a deprioritized overload is called with the exact matching type, a CS1503 error is incorrectly produced as though the call was going to the prioritized overload whose type does not match.
When NUnit, for example, uses ORPA in its public API, this causes build failures for users of NUnit if they are writing tests with SDK 9.0.103 and net9.0.
Running dotnet build
on the following repro produces:
Repro.cs(7,24): error CS1503: Argument 1: cannot convert from 'System.Collections.IEqualityComparer' to 'System.Collections.Generic.IEqualityComparer'
Full repro here: Repro.zip
Text contents provided below.
ClassLibrary1.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>13</LangVersion>
</PropertyGroup>
</Project>
LibraryClass.cs
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class LibraryClass
{
public static void M(IEqualityComparer<int> p) { }
[OverloadResolutionPriority(-1)]
public static void M(IEqualityComparer p) { }
}
OverloadResolutionPriorityAttribute.cs
Repro.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>13</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
</ItemGroup>
</Project>
Repro.cs
using System.Collections;
class C
{
void M(IEqualityComparer p)
{
LibraryClass.M(p);
}
}
global.json
{
"sdk": {
"version": "9.0.103",
"rollForward": "disable"
}
}