Saturday, August 12. 2006
Typed DataSet 2.0 without nillable types, Why!?
C# has nullable types. This gives us the ability to assign null to value types:
System.Nullable<int> x = null; //nullable integer x
int? y = 3; //C# shorthand notation for nullable integer y
Console.WriteLine(x.HasValue); //false
Console.WriteLine(y.HasValue); //true
Console.WriteLine(x == null); //true
Console.WriteLine(x == y); //false;
Console.WriteLine(x ?? 0); //short for x.HasValue ? x : 0; which is short for if...then..else
Microsoft writes the following in the C# Programming Guide about nullable types: "The ability to assign null to numeric and Boolean types is particularly useful when dealing with databases and other data types containing elements that may not be assigned a value. For example, a Boolean field in a database can store the values true or false, or it may be undefined."
Then why is it that the Typed DataSet generator in Visual Studio 2005 doesn't use nullable types in it's typed DataRow classes for columns that could be null? Instead we're still stuck with the IsNull() and SetNull() methods. This really is a missed opportunity imho. Perhaps they've had good reasons not to implement nullable types for typed dataset rows but I can't think of any. Leave me a comment if you know why.
Thursday, August 10. 2006
Where did the LINQ project templates go!?
After watching a video of Anders Hejlsberg explaining how LINQ works I decided it was time to check out the may 2006 LINQ preview myself. I downloaded and installed the bits on my laptop and started Visual Studio. I started a new project and looked for the LINQ project types that should have been installed by the preview but they weren't there! How could this have happened?
I searched the known issues to find a solution to my problem. And there it was or wasn't it? The symptom description looked fair enough: "LINQ project types do not show up in the New Project dialog" This must be my problem or wouldn't it? It seems that when de default location for the templates has been changed, the installer will still install the templates at the default location. Well yeah, but I didn't change the location of my project templates!
After fiddling around with the template files, copying them around to and from all kinds of template directories I took another glance at the list of known issues.
Almost at the top of the issue page there was an other issue marked with the word "new". It's description read "After the CTP is installed no new LINQ-specific project or item templates are added." Aha! Why didn't I see this before? Did they just add this? Well I must have overlooked it the first time but now I know the real cause of the problem at hand. The installer simply assumes that the Visual Basic language service is present in your Visual Studio install location. Well, at my install location the wasn't any Visual Basic language. I wanted to safe some hard disk space back then when I was installing Visual Studio... Unfortunately the workaround for this little inconvenience is to install the Visual Basic language and then reinstall the LINQ preview.
Thursday, August 3. 2006
TestDriven.Net has perfect support!
At work the other day I had some trouble using the TestDriven.Net 1.0 plugin for Visual Studio 2003. When I ran my tests using TestDriven, no test results where shown in the test output window. Instead I got stuck with a dozen or so test output windows, all of them empty... I tried re-installing the tool and repairing my Visual Studio installation but non of the things I tried really helped.
I was still able to debug my code using te "run with debugger" option but to see some test results I had to use NUnit, which is a separate tool outside the IDE. This was not too big of a deal but it was decreasing productivity and I wanted it fixed.
While I didn't expect too much of it I decided to send an email to the TestDriven.Net support. It didn't take long before I had an anwser from Jamie Cansdale, the creator of TestDriven, with some suggestions of what to try. Unfortunately his suggestions didn't help either but Jamie wouldn't give up. He really cared about the problem at hand and that alone was enough for me. We exchanged quite some emails that day but still without any result. Nonetheless I want everybody to know TestDriven.Net really knows how to give support. After all it's the experience that counts! A positive experience it was!
Unfortunately I was unable to test the newer version of TestDriven because we don't have any licenses for it. It would most likely have solved the problem... With Visual Studio 2005, unit testing is build into the IDE. Running tests and viewing test output is done in a nice way but I miss being able to right click a test method and just run it from there with the debugger. With TestDriven.Net 2.0 comes support for Visual Studio Test projects. When I'm able to fully swith to VS 2005 someday, I will still love to have TestDriven.Net just for running my test directly from the code window.
