Thursday, March 19, 2009

CodeRush and Refactor 9.1.0 Beta

-------------------------------------------------------------
Update: Since the full release of CodeRush and RefactorPro 9.1 Mark Miller has posted his own feature list. I’m amazed how much extra there is in this release that I completely missed.
-------------------------------------------------------------

Well the guys (and maybe gals who knows) at DevExpress are clearly very busy.

They’ve released a beta of their DXperience (v9.1.0) suite of Controls, Frameworks and Tools

This release (beta though it is) represents the first time that CodeRush and RefactorPro  have been made available in a single install together. The downside for now is that you have to download the entire 252Mb which represents their entire line-up.

Having got 9.1.0 (I only installed the IDE tools for now), I immediately noticed a few changes.

 

"New user" experience

The first time you run this new version of CodeRush, you’ll be asked what sort of user experience you’d like.

CodeRushUserMode

If you pick the first option then the DXCore (on which RefactorPro and CodeRush are based) will warn you when it expands a template or intercepts a shortcut giving you an opportunity to decide if that's the behaviour that you'd like.

HotKey Help

If the hotkey you hit used to does something in Studio normally, you'll be reminded of what that was/is and given the opportunity to disable the CodeRush Template or Hotkey. DXCoreChoice

In the above screen shot, I have used the ‘Tab’ key whilst the caret is positioned within an identifier in the editor. The popup, which in true CodeRush fashion, is Non-Modal, appears and presents you with a few options.

You can…

  • Change the CodeRush Binding for ‘ReferenceNext’ from ‘Tab’ to another key.
  • Change the Visual Studio Key binding for ‘Edit.InsertTab"’ from Tab to another key.
  • Tell DXCore to ALWAYS suppress ‘Edit.InsertTab’ in favour of ‘ReferenceNext’ (for this binding and assuming an appropriate context)
  • Tell DXCore to NEVER suppress ‘Edit.InsertTab’ in favour of ‘ReferenceNext’ (for this binding)

Template Help

If you were to type…
-------------------------------------------------------------
c<space>
-------------------------------------------------------------
…in an empty vb file you’d see the following popup.CoderushTemplateExpandWarning

The template expansion has already happened in the background, but can be reversed with a simple Ctrl+Z. In the mean time you get to see the effect of the template and options to allow this in future or not. Further you have the option to visit the ‘Templates’ options page which will open on the template you have most recently used and give you the opportunity to change some aspect of the way it works

This "’New User’ selection allows you to see what CodeRush/DXCore is doing and to decide if that suits your needs.

One word of warning… The CodeRush Template trigger phrases are designed to be memorable and simple to type. for this reason they typically contain the fewest number of keystrokes possible. for example you might have  For this reason you might find that they attempt to expand when you use variables with particularly few characters like ‘c<space>’ will expand (outside of a class) to the  template you saw above and ‘dr<space>’ will expand to the phrase ‘DialogResult’.

If you typically use variables with small numbers of characters, then is likely that you will find CodeRush expanding code all over the place. This ‘New User’ facility will help to at least explain this what is happening. However I would urge you, if this is the case, to consider using longer variable names. This will result in more readable code and CodeRush will more than save you the extra keystrokes that you will type as time passes.

If instead of the ‘New User’ option, you pick the "Expert User", you’ll default back to the standard situation where DXCore intercepts and overrides VS where keystrokes overlap without notifying you.

DXCore Toolbar

The DXCore Toolbar is a standard VS toolbar which allows you to toggle various UI features added by CodeRush.

DXCoreToolBarThese are:

  • Code Issues
  • Spell Checker
  • Member Icons
  • Flow Break Indicators
  • Code Metrics
  • Structural Highlighting
  • Region Painting
  • Right Margin Line

No word yet on how other plugin providers might extend this facility to their own UI plugins, but I've already gotten good use out of the Code Issues button.

Code Issues appears to be fast enough now to allow me to code without a slowdown of any kind, but there are times when I need to really concentrate on a particularly complex piece of coding. In these circumstances the radio is turned off (to remove the audio distraction) and Code Issues is put away (to remove what, in said times of concentration, can be viewed as visual clutter).

We used to have to visit the correct page in the hierarchy on the options screen in order to find the right option for each of these. now you simply click the right button. It's so simple but so effective. And being a VS toolbar itself, it is discreet and fits in very well with it's surroundings.

Code Issues

Not immediately apparent until you actually use it, is the fact that CodeIssues has undergone some changes to it’s UI.

For the uninitiated, Code Issues (Sometimes referred to as Code Analysis) has been available as an early access feature for some time now. It provides Graphical cues to code smells within your project/solution.

Since the UI make over, we now have nice bright informative popups to make very clear to us what is potentially wrong, or what might be better done another way.

Some sample Code Issues are:

CodeIssuesUnusedDeclaration

CodeIssuesRedundantNamespace

CodeIssuesSpecialWebPage

Additionally, an interface accessible from the left of the code file, allows you to navigate through the Issues….

 

CodeIssuesInterfaceLeft

