Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio's intellisense show private members and functions? [closed]

When working with native c++ in Visual Studio, intellisense shows private members and functions even when outside the scope of the containing class. This makes it hard to create clean APIs for the classes I write.

Is there a reason for this? Can this be prevented?

like image 727
aligray Avatar asked Jun 18 '11 00:06

aligray


People also ask

How do I open IntelliSense in Visual Studio?

Ctrl + Space should do it.

What is IntelliSense what are the option inside IntelliSense?

IntelliSense is a code-completion aid that includes a number of features: List Members, Parameter Info, Quick Info, and Complete Word. These features help you to learn more about the code you're using, keep track of the parameters you're typing, and add calls to properties and methods with only a few keystrokes.


2 Answers

Well, why shouldn't it show the private ones as well? They are members, after all, they exist and they are perfectly accessible from certain contexts, just like any other members.

It would be very difficult for the IntelliSense to determine whether the members are accessible or not from this specific context, especially if you take into account that in most cases this context is not yet complete (the user is still typing it up), meaning that it is generally impossible to analyze it.

like image 141
AnT Avatar answered Jan 02 '23 13:01

AnT


The reason probably only Microsoft knows. (I think Intellisense doesn't check where you are at the moment, so it doesn't know if you are inside the class (and can access the private members) or outside)

I actually don't know if or how it can be prevented.
But as far as I know, they have an Icon with a lock so you know that they are private. Perhaps that helps

like image 42
Zeus Avatar answered Jan 02 '23 13:01

Zeus