Extra issue when reusing existing names for extension methods

Chapter 10: Extension methods: 10.2.4

Created: 1/14/2009
Last updated: 8/15/2010

In section 10.2.4, I give an example of a potentially useful extension method: effectively making string.IsNullOrEmpty usable as if it were an instance method.

Now, I already give a warning about potentially confusing people reading your code, if they're used to it being a static method - but Intellisense makes this even worse. Here's a screenshot from Visual Studio 2008 SP1. I've declared two extension methods: IsNullOrEmpty and IsNullOrWhitespace. I've then captured the screen after typing "foo." where foo is a variable of type string.

Intellisense bug around extension methods in VS2008

Note how Intellisense is providing different icons for the two extension methods - it's still displaying the normal "static method" icon for IsNullOrEmpty.

It's not hugely serious, but it's just another thing to be aware of. I should note that ReSharper has its own Intellisense display, and that does the right thing.