VS Intellisense: can you hide extension methods?
Asked Answered
P

4

16

By default Visual Studio displays all members and its extension methods for a type in intellisense.

Sometimes I would like to hide the extension methods to make it easier to find the member I am actually looking for (especially when using Linq).

Is there a shortcut or another way to display only the members of a type in intellisense?

Pedagogics answered 18/3, 2009 at 9:43 Comment(1)
great question. It's particularly useful also when coding something which ultimately also has to run on mono. I without noticing often use an extension method, which later turns out not to work on monoOreilly
W
7

Not that I'm aware of - but one thing you might want to do is get rid of the using directive for System.Linq. At that point the extension method won't be accessible, and I believe it won't be offered by Intellisense.

Obviously that's no good if you want to use LINQ from one bit of code in a class, but not in another - but for classes which aren't using LINQ at all, it might help you.

Wyant answered 18/3, 2009 at 9:47 Comment(2)
I can confirm that they won't be offered by Intellisense, (a rather frequent gotcha for me, after having done a "Remove Unused Usings").Pisistratus
@Benjol: Same here. You can set options to re-insert particular using statements if you're using add-ons such as CodeMaid or ReSharper.Bug
P
2

In theory you could do this with the appropriate decorator attribute*, but googling this it seems it's bugged, with the fix awaiting a service pack presumably.

* [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]

Pernick answered 18/3, 2009 at 9:51 Comment(0)
S
1

Visual Studio 2022 has this.

When Intellisense is displaying, you can toggle 'Show only Properties' and 'Show only Methods' (hold Ctrl to get click both).

If you want to only see the extension methods, you can toggle 'Show only Extension methods'.

Spaceman answered 9/3, 2022 at 16:34 Comment(0)
C
0

Perhaps you could try using something like resharper which filters the list of methods as you type. I find this helps me to quickly get to what I need. And it will do so without hiding useful extention methods

Casaubon answered 18/3, 2009 at 9:58 Comment(1)
This doesn't help if all you want to do is browse the available methods.Artificer

© 2022 - 2024 — McMap. All rights reserved.