Blog

Funny .Net behaviours

Sometimes I find some curious behaviours on .Net libraries. They are, obviously, found on Mono too, because Mono tries to be 100% compatible.

I believe Mono could have some success if it introduced a new branch. We have 1.1, 2.0 and a new “Pure Mono”, or something like that. The objective is simple, to create a stack where those that don’t bother about compatibility can have a implementation without that «curious behaviours». Plus, it would enable somethings like Ruby where we can ‘change’ the System Libraries behaviours on-the-fly.

I’ll start to publish those funny behaviours when I find them, for now enjoy this one:


DirectoryInfo info = new DirectoryInfo (path);
AssertEquals ("test#01", false, info.Exists);
Directory.CreateDirectory (path);
AssertEquals ("test#02", false, info.Exists);
info = new DirectoryInfo (path);
AssertEquals ("test#03", true, info.Exists);

This code is taken from the DirectoryInfo nunit test cases. As you can easily see, if you create a directory using an instance of DirectoryInfo, the Exists will not be updated. While this is a funny behaviour, there are no references about it either on MSDN or Monodoc.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Leave a Reply

For spam filtering purposes, please copy the number 2073 to the field below: