This project is read-only.

Incorrect error (CS1501) when specifying a named argument that doesn't match a parameter name


class Program
    static void Main()
        System.IO.File.Replace(sourceFilename: "file1.txt", destinationFilename: "file2.txt", destinationBackupFilename: "file3.txt");
error CS1501: No overload for method 'Replace' takes 3 arguments
...but there certainly is an overload that takes 3 args!

EXPECTED RESULTS (old compiler behavior):
error CS1739: The best overload for 'Replace' does not have a parameter named 'sourceFilename'


Kevin_H wrote May 24, 2014 at 5:35 AM

This is just error refinement, but the poor message led to at least 1.5 wasted hours for me today (incl. time to file this bug). That is, the impact is rather profound when you are unfortunate enough to encounter it...

I was dealing with 3 overloaded methods with 18, 19 and 20 parameters respectively. There was an unfortunate choice to use non-canonical casing in one of the parameter names, and I typed it wrong. I tried numerous things to narrow this down and eventually had to resort to debugging the compiler to figure out why overload resolution had failed. The old compiler gave the correct message.