views:

87

answers:

2

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.

+7  A: 

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

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

chibacity
+4  A: 

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.

Chris Dwyer
Does regular Intellisense do the strikethrough? I thought that was a Resharper feature.
James Curran
@James You are correct. Good catch. I will modify my answer.
Chris Dwyer