Search code examples
visual-studiomethod-signature

Can Visual Studio track signature changes like Eclipse does


Imagine I have two C# files.

The first file, Class1.cs contains

namespace CrossReferenceCheckingTest
{
    class Class1
    {
        public int doSomething(String s)
        {
            return 0;
        }
    }
}

and then in Class2.cs

namespace CrossReferenceCheckingTest
{
    class Class2
    {
        public void callDoSomething()
        {
            Class1 c1 = new Class1();

            int x = c1.doSomething("asdf");
        }
    }
}

If I change the signature of Class1::doSomething (eg: public String doSomething(int i){}) I will break the code in Class2.cs.

When I'm cutting Java code, the Eclipse editor will underline packages/classes with a red squiggle.

Is there a way in Visual Studio to see if any files in the project/solution are using the old broken signature?


Solution

  • Visual Studio (2010, at least) will immediately note the breaking change you posit above, underlining the relevant code in Class2 in red, and noting the error in the error list.

    If you don't see this underlining, make sure the relevant switches are enabled in Visual Studio's options (VS 2010 again), under Text Editor -> C# -> Advanced:

    • Underline errors in the editor
    • Show live semantic errors

    enter image description here