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
2010-07-15 14:35:39
+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
2010-07-15 14:43:53
Does regular Intellisense do the strikethrough? I thought that was a Resharper feature.
James Curran
2010-07-15 14:49:00
@James You are correct. Good catch. I will modify my answer.
Chris Dwyer
2010-07-15 14:51:51