Skip to content
October 11, 2006 / Bob Black

CodeToaster Intellisense

Can I say Intellisense without getting a “letter” from Microsoft? I’ll give it a shot and see what happens.

I found out why CodeToaster wouldn’t work after being obfuscated. It was a bug in my code, caused by DotFuscator inserting namespaceless (I just made that word up!) attributes and such-like into my assemblies. Attributes with no namespace. Not having a namespace, in other words.

CodeToaster populates its Intellisense cache differently for assemblies than for uncompiled C# code. It’s much more difficult to build the cache from uncompiled C# code because the code has to be parsed, and the Intellisense has to be aware of inherited classes and all that good stuff. But to cache a compiled assembly you just iterate through all of the types in the assembly (I’m oversimplifying, but that’s really the gist). And yes, CodeToaster is building its Intellisense cache from both compiled and uncompiled code.

Here’s a slimmed-down snippet of the code that was breaking after my assemblies had been obfuscated. This code loops through the types in an assembly and caches each namespace (if it hasn’t been cached already). Unfortunately, it assumes that each Type will be in a namespace, which may not always be true. For a Type that does not belong in a namespace, the Namespace property will return null. 

foreach (System.Type type in typeList){

Being the good coder that I am, I  “fixed” the problem by ignoring (and not caching) namespaceless types. I can probably get away with this because, frankly, I’ve never come across a .Net Type that didn’t have a namespace (VS.Net even includes a namespace automatically when creating a new code file), and this code’s effect on such a case would be minimal, since the code would still compile in CodeToaster – the Type just wouldn’t appear in Intellisense.

I’ll probably revisit this later, but for now I’m just trying to release CodeToaster to the masses. Oddly, packaging the nasty thing up into an installable package seems to be taking longer than it did to write the app.

But more on Intellisense. Currently CodeToaster keeps a parse tree in-memory for Intellisense. It’s blazing fast, but unfortunately can take up a good chunk of memory. For subsequent versions I’m thinking of using something like SQL Server 2005 Everywhere Edition to bring memory utilization way down while retaining the current lightning-fast response times, which would involve moving the cache into an Everywhere Edition database: basically a complete rewrite of the current Intellisense engine which would take a significant amount of time, so I’m going to wait and see how folks feel Intellisense performance and memory utilization before putting that on my tackling that.

That’s enough for now. Hopefully I can have this cool tool packaged up and ready to “ship” in a few days. 

– Later.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: