Thursday, January 3, 2008

A twisted, yet valid observation

Today, I again saw what is an all too frequent occurence in some dev shops - a failed build.

Rather, a grossly negligent failed build. One that could have easily been avoided. So to that developer, and others of similar ilk, I send this message:

I know you only changed one line in a single file. And I'm aware it takes ten minutes to build the solution on your machine. I even realize that no one was going to pull down code at that precise moment.

Nothing, however, pains the resident Build Guy more than that big red Build Failed icon. Every time I see that, a little piece of me dies.

And no, Fellow-Programmer-Who-Shall-Remain-Nameless, remembering to build immediately after checking in the file is not "close enough." Sure you'll have the fix checked in even as the build reports the failure. And sure, any other time of the day I would have been wandering the halls and never would have known. But apologies won't help. It's still too little, too late. It's like applying the brakes after running over the cat...

Tuesday, January 1, 2008

Customizing DataTips

A convenient debugging tool in Visual Studio is the ability to hover the mouse over an object and see the information currently stored there. This is referred to as a DataTip.


If the class is derived from a base class, or contains other objects within, you can drill down to see those values as well. Depending on the complexity of the object however, this can become tedious. This is especially true if there are a couple values that you always want to see when debugging.

To quickly see one or more properties on a class, you can do so using the DebuggerDisplay attribute in System.Diagnostics. If I add the following to MyBaseClass, I can view the value of X without expanding the DataTip. (The property to display is placed in braces.)


[DebuggerDisplay("The value of X is: {X}")]


If I derive a new class from MyBaseClass, I can set a DebuggerDisplay attribute that accesses values both from this class and the base.



[DebuggerDisplay("{X}, {Y}")]
class MyDerivedClass : MyBaseClass
{
private int _y;
public int Y
{
get { return _y; }
set { _y = value; }
}
}