Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to keep a method from showing up in intellisense?

Say I have a class and I want to deprecate a method. Is it possible to have that method not show up in intellisense so that people won't be temped to use it? I just want existing code that uses it to continue compiling but hide the method from view at the same time.

like image 859
Abe Miessler Avatar asked Jul 15 '10 14:07

Abe Miessler


People also ask

What does IntelliSense provide a list of?

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.

How can I see overloaded Methods in Visual Studio?

The default key binding for this is Ctrl + Shift + Space .

What is IntelliSense VSCode?

IntelliSense is a general term for various code editing features including: code completion, parameter info, quick info, and member lists. IntelliSense features are sometimes called by other names such as "code completion", "content assist", and "code hinting."


2 Answers

The EditorBrowsableAttribute attribute can be used to hide members from intellisense:

http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx

like image 88
Tim Lloyd Avatar answered Oct 18 '22 02:10

Tim Lloyd


Alternatively, you can use the System.ObsoleteAttribute. It still might be a good idea to have the method show up in intellisense, since technically it exists.

Using this attribute will show the method name in the intellisense, but with a [deprecated] tag in front of it.

[Obsolete("Method is in the process of deprecation.")]
void MyMethod() {...}

If you use ReSharper, and tell it to override Visual Studio's Intellisense settings, it will strikethrough the method name.

like image 31
Chris Avatar answered Oct 18 '22 01:10

Chris