Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net - How do I hide methods/properties of my class-library (dll) from Visual Studio's IntelliSense?

Tags:

.net

vb.net

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...

like image 334
moster67 Avatar asked Mar 03 '09 20:03

moster67


3 Answers

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.

like image 63
Jon Skeet Avatar answered Nov 02 '22 04:11

Jon Skeet


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

like image 4
DCNYAM Avatar answered Nov 02 '22 06:11

DCNYAM


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

like image 2
JaredPar Avatar answered Nov 02 '22 04:11

JaredPar