简体   繁体   中英

Are there attributes in C# for affecting how IntelliSense displays class members?

Are there any C# attributes that I can apply to class members, to change the way they appear in the IntelliSense listings? This popped into my head when I was building a class with many static constants, and I (briefly!) wanted it to look like an enumeration in IntelliSense.

Yes, that's silly.

But it got me thinking - is there any way some crazy programmer can make a class members appear differently in IntelliSense? Make fields look like properties, etc?

For instance, there's the Obsolete attribute:

[Obsolete("Stop using this. Really. It's old.")]
public int VariableThatIsReallyOld;

Which prefixes the word [obsolete] to the description of VariableThatIsReallyOld .

有记载的DebuggerDisplay属性在这里

I tend to think that manipulating the comments is a much better proposition.

///<summary>
/// Bomb!
///</summary>
///<example></example><value></value><![CDATA[]]><param name="ss"></param><exception   cref="ss"></exception><remarks></remarks>
///<returns></returns> 

If you dig into the options available in the comment structure(which the intellisense and compiler understands) like <example>,<include>,<see>,<seealso>,<exception> etc, you can pretty get all the functionality sans performance dip introduced by the attribute.

Turns out there also some other attributes at Custom intellisense for server controls? (But the search continues!)

[EditorBrowsable(EditorBrowsableState.Never)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM