dotnet / dotnet/command-line-api
FYI: LegalFilePathsOnly extension method is ambiguous in C# 7.2 and lower
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
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)' and 'OptionExtensions.LegalFilePathsOnly\(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](https://docs.microsoft.com/dotnet/csharp/whats-new/csharp-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:
```C#
using System.CommandLine;
namespace Demo
{
internal static class Program
{
private static void Main()
{
new Option("file").LegalFilePathsOnly();
}
}
}
```
Project:
```XML
Exe
netcoreapp2.1
7
```
Contributor guide
Assessment
This issue has not been assessed yet.