NAnt: Does null really exist?

Stumbled upon an interesting situation in NAnt, which may inspire some philosophical thought on what “to exist” really means.

We run a NAnt build script from our program and set its properties manually. Due to a bug in our code, certain property foo is set to null:

var project = new NAnt.Core.Project(...);
project.Properties.Add("foo", null);

The end result is quite spectacular: property::exists('foo') returns true, but attempt to access ${foo} fails, claiming that the property has not been set.

On a deep philsophical level it kinda makes sense, but it defeated our required property checker, that foolishily assumed that if a property exists, its value can be retrieved.

P.S. This might as well have been fixed in the latest NAnt, we are using version 0.90. On second thought, when I am out of the current crunch, I may try it with the latest version, create a repro case, and report a bug.

Leave a Reply

Your email address will not be published. Required fields are marked *