ReSharper 2.0 syntax highlighting problem isn’t a problem

I posted yesterday about ReSharper 2.0 shipping.

All through the beta I was having trouble with the syntax highlighting, both in VS 2003 and 2005. I thought it was a beta problem and it would be fixed by the production release.

It wasn’t.

Turns out it’s not a bug, the feature is just off by default. To turn on the glorious highlighting to which you are accustomed in ReSharper 1.5, go to ReSharper->Options… Select the Highlighting section, and check Color identifiers. Et voila!

I found this out in their forum. The guys at JetBrains were very quick to respond to the problems. Thanks to them for the tip.

Now playing: Hoobastank – Born To Lead

ReSharper 2.0 is here!

Super awesome: my favourite Visual Studio Add-in has just been upgraded.

I’ve been waiting a while for this release. The beta, which I’ve been using for the past few weeks, was showing a little roughness. Hopefully, they got rid of that. I’ve been pining for a few refactorings that they have in this release: push member up/pull member down. The error highlighting is still awesome, although they are a little aggressive on the warnings – I prefer prefixing member variables with ‘this’, for example – but they make it super easy to turn off the warning: Alt-Enter, disable warning. Too easy!

Even though there is some overlap with the features of VS 2005, I have to say they went beyond what MS provides, especially with code snippets – Resharper’s are context-aware and will put in what it thinks you want, usually they’re right; and now you can export them!

Some other features I love:

  • the code navigation is awesome – you never have to leave the keyboard. 
  • the code generation is really smart and it goes just as far as it needs to make you smile – for example, when implementing an interface with a property, Resharper will ask if you want to generate a member variable for the property too. Yes, please!
  • the refactorings kick the default Visual Studio refactorings all over the room, so much so that they took over the Refactor menu when you right click.
  • every feature has a keyboard shortcut. It’s totally worthwhile occupying a few brain cells with the short cuts, because they save you so much time.
  • the new preview documentation feature – hit Ctrl-Q over comments and get a preview of what they look like in a tooltip window.

To top it all off, the upgrade from 1.x is free! Go get it now.

Now playing: System Of A Down – Chop Suey

WinForms Weirdness – ToolStripDropDownItem.DropDownOpening not raised in a timely manner.

I’m working on a little project to learn the ins & outs of Winforms 2.0, and I’ll be posting in the near future (well, I think I’ll be posting stuff in the near future) on the surprises and gotchas I encountered; oh, and the cool stuff, too.

The first surprise, and coolness, is with the new MenuStrip control. Menus and toolbars got a huge makeover for 2.0. We got Win98 menus in 1.1; now, we have Office 2003 menus complete with themes, textboxes, comboboxes and CommandBars. Funny that we get all those things after the Office team abandons them, which is not to say that they aren’t useful. So the feature set is way bigger, and there is some translation needed. This article on CodeProject is very helpful for that translation for menus and toolbars.

So, what’s the weirdness? Well, I want to enable/disable a menu item based on whether some object is null. I’d do this in 1.1 with the MenuItem.Popup event. The article linked above says the Popup event on the MenuItem translates to the ToolStripDropDownItem.DropDownOpening event; ToolStripMenuItem inherits from ToolStripDropDownItem. I hook up the following event handler to my ToolStripMenuItem:

        private void myToolStripMenuItem_DropDownOpening(object sender, EventArgs e)

        {

            myToolStripMenuItem.Enabled = someObject != null;

        }

Looks normal, right? And, it works, but the event is raised at, it seems, arbitrary times which isn’t what I expected. I’d open the menu, let the mouse dance around a bit, then as soon as I pointed the mouse on that menu item, it would be disabled. That’s the weirdness. You can probably tell that this is not desirable behaviour: imagine your user clicks the menu, points her mouse at your terrific new feature in the menu but when she gets to it, it becomes disabled. That ain’t cool. So, I think I’m doing something wrong; I just can’t bring myself to believe that Microsoft would ship something that broken.

Now, I was hacking away, and I didn’t want to let this stop me, so I found a workaround which demonstrates some new coolness. The MenuStrip has a MenuActivated event that’s raised before it shows the menu, so I figured I’d try that event. This time, I’d have to find my menu item and then set the property, and that is the coolness. Jessica (aka jfo) explains the keyed collection that WinForms 2.0 gives you for every control. So I hook up the following event handler to the MenuStrip.MenuActivated event:

        private void menuStrip1_MenuActivate(object sender, EventArgs e)

        {

            MenuStrip menu = (MenuStrip)sender;

            ToolStripItem[] item = (ToolStripItem[])menu.Items.Find(“myToolStripMenuItem”, true);

            item[0].Enabled = someObject != null;

And that works like a charm. The boolean parameter is for searching all children, which is what I want. Passing false there only searches the top-level menu.

Now playing: Watchmen – Any Day Now

Technorati Tags: , , ,

Code Camp Follow-Up

We had our code camp today and I can only call it an outstanding success. There were almost no hiccups; the speakers that I heard were great and we had a butt in pretty much every seat, something we can’t do for a little two hour talk most meetings.

My talk went well (from my perspective, anyway  ); I got through all my demos without error and hopefully passed on what I wanted to about MSBuild. You can check out my resource page for the talk here.

Thanks to everyone who participated. Hopefully the next one will be that much better.

Now playing: Treble Charger – Brand New Low