# Tuesday, August 07, 2007
I got both my ReSharper and VisualSVN registration keys via email today!  It can't get much better than that.

Tuesday, August 07, 2007 10:01:46 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, August 06, 2007
This is almost blasphemous, but I'm disappointed with JetBrains right now.  If you don't know they make the excellent Re# plugin for Visual Studio.  I'm disappointed because my trial license of Re# 3.0 ran out and I had to go purchase the software.  I procrastinated a while but I wasn't worried about it because you can  buy it online and enter a license code to activate it.  That's what I thought until I didn't see my license email immediately show up.  After reading their website help I found this:

Delivery Information

JetBrains products are available via electronic delivery only. The product license details will be e-mailed to you within 2 business days of receipt of your order.

What?!  How can this happen in this day and age, especially from a company that makes kick-ass software? This means there must be a manual process in there somewhere, so now I'm stuck using regular Visual Studio all day.  I feel like I'm programming twice as slow today.

WTF
Monday, August 06, 2007 5:56:36 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, July 30, 2007

This post is using the CSAH Visual Studio plugin.  I like it for the following reasons:

  1. Includes an installer, so its brainless.
  2. It has options you can set to override your current Visual Studio settings like font.
  3. It appears to copy all my colors, including background colors.  WYSIWYG.
  4. Best of all it has a menu option in the context menu, Copy as HTML.

Lets try it, select some code in Visual Studio, right click Copy as HTML.  ALT-TAB to Live Writer, right click select Paste Special.  Select Keep Formatting, OK.  It keeps all the formatting info inline, so it should work in RSS aggregators.

/// <summary>

/// Gets or sets the data dictionary reference.

/// </summary>

/// <value>The data.</value>

protected IDictionary Data

{

    get

    {

        if (IsWeb)

        {

            return HttpContext.Current.Items;

        }

        else

        {

            LocalDataStoreSlot slot = Thread.GetNamedDataSlot(DataKey);

            return (IDictionary) Thread.GetData(slot);

        }

    }

}

Sunday, July 29, 2007 11:40:38 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

This is something so simple, but so cool.  In FireFox I just noticed that I can select a piece of text on web page and right click select View Selection Source.  Only the HTML source for the selected area will be shown, all the other noise is gone.  I just double checked and IE doesn't have anything like this.

Sunday, July 29, 2007 11:22:04 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, July 29, 2007

For now obvious reasons, inserting code using an external style sheet DOES NOT work inside an RSS aggregator.  Hopefully I don't have to devolve into using Font tags as Jeff Atwood does.  Lets try the Live Writer plugin with the Embed StyleSheet option checked this time.

/// <summary>
/// Recursively gets the innermost exception, i.e. the first exception
/// that was thrown.
/// </summary>
/// <param name="ex">The exception to unwind.</param>
/// <returns>The inner most InnerException.</returns>
public static Exception GetInnerMostException(Exception ex)
{
    Exception inner = ex;
    while (inner.InnerException != null)
        inner = inner.InnerException;

    return inner;
}
Sunday, July 29, 2007 6:47:39 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

By now most of us have figured out how to create sophisticated build scripts using NAnt, NAnt is the de-facto standard among .NET OSS projects and for good reason.  NAnt is the best build system on the .NET platform.  So with that out of the way, why would I be writing a series on MSBuild? 

Here's the biggest problem with NAnt as I see it, NAnt doesn't work in the de-facto .NET IDE, Visual Studio.  In Java, Ant build scripts work right there in your IDE.  As good as NAnt is, there's still the context switch cost of switching between Visual Studio and the command prompt.  Aw but I have hot keys you say.  OK, but some newbie dev on your team certainly doesn't, and in general most .NET developers are most comfortable within the realms of Visual Studio rather than the command line.  Like it or not, most .NET developers don't want to build through a command line before they can build through Visual Studio.

The other advantage MSBuild has is that csproj files work natively in the build engine.  If the C# project works in Visual Studio, then you know it will work on the command line with MSBuild.  There's no need to maintain two separate build scripts or any other silliness.  I have also found MSBuild to be really good at resolving dependant nested builds.  So without further ado, here's the rundown of posts I hope to hit in this series:

  1. The basics, project structure.
  2. Configuration file management.
  3. Building the database.
  4. Unit testing.
  5. Code documentation with Doxygen.
  6. Preparing your build artifacts for deployment.
  7. Integrating with CruiseControl.NET.
Sunday, July 29, 2007 5:56:21 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

So I tried out the Windows Live Writer code formatting plugin available on CodePlex, and at first sight it seemed to work well, that was until I read my feed through Google Reader.  For some reason within Google Reader there was a bunch of extra white space between lines of code, which as a result made it completely unreadable.  So here I am again trying out yet another Live Writer plugin, Insert Code for Windows Live Writer.  Hopefully this one works.

/// <summary>
/// Recursively gets the innermost exception, i.e. the first exception
/// that was thrown.
/// </summary>
/// <param name="ex">The exception to unwind.</param>
/// <returns>The inner most InnerException.</returns>
public static Exception GetInnerMostException(Exception ex)
{
    Exception inner = ex;
    while (inner.InnerException != null)
        inner = inner.InnerException;

    return inner;
}

I'm using the instructions from Phil Haack.

Sunday, July 29, 2007 4:27:32 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
# Friday, July 27, 2007

After upgrading DasBlog to the latest release and setting up FeedBurner I felt that I needed to do something to improve my posting experience.  Since inception I've been using the built-in rich text web form in DasBlog.  However good it may be it still lacks in a few areas:

  1. No real-time spell checking.  Since FireFox 2.0 came out this hasn't been an issue since it includes a very nice spell checker.
  2. Code formatting.  For the life of me, I cannot get code formatting to respect my tab spacing.  It parses the code just fine, but after it gets inserted into the post text area all the tabbing is gone.  This last point has really frustrated me and kept me from posting code as often.
  3. No offline mode.  Yeah I know, that's a bit much to ask of a web product, although Google seems to have found away around this with their Google Gears, which allows me to use the Google Reader in offline mode.

All of these issues have led down the path to Windows Live Writer, which is what I'm using right now to write this post.  The thing that amazed me about both DasBlog and Windows Live Writer, is that installing and configuring Windows Live Writer just worked.  There was no oeed to read any instruction manual or otherwise research how to set this up.  It just worked.

The other thing that impressed me was that it has a web preview mode which allows me to actually see this post as would appear on my blog - and I mean exactly as it would appear on my blog.  It basically has a complete cache of my blog home page, even when disconnected from the inter-web, which is really nice and unexpected.  In Google terms, that feature "delighted" me.

As for code, lets see if I can cut and paste from Visual Studio...

/// <summary>
/// Converts a local DateTime instance to the MiniTix date time format.
/// </summary>
/// <remarks>
/// ISO 8601 date format in Zulu time.
/// </remarks>
/// <param name="date">The date.</param>
/// <returns></returns>
public static string ToMiniTixDateTimeFormat(DateTime date)
{
    return date.ToUniversalTime().ToString("u");
}

Darn, that didn't quite work did it?  Fortunately I noticed Windows Live Writer has a plugin feature.  Google search...  Found a code formatter plugin right away on CodePlex!  Lets see how the new plugin works.  Exception, Directory not found!  OK that didn't work, although Live Writer did find and load the plugin automatically while it was running (I unzipped the plugin to the plugins folder while Live Writer was still running), lets try restarting Live Writer and try again - Insert clipboard as code:

/// <summary> /// Converts a local DateTime instance to the MiniTix date time format. /// </summary> /// <remarks> /// ISO 8601 date format in Zulu time. /// </remarks> /// <param name="date">The date.</param> /// <returns></returns> public static string ToMiniTixDateTimeFormat(DateTime date) { return date.ToUniversalTime().ToString("u"); }

 Much better!  Even the XML comments got picked up.  Finally, lets see if I can post!

