This project is read-only.
1

Resolved

Not very helpful CS0121 error message text

description

Compile following code
using System;

namespace A.B
{
    static class X
    {
        public static int Test (this int o)
        {
            return 1;
        }
    }
}

namespace A.C
{
    static class X
    {
        public static int Test (this int o)
        {
            return 2;
        }
    }
}

namespace C
{
    using A.B;
    using A.C.X;

    class M
    {
        public static int Main ()
        {
            if (1.Test () != 1)
                return 1;

            return 0;
        }
    }
}
It fails with "error CS0121: The call is ambiguous between the following methods or properties: 'X.Test(int)' and 'X.Test(int)'" which is quite hard to track down to actual methods when not in simple test case like this one.

comments

AdamSpeight2008 wrote Nov 11, 2014 at 5:30 PM

It's ask you to further disambiguate which method you want, as both static methods are in scope and the compiler can't guess your intent.
  using A.B;
  using A.C.X;
is letting you call methods within those namespaces with prefix them with the fully qualified namespace.

angocke wrote Nov 13, 2014 at 11:55 PM

Fixed in changeset f9ecd4d77ddc97bd1ebfb897350700b689795e9c