Delta Engine Blog

AI, Robotics, multiplatform game development and Strict programming language

Having fun with C# 3.0 (LinQ CTP May 2006) and CR_Commenter v1.6 Update

Quick link to CR_Commenter v1.6 which supports C# 3.0 and adding namespaces now.

C# 3.0/LinQ (Language integrated Query) is pretty cool. I saw it at the PDC last year and watched some videos on Channel9. However, to use it you had to install a special VS2005 version from the PDC. Later an updated version came out, but still it was no fun to use it since the Visual Studio implementation wasn't any useful.

The technology behind LinQ is pretty amazing. It allows you to use Sql databases or Xml files or just lists or arrays in your code and query them with a very simple syntax. It improved a little, querying is not only easier, but more powerful and a lot of fun to play around. There are also a couple of cool short videos on the LinQ page (scroll down), which explain every big feature of LinQ.

However, it is still a CTP (the current one is from May 2006) and it is not really recommended for production code yet. You can read about problems with LinQ here and here.

You might ask why I think LinQ is so important, it looks like only database developers, business guys and maybe website developers will benefit from it, but right now there are a couple of projects and classes in my game engine that really benefit from C# 3.0. It does not only make the code much easier to write and is more fun to play around with, it is also much easier to read and test, debug, etc.

I don't really care if the product is ready or not, for example I like Atlas too and use it. I already like C# 3.0/LinQ in the current version and think it is very useable. The Visual Studio 2005 IDE does have its problem with it, but some of the problems can be fixed by just enabling automatic formating again and direct intellisense without pressing alt+space (if you like that and can live with some wrong suggestions). LinQ does disable all of them after installing, I only found out about it 1 day later and was happy to reactivate it again.

Some problems can't be fixed that easily. For example the Ctrl+. helper to do refactoring and adding namespaces, etc. does not work properly anymore. This isn't that bad for me because I use CodeRush for most refactorings anyway. But when a feature is missing you really need all the time, it really hurts and one of these features is the simple Add Namespace refactoring by Visual Studio 2005, which doesn't work anymore with LinQ. There was a plugin available some time ago for CodeRush, but it doesn't work anymore with the new version. After searching the internet and finding no solution other than to uninstall LinQ again, I improved my CR_Commenter plugin a little and it supports now adding namespaces ;-)

CR_Commenter v1.6 Installer download (81kB)
CR_Commenter v1.6 Source Code (72kB)

As you can see on the image a non-existing namespace will be added automatically if you just press Ctrl+., I also added some nice Action Hints for adding namespaces, adding comments and for generating regions. There are also more hotkeys around (Ctrl+1 for commenting, Ctrl+. or Ctrl+2 for adding a namespace, Ctrl+3 for creating a region around the current method, Ctrl+5 or Ctrl+F9 for updating the whole file).

More information about my CodeRush plugin CR_Commenter and the new improvements can be found on the CR_Commenter post.

Some links about LinQ in case you have not heard of it yet:

Update 2006-08-09: Added a couple of features (same download link, still v1.6):
  • Adding namespace does work now for older CodeRush versions too
  • Removed region feature (Ctlr+3), which already works fine with CodeRush
  • Added auto-updating on header comments every time you update your code (not only the date, but also the line numbers, file size, etc. is now updated)
  • Action hints are now only displayed if some code was changed