…and even suppress the ones you aren’t interested in seeing in the future. (By Solution, Project, File or just everywhere)

CodeIssuesSuppress

Under the hood

Under the hood there are a few changes as well. The once simple folder layout has been altered to include not 1 but 7 plugin directories. Well 7 directories if you install everything that comes with the beta of the IDE Tools.

There's one directory for each of :

  • CodeRush
  • CodeRush Xpress
  • DXCore
  • RefactorPro
  • Refactor VB
  • Refactor CPP
  • Refactor ASP

As well as a few support directories. A little digging suggests that with a quick registry addition, we can create a pointer to a new directory for the plugins from our Community Plugin Site.

Build it yourself

Finally 2 of the 'Labs' plugins which have previously been available only on request, now ship with the main products. Both the 'Memory Lab' and 'Expression Lab' are available from the "DevExpress\Tool Windows\Diagnostics" menu

These plugins are used to analyse code and memory usage to aid in the construction of your own plugins.

Final version

Who knows what might change or be added in the final build of this version of the IDE tools. I do know I like what I've seen so far and this version (beta though it is) will be staying on my machine until another version comes along to replace it.

This Beta is only available to existing DXperience subscribers. Note this means any level of DXperience including DXperience ASP.NET, WinForms, Enterprise and Universal. If this is you then feel free to drop by the Client Center (http://www.devexpress.com/ClientCenter/)  and look for the Beta Tab.

It’s worth mentioning once again, since so many seem not to know, that Microsoft MVP’s are entitled the Universal variant of this for free. If you’re an MVP who would like a Free licence of everything.Net that DevExpress do (including Components, Frameworks and IDE Tools + Access to this new beta), then contact ClientServices@DevExpress.com


Tuesday, March 17, 2009

The walk to School

This morning my wife (Anne) was walking the kids to school and she related the following story to me about the journey.

Daniel (5) suddenly jumped… He became very concerned, worried and then frightened.

“Mummy… What was that..?!?!?”

“What do you mean dear?”

“That noise! That noise! What is it ?!?”

Sounding more and more frightened he started backing away from the road towards the nearest fence.

“What’s that noise!?! I don’t like it!!”

Daniel was looking around himself, as he didn’t know where this ’Noise’ was coming from.

Our son Daniel, has recently (Last Friday – so approx 4 days have elapsed) undergone minor surgery to insert grommets into his ears to fix a condition called glue-ear.

My reaction to hearing this story was the same as Anne’s at the time.

Had something gone wrong?

Was he now suffering some horrible form of Tinnitus or something worse?

Anne tried to calm Daniel down but he was very unnerved. They started to try to work out what the noise might be. It wasn’t the Cars or nearby people talking. It wasn’t constant, but very small (short) and spaced out by about 3-4 seconds in bursts. Daniel can’t describe all these concepts (burst, short noise) but mothers are very good at extracting this sort of information from their children.

Gradually Anne got Daniel to indicate when he was hearing the noise, telling him all the while that everything was fine and that nothing was going to hurt him.

Anne was listening all the while to see what she could match up the nearby audio with the timing that he indicated.

Then it dawned on her…

Calm descended on her…

“Daniel”

“Yes Mum”

“It’s Ok…I know what it is”

“What is it?”

“It’s the birds…They are singing”

“Singing Mum ?”

“Yes Daniel they tweet and sing.”

“Oh…(calming) …Oh… (breathing easing) …ok …(starting to relax).. ok ”

“Daniel..have you never heard birds sing before?”

“No mum never…It’s nice…..Can we get a bird?”

“No Dan… Sorry they would cost too much for us to keep one”

“Oh ok mum (slight note of disappointment)……(Pause)… Mum when I get home after school, can I sit in the garden and listen to them? (hopeful)”

“Absolutely Dan… No problem (beaming)… Now shall we get you to school”

“(furious nodding and smiling)”

So I would like to take this opportunity to thank those Nurses, Surgeons and frankly all other members of Poole General Hospital for their wonderful work in bringing my son the gift of being able to hear the birds sing.

You will never understand how much this means to him and us :)


Monday, March 16, 2009

CodeRush and Dark Color Schemes

It has been noted that the default colors for CodeRush are a little hard to see if you use a darker color scheme.

I asked about on twitter and it seems not many so far have bothered to tweak the default settings for such a scheme. However David O’Hara is one man who has certainly taken up the challenge. Personally I’m in favour of the lighter side of schemes but for those of you who have turned to the dark side here is a copy of the “painting” settings within CodeRush which David uses to achieve the following affect on his “Vibrant” color scheme.

Code

 

FlowControl


CodeRush Wish list

Everyone (in the Tech world) who knows me, knows I am a big fan of the DevExpress stack ( DXCore, Coderush, RefactorPro)

I will grant you that we could always do with more perf / stability. (Although I haven’t had issues with either of these in the DevExpress stack for some time)

However I thought I’d sit down for a few minutes and try to bash out  a short list of improvements I’d make to CodeRush if I were in charge :D (Hey we all know that’s never going to happen so this is the closest I’m gonna get :)

