I am addicted on ReSharper

The last weeks I’ve play a lot with Visual Studio 2008. It is a fantastic product and the startup time is amazing fast, but without ReSharper ( the 2008 version with C#3.0 support isn’t released yet ) it is so circuitous to write code. So it isnt really funny to write code without ReSharper.

For all who dost know what ReSharper is. It is a Visual Studio Extension with extend C# and VB.Net with various features.

A few examples:

  • From lightning fast property and constructor creation
  • It shows you all your unused code
  • It shows you common coding mistakes
  • Creates delegation proxy’s with a few clicks
  • and a lot more

Change assembly search path within MSBuild

Today I’ve try to create a simple MSBuild task. It should load all NHibernate mappings, use the configuration to build the session factory and write all exceptions as errors to MSBuild build log ( and in Visual Studio output window ). Sounds pretty simple?….it isn’t 🙂

First i have to change the assembly search path to allow NHibernate to find the in mapping referenced assembly’s.

To do this, my first idea was to create a new appdomain, it isn’t possible to change the assembly search path of a running appdomain ( this where my msbuild task is running in ).  This works when you only running your MsBuild tasks from command line…but not in Visual Studio. All custom tasks there running in partial trust environment and you can no create appdomain’s within it.

After a long while of testing, i gave it up and move to “ToolTask”. ToolTask allow you to run another process as tool. This process is not running in partial trust, so you can create appdomain’s there.

This works, but you have to do all the interprocess communication stuff. Ive create input and output temp file where i serialize my parameters only as simple framework types ( when you use your custom types, you have to deal with the changed assembly search path ) and pass the filenames as argument to the tool process.

String interpolation feature wish for C# 4.0

Mitch posted about his wish to integrate a shortcut for formatting in c# vnext.

Let’s say that my code is going to throw and exception, I typically need to build the error message to load into the exception message. That could be expressed as:

throw new Exception(string.Format(”{0}{1}{2}”, a, b, c));

But I think we could have a nicer inline string format syntax:

throw new Exception(  @(”{0}{1}{2}”|a|b|c)  );

I think this should be resolved more like it is in other dynamic languages like boo. Lets take a sample:

throw new Exception( $" {a}{b}{c} " );

The $ (or something other) before means, allow in line variable interpolation in this string literals.