3

Based on this answer: " Should a property have the same name as its type? ", I've started to use property names the same as their class names. But recently I've met a strange corner case and I don't know if it is only my problem and how to solve it. Here is the code to repeat the case:

class R
{
    public Test Test { get; private set; }

    public R()
    {
        Test = new Test();

        // IntelliSense not working here:
        // Test.Use(
    }
}

public class Test    
{

}

public static class Extensions
{
    public static void Use(this Test test, string msg)
    {
        Console.WriteLine(msg);
    }
}

I'm using VS2010 and .NET Framework 4.0

Here is the video showing the problem: http://www.youtube.com/watch?v=HgszAu_Pir0&feature=youtu.be

Community
  • 1
  • 1
astef
  • 8,575
  • 4
  • 56
  • 95

1 Answers1

1

Could you try using .this when selecting the property?
eg. this.Test.use() ..

  • That helped, thank you! (you'll be awarded in 24 hours or so) Any thoughts about reason of that strange behavior? – astef May 17 '13 at 09:26
  • Well it happens because intelisense is not sure whether you are referring to the the class or the property therefore needing the (this) thing to state that 'hey i'm referring to the class member' – Geo A. Fragedakis May 17 '13 at 09:46
  • No, it knows I'm referring to the property because it shows `Use` method in combobox. Class `Test` has no static `Use` method. The reason of not displaying `Use` method's parameters is really strange. It could be a bug I think. – astef May 17 '13 at 11:37