Finally an improved debugger's Step Into feature

Finally we got an improved VS' Step Into feature. But what is wrong with actual one? Let's see an example:

public static void Main() { SomeMethod(SomeField, GetSomeValue()); } private void SomeMethod(bool flag, int value) { ... } private bool SomeField { get { bool result = ... ... return result; } } private int GetSomeValue() { .... return number; }

Imagine you are positioned before SomeMethod gets invoked and you want to step into SomeMethod directly. Untill now you've got an annoyance here. The only option was to set a breakpoint at the beginning of SomeMethod and Step Over or run the code and wait for breakpoint being hit.

If you instead choose Step Into then you would step into each of the parameters being passed before stepping into SomeMethod, in my case a property and another method.  Highly annoying.

OK, there is also a DebuggerStepThrough attribute which you can apply at design time to a property or to a method. At the runtime the debugger won't step into methods or properties decorated with this attribute. But this option is very rigid as you have to decide at design time and you can't change it during execution. Plus it requires source code modifications.

So people have been waiting for direct step into (or whatever you want to call it) since the beginning of VS creation. No luck so far, [MS] apparently didn't hear on this ear. Instead, fine [DevEx] folks decided to implement it by themselves and put the feature into the latest incarnation of CodeRush. Yes, by installing CodeRush 2.1.1 or newer you get direct step into through the Shift-Ctrl+F11 (configurable) shortcut. No more ad-hoc breakpoints, no more countless hours of stepping into just to get into the right method - hit Shift+Ctrl+F11 and there you go directly into the method you want.

If you are still undecided whether to install CodeRush or not, this is a perfect reason to install it. Besides this handy feature there is a lot, lot more that CodeRush brings you.

Default Padding for XtraLayoutControl items

[DevEx] XtraLayoutControl sets its items default Padding to 5;5;5;5 (left, right, top, bottom) which might not be always desired value and there is no easy way to alter this default setting as per this support center entry.

However, there is a solution that is fairly easy to implement. Just derive a class from XtraLayoutControl and override CreateLayoutItem method as shown in this piece of code:

public class RhLayoutControl: LayoutControl { public override BaseLayoutItem CreateLayoutItem(LayoutGroup parent) { BaseLayoutItem item = base.CreateLayoutItem(parent); item.Padding = new Padding(5, 5, 2, 2); return item; } }

Here I set default Padding for an item to (5, 5, 2, 2) but you can set is as you wish. Of course, instead of XtraLayoutControl you would have to use RhLayoutControl to make this trick work.

Visual Studio 2005 SP1 beta looses 3rd party toolbox entries

After installing VS 2005 SP1 beta I noticed that all 3rd party icons disappeared from toolbox. Apparently SP1 beta looses icons on install. The situation is more annoying with [DevEx] components because setup won't repair the situation nor will uninstall/install help (Note: I didn't check much other vendor's components, I just noticed that telerik stuff is installed correctly). Obviously SP1 beta changed something in toolbox entry install process and installer for [DevEx] stuff doesn't work correctly. You can still create all those entries manually but this process is rather tedious.

The good news is [DevEx] folks already fixed the problem. All you need to do is to download improved ToolBoxCreator tool (a tool that ships with their stuff) that you'll find here and run it. Simple as that.

My favorite CodeRush/Refactor! Pro features

  1. Ctrl+3 aka embed method in region with the name of method
  2. Auto Completition aka completes the word you are typing and mostly the suggestion is correct.
  3. Introduce local aka extracts an expression and assign it to a variable.
  4. Templates aka CR writes code blocks for you.
  5. Moving within an identifier aka jumping between different casing instead of whole word.

And these are only most used features right out my head. There are tons of other excellent features worth exploring.

You might also check my DXCore plugins here and here.

Developer Express releases new major version (6.2) of their .net stuff

It contains new ASP.NET controls; ASPxMenu, ASPxNavBar, ASPxTabControl, ASPxSiteMapcontrol and of course, full support for AJAX. Then there is a RibbonControl, XtraCharts has new graphs (3D ones among them), VisualStudio type docking, XtraGrid got an advanced filter, new WinForms controls (MarqueeProgressBar, TrackBarControl, LabelControl, XtraScrollableControl), XtraForm supports skinning of entire outlook plus other improvements and fixes. If you are a subscriber, go to client area and download them. If you aren't, go to [DevEx] site and look for trial download - worth checking out.

DevExpress event-raising method naming

Sometimes you want to override certain method that fires an event.  By design guidelines one would expect a protected virtual On[EventName] method. But for some reason [DevEx] decided to go with their naming convention which looks like Raise[EventName] instead. Needless to say that this is a tiny time waster for developer as one has to search for correct naming instead on relying on standard one.

XPCollection peculiarity

These days I’ve came across this situation – related to [DevEx]' XPO:

This piece of code creates an instance of generic XPCollection that deals with Customer list. Next I set the condition to use for data retrieval and at the end I say that it is OK to load the data (note that XPCollection does lazy load). However it won’t work like that. Second line will throw an exception: can't reload collection with disabled loading. The solution is quite simple but perhaps it won’t work always for you - just switch second and third row to get code like this:

If you ignore the fact that it doesn’t allow you setting the condition before loading (unless you do it in constructor), which I struggle to understand why, you’ll see another issue. The guidelines for creating properties say something like (out of my memory):
It shouldn’t matter the order of setting properties
Properties shouldn’t perform any actions and should return the same value when called multiple times in a row

Clearly the way that XPCollection works is against first rule but not against second rule as one would assume from the exception text as it really doesn’t perform any action when setting Criteria – it just throws an exception if LoadingEnabled is disabled. I hope that this behavior will change in the future as it is against guidelines and it doesn’t allow you to construct Criteria before loading is enabled.

Why is Introduce Local (Replace All) allowed in certain circumstances

Yesterday I had a repeat of my whole day presentation "What's new in Visual Studio 2005/.net 2" and the audience was great. Note: you can find the slides here. I was asked few questions which I promised to answer later because I didn't know them on the spot (yes, yes, I know). So, here is the first question answered:

Why is R! (both free refactor that comes with VB.NET and R! Pro) allowing Introduce Local (Replace All) operation on Double.Parse(TextBox1.Text) in the following situation:

After the Introduce Local (Replace All) operation we get this result, which is obviously faulty because the value should be different for d and c variables.

So, the question was whether this is a bug or by design (by design I mean: do this operation on your own risk)?
The answer is quite logical and simple: it is a bug and R! guys are woking on to fix it.


Building class constructors with ease using CodeRush

Imagine a class with lot of fields.


 Now, you would want to build a constructor that initializes all or many of the fields by assigning arguments to coresponding fields so you don't need to initialize all fields one by one, plus you have the guarantee that all fields are initialized. Makes sense, right. Now, how would you write such a constructor? You might just use all of your 20 fingers and type it. Pretty annoying, isn't it. Afterall all the information is already there.

So, meet one of the CodeRush's feature I love: Smart Constructor. Just move the caret to the point where you want your constuctor created and type cc [SPACE] (assuming default CodeRush settings). A window like this will appear:

You can uncheck fields at will. After you are done just press [ENTER].

Isn't this feature just lovely? CodeRush just sucks the metadata from the declaration and creates a constructor with all arguments you've selected. It certainly saves a lot of annoying typing for me and prevents me to type wrong assignments. And this is just one of the million CodeRush's features.