This is just a small list of things that I feel would make CodeRush that little bit better.

Multi file templates

Ok I lied… This feature wouldn’t make CodeRush a little bit better. For me at least this would add hugely to Coderush.
I’m quite sure that the possibilities for this go well beyond what I’ve thought of.

So what is a Multi-File template?

Well simply put, it is a template whose output results in text being injected into multiple (possibly not yet existing) files.

For example I could “Create New Form” using…
-------------------------------------------------------------
CNF<Space>
-------------------------------------------------------------

In Winforms Project, this would create a Form1.vb and Form1.designer.vb, links the 2 and creates suitable multi-file linked fields for phrases like Form1 throughout.

The same template should work inside an ASP.Net App, an MVC App and a WPF App, creating suitable forms in those circumstances

This could easily be extended to work for WebServices, UserControls and many other types.

With the right templates in place, you'd never need to visit the "File Add New" dialog again :)

[Update: So this turned out to be so easy I built it myself]

Enhance 'Go To Definition

I really like the ability to leap from one part of the code to another in a logical fashion but we have developed a in-house practice which makes this rather difficult.

We don't use project references.

Instead, every reference made in a solution built by us, is to a dll already built at an earlier stage of said build.

We use file references in order that large solutions may be broken down into smaller ones with a subset of the projects that exist in the whole. This may be done by copying the Solution (or using save as) and then any projects not being edited may be deleted.

The down side of this is that when I select 'Go To Definition' for an object in one of those other assemblies, I will invariably end up in the object browser.

I would really like CodeRush to look around the solution and recognise that there is a project in the solution which has the exact same namespace structure as the item I am attempting to locate the Definition of and redirect me to the source of that item.

 

Setting Schemes

Allow me to copy my settings to multiple named instances and allow me to switch between them. This does not need to be quick, but I could have a 'full' set, a 'slim line' set and an 'experimental' set.

Due to the recent inclusion of the Plugin Manager ToolWindow, we would be able to define schemes of plugins. so we could switch to a very minimal set of plugins in order to enhance speed.

 

Setting Export/Import

I would love to be able to create a “Selection Embedding”, “Shortcut”, “Template” or other setting and be able to export it to a file something like a .reg file.

I could then hand this file to a user or post it on my blog or attach it to a forum post.

CodeRush/Refactor/DXCore would have installed and associated a new utility with files of this type in order that a simple double-click would be treated as a request to absorb these settings into your current DXCore installation.

Naturally DXCore would detect if you had multiple sets of settings and ask you which ones you wished to affect with this file… Offering you the chance to backup these settings prior to this if needed.

 

Filterable Toolbox

There are so many items in the toolbox these days, especially with the DXperience controls, that it can be quite hard to find what you’re after.

This could be solved with the introduction of a search box at the top of the toolbox. This would probably just restrict the showing toolbox items based on an incremental contains search using the text currently in the search box. It would probably be fair to remove the tabs during such a search but this could be optional.

In simple terms, it would work like the Vista Start Menu

 

 

These are just a few things which I feel would make CodeRush even better.


Is Dynamic is too dynamic?

I was just watching the start of a screencast by Kirill Osenkov.

In it he describes some of the new features for C# 4.0 starting with the dynamic keyword.

Take for example the following…
-------------------------------------------------------------

static void main()
{
    dynamic SomeVar = 1;
    SomeVar.Foo();
}
-------------------------------------------------------------

Now while I appreciate the ability to call into dynamic methods in this way… I feel it’s too easy to get things wrong.

I can call into this dynamic method several times and any mistakes made are simply not detectable until runtime.

So I can call a method correctly several times and then call it incorrectly once also and not notice the mistake until my programming logic is enacted at runtime.

-------------------------------------------------------------

static void main()
{
    dynamic SomeVar = SomeOfficeToolbarFactory.GetMeAToolbar();
    SomeVar.Show();
    SomeVar.Hide();
    SomeVar.Show();
    SomeVar.Hide();
    SomeVar.Show();
    SomeVar.Hide();
    SomeVar.Show();
    SomeVar.Hide();
    if (SomeSpecialConditionHere)
    {
        SomeVar.Showww(); // <- this does not exist at runtime.
    }
}
-------------------------------------------------------------

What about if I could define the dynamic methods that I expected to exist on a given type at runtime?

What if you could define a “dynamic partial interface” for any type which would list said methods?

So in VB.Net terms I could say…

-------------------------------------------------------------
Dynamic Partial Interface SomeOfficeToolBar
    Sub Show()
End Interface
-------------------------------------------------------------

If this definition existed then the compiler could detect that “Showwww()” was incorrect before runtime.

“Show()” and “Hide()” would still be detected and used dynamically but you would giving yourself design time aid in finding bugs in dynamic calls.

I guess it’s a bit like defining your external functions using a .h file in C++

Now technically this would no longer be a dynamic type. It would still be a static type. However you would have added the ability to statically check the code that made calls to methods which would be located dynamically at runtime.

 

Just a thought.