Skip to content
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

FYI: LegalFilePathsOnly extension method is ambiguous in C# 7.2 and lower #957

Open
KalleOlaviNiemitalo opened this issue Jul 1, 2020 · 1 comment

Comments

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Jul 1, 2020

I got a C# compiler error like this, in a project consuming the System.CommandLine package:

error CS0121: The call is ambiguous between the following methods or properties: 'ArgumentExtensions.LegalFilePathsOnly<TArgument>(TArgument)' and 'OptionExtensions.LegalFilePathsOnly<TOption>(TOption)'

I was able to fix that by upgrading my project from C# 7 to C# 7.3. I presume this corresponds to What's new in C# 7.3 item "Overload resolution now has fewer ambiguous cases."

Filing this in case anyone else has the same problem.

To reproduce

Visual Studio 2017 version 15.9.24 and .NET Core SDK 2.1.515.

Source code:

using System.CommandLine;

namespace Demo
{
    internal static class Program
    {
        private static void Main()
        {
            new Option<string>("file").LegalFilePathsOnly();
        }
    }
}

Project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <LangVersion>7</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20303.1" />
  </ItemGroup>

</Project>
@KalleOlaviNiemitalo
Copy link
Author

KalleOlaviNiemitalo commented Jul 2, 2020

The required C# 7.3 feature 'ImprovedOverloadCandidates' was implemented in dotnet/roslyn#24756 and ought to be specified in dotnet/csharplang#98.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant