开发者

Possible to keep a method from showing up in intellisense?

开发者 https://www.devze.com 2023-01-07 02:34 出处:网络
Say I have a class and I want to deprecate a method.Is it possible t开发者_Go百科o have that method not show up in intellisense so that people won\'t be temped to use it?I just want existing code that

Say I have a class and I want to deprecate a method. Is it possible t开发者_Go百科o 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.


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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消