Why doesn’t VS 2008 display extension methods in Intellisense for String class

Why doesn’t VS 2008 display extension methods in Intellisense for String class

Since String implements IEnumerable, I was expecting to see the Enumerable extension methods in Intellisense, for example, when typing the period in
String s = "asdf";

I was expecting to see .Select(...), .ToList(), etc.
I was then suprised to see that the extension methods do in fact work on the string class, they just don't show up in Intellisense.  Does anyone know why this is?
This may be related to this question.


Answer 1:

It’s by explicit design. The problem is that while String most definitely implements IEnumerable<T>, most people don’t think of it, or more importantly use it, in that way.

String has a fairly small number of methods. Initially we did not filter extension methods off of String and the result was a lot of negative feedback. It almost tripled the number of methods at times with the right imports. With all of the extension methods displayed, people often couldn’t see the String method they were looking for in the noise.

String is a … simple type and it’s better to view it that way πŸ™‚

It’s still completely possible to call an extension method on string. It’s just likely not going to show up in intellisense.

EDIT: String actually has quite a few methods. But because many of them are overloads they collapse in intellisense.

Answer 2:

For info, this has changed in VS2010 (in beta 2, at least). It looks like this filtering has been removed (presumably it caused too much confusion), and the methods are now visible, along with the extension-method glyph.

Answer 3:

It should.

For example you can write it public static string myExtensionMethod(this String yuppi){

Then it is supposed to be there.