Intellisense for case statements on enumerations not working?

I suppose I must have a strange setting in my options or something, cause I can't imagine this being an unnoticed bug.

I create a Windows Form Application in VS2008. Then I go to the forms properties and create an event handler for the MouseDown event. In it, I want to use a switch statement to see which mouse button was pushed, so I start with this:

using System.Windows.Forms; namespace WindowsFormsApplication1 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_MouseDown(object sender, MouseEventArgs e)         {             switch (e.Button)             {             }         }     } }



If I then type the word case inside the switch(mouseButtons), ReSharper's Intellisense isn't offering me anything. If I go ahead and type MouseButtons followed by a dot, ReSharper automatically changes it to the fully qualified System.Windows.Forms.MouseButtons. which doesn't make sense (as there is already a using System.Windows.Forms in the code file).

I would've expected Intellisense to offer me a list showing the  MouseButtons enumeration. I do get that list if I turn ReSharper off.

If I create a class with a method that defines a MouseButtons variable, the case still doesn't offer me anything, but when I type MouseButtons followed by a dot, at least it doesn't include the fully qualified name.

If I start typing if (e.Button ==, IntelliSense does show me a list with options, with the MouseButtons.Left semi active. In order to actually get the MouseButtons.Right entry, I have to push my down arrow first in order to actually select the item.

I'm not sure what should happen exactly. I think I would expect Smart Completion to kick in (I have the option to Automatically complete single item with... all turned on). I want to be able to type in case .R<tab> in order to get case MouseButtons.Right, as VS2008 does without ReSharper.

If I trigger Smart Completion myself by pressing Ctrl+Alt+Space, it does work (I get the MouseButtons enumeration and ReSharper doesn't add the fully qualified name). Although I still can't type .Right in order to get that option from the list. I would have to hit the down arrow key to go that the Right enumeration value. VS2008 itself will just show MouseButtons where Smart Completion only shows the members of MouseButtons.

So I have two questions
  1. Based on the default ReSharper settings, what should happen after typing case?
  2. What would be the fasted way to type in the case statement? Like I said, in VS2008 itself I can type in
    case .r: (case<space><dot>r<colon>) or
    if (e.b== .r)
    It seems like I have to use more keypresses in ReSharper to get the same result.
5 comments

Hello Dick,

At the moment this behavior is by design: you can get enum completion for
a 'case' label by using Smart Completion. You're welcome to log an issue
through our bug-tracker: http://youtrack.jetbrains.net/issues/RSRP if you'd
like to get such completion automatically. The quickest way to fill the switch
statement with all possible labels is to place the caret inside the switch
statement and use the 'Generate switch labels' context action. Let me know
if this helps. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I suppose I must have a strange setting in my options or something,
cause I can't imagine this being an unnoticed bug.

I create a Windows Form Application in VS2008. Then I go to the forms
properties and create an event handler for the MouseDown event. In it,
I want to use a switch statement to see which mouse button was pushed,
so I start with this:

 System.Windows.Forms;
> 
> namespace WindowsFormsApplication1
> {
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
> }
> private void Form1_MouseDown(object sender, MouseEventArgs e)
> {
> switch (e.Button)
> {
> }
> }
> }
> }]]>

If I then type the word case inside the switch(mouseButtons),
ReSharper's Intellisense isn't offering me anything. If I go ahead and
type MouseButtons followed by a dot, ReSharper automatically changes
it to the fully qualified System.Windows.Forms.MouseButtons. which
doesn't make sense (as there is already a using System.Windows.Forms
in the code file).

I would've expected Intellisense to offer me a list showing the
MouseButtons enumeration. I do get that list if I turn ReSharper off.

If I create a class with a method that defines a MouseButtons
variable, the case still doesn't offer me anything, but when I type
MouseButtons followed by a dot, at least it doesn't include the fully
qualified name.

If I start typing if (e.Button ==, IntelliSense does show me a list
with options, with the MouseButtons.Left semi active. In order to
actually get the MouseButtons.Right entry, I have to push my down
arrow first in order to actually select the item.

I'm not sure what should happen exactly. I think I would expect
Smart Completion to kick in (I have the option to Automatically
complete single item with... all turned on). I want to be able to type
in case .R<tab> in order to get case MouseButtons.Right, as VS2008
does without ReSharper.

If I trigger Smart Completion myself by pressing CtrlAltSpace, it
does work (I get the MouseButtons enumeration and ReSharper doesn't
add the fully qualified name). Although I still can't type .Right in
order to get that option from the list. I would have to hit the down
arrow key to go that the Right enumeration value. VS2008 itself will
just show MouseButtons where Smart Completion only shows the members
of MouseButtons.

So I have two questions
1. Based on the default ReSharper settings, what should happen after
typing case?
2. What would be the fasted way to type in the case statement? Like I
said, in VS2008 itself I can type in
case .r: (case<space><dot>r<colon>) or
if (e.b== .r)
It seems like I have to use more keypresses in ReSharper to get the
same result.

---
Original message URL:
http://devnet.jetbrains.net/message/5283456#5283456



0

Hi Andrey,

Thanks, the context menu options sure helps. It has the advantage that I can be sure all values of the enumeration will get a case label (that is, until the enum gets expaned with extra values of course).

Dick

0

I hope this will be fixed soon. As of now, I just use Visual Studio's IntelliSense and disable R#'s IntelliSense.

To R# team: please stop telling us that "this is by design". It's obvious that the feature was broken. Just fix it instead of being arrogant.

0

Hello Arvin,

Sorry, I didn't mean to be arrogant. With 'by design' I mean't that at the
moment there's no special treatment for places where an enum is expected
in basic completion, so you can use smart completion instead. As I've said,
you're welcome to log a request into our bug-tracker and we will schedule
a fix for one of the future releases. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I hope this will be fixed soon. As of now, I just use Visual Studio's
IntelliSense and disable R#'s IntelliSense.

To R# team: please stop telling us that "this is by design". It's
obvious that the feature was broken. Just fix it instead of being
arrogant.

---
Original message URL:
http://devnet.jetbrains.net/message/5312854#5312854



0

This seems to be fixed / changed in ReSharper 6.1. Don't know if anybody requested it specifically.

0

Please sign in to leave a comment.