Visual Studio 2008 intellisense for enum type

Is there a setting where intellisense in Visual Studio also puts variables in intellisense and not just values ​​for the enumerated type? Obviously it should be an enumeration. Perhaps this is just a mechanism preventing me from putting something in there that could throw an exception.

Consider the following setup: (This is a little far-fetched, 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
    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, there is something in the code that sets _emphasisFromCode (obviously) and then I want to call the function. Then what happens when I start typing Speak ("HelloWorld", ...) on ellipses there I don't like intellisense. The only thing that pops up in intellisense is a list of all enums.

And now I've spent a disproportionate amount of time explaining this in terms of how much I really care. However, my machine is compiling very slowly today.

+2


source to share


2 answers


No, there is no such setting. Intellisense lists the enumeration so you can quickly select it. If it is stored in a variable (or multiple type variables PhraseEmphasis

), it will not check your code against parameter type variables to fill in parameter clauses.

Also, the only related settings are to enable / disable Intellisense:

visual studio options



VB has additional options under Basic -> VB Specific, but still nothing for what you suggest.

As far as I know, I don't think CodeRush / Refactor! Pro or ReSharper (Visual Studio add-ins) offer this feature as well.

+1


source


No, there is no such setting. How does IntelliSense guess from your method signature that you want to put an arbitrary value in the method when the signature indicates the opposite?



Instead, you can declare another enum member (say PhraseEmphasis.None = 0

, which has recommended best practice anyway) and use that, or end up declaring the parameter as a emphasis

keyword optional

to avoid having to complete it.

+1


source







All Articles