views:

297

answers:

4

I found a bug in the method stub generation of Visual Studio intellisense.

class A { }
class B : A
{
    A a;
    void f() { a.NewMethod(); }
}

When I choose "Generate Method Stub" on a.NewMethod(), I should get a public method. Instead, intellisense confuses itself and creates a protected method for me.

The compiler correctly complains about the call to the generated protected void NewMethod() in A.

Is there any way to report this to Microsoft? This post says it's a Mission Impossible to get through.

+7  A: 

Go to the Microsoft Connect site. At least they are listening there. Of course, it might take a while until you receive an answer (or a fix).

David Schmitt
+1  A: 

Assuming your bug is a bug, post in the relevant microsoft.public newsgroup. They are usually pretty responsive.

cciotti
+3  A: 

Per Microsoft expected behavior is

"A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type."

http://msdn.microsoft.com/en-us/library/bcd5672a(VS.71).aspx

In your case a.NewMethod() generates an error because A is not derived from B. Which is exactly what you're talking about.

Therefore, the "Generate Method Stub" command is flawed.

That said, use Microsoft Connect for bug reporting. Let me know what the bug # is and I'll up vote it there.

Chris Lively
Thanks.The Bug # is 380127
Bjarke Ebert
I added a validation and upvoted it.
Chris Lively
+1  A: 

Sorry, you were right. I just tried this with Resharper's stub generator, and it created a public method.

hmemcpy