the blog
Back to -Blog

IronRuby and IntelliSense

Adding some .NET features
by Dermot Hogan
Monday 19 November 2007.

I’ve been fixing various bugs while waiting for Visual Studio 2008 to appear. A worthy occupation, but I must admit it’s not been very interesting. So as a diversion, I decided to see what’s involved in getting IntelliSense for IronRuby running.

After going down a couple of wrong tracks (I nearly started trying to figure out how to get IntelliSense out of a COM type library before realising that all I needed to do was use a .NET assembly: I think I’ve been COM brainwashed by Visual Studio) it all turned out to be really pretty much of a breeze. All I had to do was load the assembly and iterate through the type definitions to build an IntelliSense database.

So the first thing was to add in the Reference nodes you see in C# or VB:

Just adding a new Reference in the usual Visual Studio way now causes the IntelliSense database to be expanded with the new type definitions. Here’s what I get for a Form:

Right now, it’s basic, but workable. Getting the documentation proved a bit harder, but no great sweat. The documentation for System.dll say is in a corresponding file System.xml. A quick Xpath query then gives the relevant documentation string. It’s a lot more civilised than RDoc, I can tell you.

The only real problem is that it’s a bit slow to load. It takes 1.2 seconds to load System.Windows.Forms – which is OK (given that it’s only done once when a Reference node is added) – but it’s not great. A little digging revealed the source of the problem. In the Forms assembly alone, there’s about 2,500 types (equivalent to Ruby classes) and (wait for it) about 30,000 methods. Yikes!

My current technique is just to incorporate the assembly data into the standard Ruby IntelliSense database. This database has to handle instance variables, class variables, block scopes, etc. – all of which has no relevance whatsoever to .NET. The existing structure (optimised for Ruby) is a huge overkill for the compiled .NET IntelliSense database in an assembly. Still 1.2 seconds for 30,000 methods isn’t too bad - but it can be made a lot faster.

The way forward is clearly to have a ‘bypass’ in the IntelliSense system for a .NET assembly, allowing a very fast lookup and extraction. There’s no need at all to try to pretend that it’s really Ruby. I’ll do that in the next IntelliSense upgrade (which I’m scheduled to work on when VS 2008 is done and dusted). However, the basic mechanism is there and does work. When IronRuby is a bit more advanced - it’s still too early for us to incorporate into a full beta - you’ll be able to use full .NET IntelliSense for .NET objects.

Bookmark and Share   Keywords:  .NET  development
© SapphireSteel Software 2014