Hide extension methods for some common types in IntelliSense

I have an extension method:

public static void Foo<T>(this MyClass<T> target) where T : IEnumerable { // Code goes here } 

I want to hide this extension method from InteliSense if T is a string, but not for other types, just as the extension methods for IEnumerable in Linq are hidden when you work with a string. I looked at the EditorBrowsableAttribute , but doesn't seem to hide the method based on the generic type.

+4
source share
1 answer

Try putting the EditorBrowsableAttribute to this method (and possibly to the class that also contains this method) and move the method to another assembly (another project). After that, compile the assembly and unload the project, so that you only have a link to the DLL. This is the only way to use the power of EditorBrowsableAttribute .

0
source

All Articles