Is it possible to hide select enumeration values from intellisense?  
Author Message
BhuttCrackSpackle





PostPosted: .NET Base Class Library, Is it possible to hide select enumeration values from intellisense? Top

If I have an enumeration in it that has values that I use internally as well as values I want users (clients) to use, is there a way that I can hide mine from intellisense Is there an attribute to do this




.NET Development31  
 
 
TaylorMichaelL





PostPosted: .NET Base Class Library, Is it possible to hide select enumeration values from intellisense? Top

Normally you could use the EditorBrowsable attribute to hide a class or class member but enumeration values aren't either of these. I'm not aware of any mechanism to hide enumeration values though. Intellisense only looks for this attribute on types and type members.

The only real workaround is to not define the enumerated values but rather rely on the fact that an enumeration is just an integer so you can define (through constants in a class or something) special values that are not part of the enumeration but can still be assigned to it. However this is generally not a good approach especially if your clients are careful because they will probably assume that any enumerated value not in the enumeration list is an error.

Michael Taylor - 10/11/06


 
 
ItchyAshcrackistan





PostPosted: .NET Base Class Library, Is it possible to hide select enumeration values from intellisense? Top

Actually, it does work on a per enum value basis...

Tried it and it worked.

<Flags(), Description("Use OR to set a flag. Use AND to test for a flag.")> _

Public Enum asrTraceLevel

<EditorBrowsable(EditorBrowsableState.Never)> [STRUCTURE] = 1

<EditorBrowsable(EditorBrowsableState.Never)> CONDITION = 2

INFORMATION = 4

WARNING = 8

[ERROR] = 16

CRITICAL = 32

End Enum