Visual Studio 2008 intellisense for an enumeration type
Is there a setting whereby intellisense in Visual Studio will also put variables in the intellisense pop up instead of just the values for the enumerated type? It obviously knows it is supposed to be an enumeration. Maybe this is just a mechanism to keep me from putting something in there that might cause an exception.
Consider the following setup: (It's a bit contrived, and I'm sorry about that.)
Public Enum PhraseEmphasis
Monotone = 0
Question
Statement
Exclamation
CrazyExclamation
QuestioningExclamation
Cursing
End Enum
Private _emphasisFromCode as PhraseEmphasis
Public Function Speak(ByVal phrase As String, ByVal emphasis As PhraseEmphasis) as String
Select Case emphasis
Case PhraseEmphasis.Question
Return phrase + '?'
Case PhraseEmphasis.Statement
Return phrase + '.'
Case PhraseEmphasis.Exclamation
开发者_JAVA技巧 Return phrase + '!'
Case PhraseEmphasis.CrazyExclamation
Return phrase + '!!!1!eleven!!'
Case PhraseEmphasis.QuestioningExclamation
Return phrase + '?!'
Case PhraseEmphasis.Cursing
Return '!@#@%@#!'
Case Else
Return phrase
End Select
End Function
Now, in the code I have something that sets the _emphasisFromCode (obviously) and then I want to call the function. Then what happens when I start typing Speak("HelloWorld", ...) at the elipses there, I don't like the intellisense. The only thing that pops up in the intellisense is a list of all enumerations.
And now I have spent a disproportionate amount of time explaining this with respect to how much I actually care. However, my machine is really slow in compiling today.
Nope, there's no such setting. The Intellisense lists the enumeration to allow you to quickly select one. If you have one stored in a variable (or multiple variables of type PhraseEmphasis
), it won't scour your code for matching variables of the parameter type to populate the parameter suggestions with.
Apart from that, the only related settings are to enable/disable Intellisense:
VB has additional options under Basic -> VB Specific, but still nothing for what you suggest.
To my knowledge, I don't think CodeRush/Refactor! Pro or ReSharper (Visual Studio add-ins) offers this feature either.
No, there is no such setting. How could IntelliSense guess from your method signature, that you want to put an arbitrary value to the method, when the signature states exactly the opposite?
Instead, you may declare another enum member (say PhraseEmphasis.None = 0
, which is recommended best practice anyway) and use that, or eventually declare the emphasis
parameter with the optional
keyword to avoid the need of providing it altogether.
精彩评论