$exception; exceptional

I have been using Visual Studio 2003 since the first beta. Until today however, I never knew about $exception. This post is a reminder to me that the Locals Window is my friend.

There is a local variable in the locals window when the debugger breaks due to an unhandled exception that holds the thrown exception. I cringe at the thought of time wasted trying to get the same information via other, shall we say less effecient, means.

Bang! Bang! your dead

I found an obscure bug today, a typo no less, but Im getting ahead of myself.
It turns out that C# allows you to use multiple not operators (!).

So:  true == !!true and false == !!false

Why you would ever want to use this is beyond my small level of comprehension, but it made finding my bug a little harder.

if(!X and !!Y) then do something

it turns out it was meant to be
if(!X and !Y) then do something

The double bang is easily glossed over as your eyes are looking for its presence not checking there is a correct count of bangs.


NUnit and Dynamic Object Creation

I have had a couple of tests failing for some time that I could not fix. I came back to them today and have still not got very far. The code that fails during testing, only fails during testing and I can only guess it has something todo with the way NUnit loads the assemblies.

My problems:

ConstructorInfo constructor = systemJobType.GetConstructor(typeArray); – returns null during testing
Activator.CreateInstance(systemJobType, getConstructorArguments(node)) – returns null during testing(IEventHandler)Activator.CreateInstance(handlerType);- doesn’t return null but the cast fails during testing

The commonality in these lines is that they all use interfaces. The first two lines are trying to do the same thing in different ways, create an object that takes an interface as an argument. The use of interfaces is obvious in the second line. The interfaces are different but they are all in different assemblies to where the code is running, although they are referenced.

So im still stumped….

Is it just me?

… or is XML a really stupid choice for Build Scripts?
Im sick of writing NANT scripts in XML.

I guess it’s just me as there is almost nothing around that doesn’t use XML, at least in the .NET world.