Friday, July 27, 2007 6:14:49 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
It seems like most of the libraries I use in .NET output log statements via log4net, which is great.  The one thing that often occurs though is information overload, especially when I set my root logger to DEBUG.  Since I follow the logger per class convention, and I name all my loggers based off of type its super easy to allow DEBUG messages for my code, while turning other packages to INFO.

    <root>
      <level value="INFO" />
      <appender-ref ref="ConsoleAppender" />
    </root>
    <logger name="GalleryPlayer">
      <level value="DEBUG"/>
      <appender-ref ref="ConsoleAppender" />
    </logger>

The above lets NHibernate (or whatever else) log at the INFO level, while my code under the GalleryPlayer namespace logs at the DEBUG level.

Friday, July 27, 2007 5:29:09 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
It seems everyone these days is using FeedBurner or some other feed aggregation service, so I finally jumped on the band wagon and setup a feed for this blog @ http://feeds.feedburner.com/sneal.  There were several compelling reasons to do this:

  1. Feed speed optimization, my blog server isn't the hottest thing around - by a long shot.  In fact its on my todo list to find a new hoster.
  2. Exposure, hopefully I can draw in more readers.
  3. Feed analytics.  Right now I have really no idea if anyone ever reads this blog, or how often.
  4. Everyone's doing it.

Friday, July 27, 2007 4:42:33 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [3]  | 
I just finished upgrading my DasBlog software from an older 1.9 release to the latest 1.9 version.  I just copied everything from the new version's zip archive, except for the SiteConfig folder, directly over my blog site.  It seems to have worked just fine, which actually somewhat suprised me.

Wee!

Friday, July 27, 2007 3:17:31 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, July 26, 2007

Well, I fixed our CC.NET build that builds one of our C++ projects.  The MSBuild script was taking longer than the timeout specified in CC.NET (which was set to 5 minutes), so CC.NET was killing the build before it finished without reporting as to why the build was failing.

Thursday, July 26, 2007 10:26:06 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
This is a note to myself to take a look at Coco-R.

Coco is a compiler compiler (I guess that's where coco comes from). You have probably heard of tools like lex and YACC - Coco-R is a modern version of these tools. What's really great about it is that there are ports to several languages including C#. This is very convenient because additional processing you may want to do during parsing can be written in the same language tool itself is written in - C#.

Thursday, July 26, 2007 5:17:12 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, July 21, 2007
Sometimes I like to drop databases locally even when I'm connected to them.  This usually comes in handy when I'm rebuilding a DB using a script.

USE MASTER
GO

-- If the database already exists, drop it
IF EXISTS(SELECT * FROM sysdatabases WHERE name='Northwind')
ALTER DATABASE Northwind SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

IF EXISTS(SELECT * FROM sysdatabases WHERE name='Northwind')
    DROP DATABASE Northwind
GO


Friday, July 20, 2007 11:20:15 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, July 18, 2007
Unfortunately I found myself needing to use an out parameter in a legacy codebase, but couldn't figure out how to get it to work correctly with Rhino Mocks.  It turns out there's a special syntax for that.

From: http://en.wikibooks.org/wiki/How_to_Use_Rhino_Mocks/Out_and_Ref_Parameters

int theRef = 42;
int theOut = 0;
Expect.Call(obj.MyMethod(ref theRef, 0, out theOut)).Return(True).OutRef(13, 666)


Wednesday, July 18, 2007 5:17:16 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, July 06, 2007
So I spent a few hours on the 4th of July learning to use Windows PowerShell.  I was intrigued by the raw power available WMI, COM, and best of all .NET all from a scripting platform made for doing admin like tasks.  The best part is that the interfaces between local disk, UNC paths, and even registry keys are all the same.  So with my new tool in hand, I thought I would give my problem of recursive deletion of "_thumbs" directories another shot.

Get-ChildItem -path c:\temp -filter _thumbs -recurse | Remove-Item

How much simpler is that?!  That's what I wanted to do the first time with the regular windows command shell.  I'm sold, I'm using the Windows CommandShell from here on out - and you should too.

Friday, July 06, 2007 6:42:05 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |