views:

833

answers:

5

I am writing my first class-library in VB.NET. My idea is to distribute this library so others may use it in their applications.

However, perhaps due to my lack of experience in writing and structuring the library and the classes therein, I noted that the methods/properties are ALL being shown in the IntelliSense of Visual Studio.

The thing is that many of them are only used within the library itself and should NOT be used by the developers (could create a disaster) when they incorporate my library in their application - only a few should be visibile i.e. the ones which are needed by the developer.

Thus, my question is: is there a way to hide certain methods/properties of my library from Visual Studio's IntelliSense? Maybe something similar to REM?

Thanks in advance.

EDIT: as mentioned - this is my first library and I now understand that my question could be intepreted in two ways:

1) how to hide something from IntelliSense

2) how to prevent a developer from using and calling certain methods/properties

Of course, the end-result that I want is that the developer is not able to access AT ALL certain methods/properties i.e. No. 2 above.

Many thanks. I just learnt something new today and I will now study Access Levels...

+4  A: 

You need to change their access modifiers to something other than Public. If they are just used within a given class, make them Private Sub XYZ(). If they need to be accessed by other classes in the same assembly, make them Friend Sub XYZ(), etc.

http://msdn.microsoft.com/en-us/library/76453kax.aspx

NYSystemsAnalyst
+22  A: 

Only the types/methods/properties you want to be visible should be declared Public. The rest should be declared Private, Protected, Friend or Protected Friend.

You can read more about these access levels on the MSDN web page for them. In general you should usually only make things as public as they really need to be.

Jon Skeet
+1 I think this is actually what the OP was after - I didn't think that at first.
Andrew Hare
Andrew: You're right but I guess that my question was very vague. SOrry about that.
moster67
came here via Skeet's twitter. Good one! Upvoting.
abelenky
+2  A: 

For reference: http://www.fmsinc.com/free/NewTips/NET/NETtip23.asp

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public void myHiddenMethod() {
}
Inferis
To whoever downvoted this: just edit, even if the language is not good, the answer by itself solves the problem. Just edit.
Sunny
A: 

There's an attribute which you can apply to your code, meta data which will encurage Visual Studio to hide code. This code can still be called and I'd recommend against it, but if you really need it, just add:

What Andrew Hare said...

...to your code.

John Leidegren
+2  A: 

If you want to hide them then add a filterpriority tag to the XML comment of the function with the value 3

''' <summary>
''' </summary>
''' <filterpriority>3</filterpriority>
''' <remarks></remarks>
Sub DontShowMe()

End Sub

This will hide it by default in intellisense. You can also control the placement in the Common/All tab with the values 1/2 respectively.

Blog Post on the subject: http://www.lostechies.com/blogs/sdorman/archive/2009/01/10/xml-comments-filterpriority.aspx

JaredPar