Visual Studio Intellisense does not show shared overload methods

Given the following two interfaces (these are small examples, not my actual implementation):

public interface IAssertion<T> {
     IAssertion<T> IsNotNull();
     IAssertion<T> Evaluate(Predicate<T> predicate)
}

public interface IStringAssertion : IAssertion<string> {
     IStringAssertion IsNotNullOrEmpty();
}

and a static factory that will return the corresponding interface, for example:

public static class Require {
     public static IAssertion<T> That<T>(T value) {
          ...
     }

     public static IStringAssertion That(string value) {
          ...
     }
}

I should be able to do the following:

public void TestMethod(SomeClass a, string b) {
    Require.That(a).IsNotNull();
    Require.That(b).IsNotNullOrEmpty().Evaluate(SomeMethodThatAcceptsString);
}

This code compiles and will execute. I can even set up tests that pass, for example:

Assert.IsInstanceOf<IStringAssertion>(Require.That(string.Empty));
Assert.IsNotInstanceOf<IStringAssertion>(Require.That(new object());

The problem I am facing, and the whole point of this issue, is that Visual Studio 2005 intellisense does not resolve the differences between the two.

When I type Require.That("...")., I should expect to see a list

Evaluate (Predicate predicate)
IsNull ()
IsNotNullOrEmpty ()

but instead I don’t see anything.

. - Evaluate IAssertion.

, , - , , , .NET 2.0 api.

:

, Visual Studio. , Visual Studio - , . ( !)

, Visual Studio 2005, Visual Studio 2008.

:

Visual Studio 2008. , Luke. Visual Studio 2005.

+3
4

, , Intellisense , Generic Type, intellisense, . , "Require.That(string)", Visual Studios IAssertion IStringAssertion.

, "" IStringAssertion "ThatString".

public static class Require
{

    public static IStringAssertion ThatString(string value)
    {
        return null;
    }

    public static IAssertion<T> That<T>(T value)
    {
        return null;
    }

}

public class RAR
{
    public void TestMethod(StringComparer a, string b)
    {
        Require.That<StringComparer>(a).IsNotNull();
        Require.ThatString(b).IsNotNullOrEmpty();
    }
}

, , , .

+1

, , Intellisense .

0

Then you must install Resharper . This is much better than VS 2008 intellisense.

0
source

Same problem here - Intellisense is not so good.

I started using Visual Assist X and switched to Visual Assist X.

edit: (saw your answer to the resharper suggestion). I think resharper has a free version. In any case, the VAX is really worth it to buy it for yourself.

0
source

Source: https://habr.com/ru/post/1723345/


All Articles