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?
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.
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)]
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
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'.
Related
Is there a way to quickly "Auto qualify" a variable type declaration in Visual Studio 2013?
E.g. if I type:
Dim SomeExcel as New Application
is there a way to get the IDE to automatically fill in the namespace? like this:
Dim SomeExcel as New Microsoft.Office.Interop.Excel.Application
The IDE seems to be able to infer the namespace readily enough; if I hover over the type name it can tell me what namespace(s) contain the type.
It would be really useful to me to be able to change an old project from "short names" like Application to fully qualified names like Microsoft.Office.Interop.Excel.Application without having to find each one and type out the whole namespace.
Or, in the event of an ambiguous name, if it would give me the option to pick which namespace and it would fill it in. Similar to how if you use an undefined class it will warn you and give you the options to either automatically add the Imports statement or even create a class stub for you.
Since it will do all that for you automatically, and it will make suggestions and autocomplete methods/properties for an interface instance as you type, I would be surprised if there was not a quick way to have it convert "short names" to fully qualified names, but if there is - I can't seem to find it! I looked through the menu commands, and various right-click menus, and I looked on MSDN but couldn't find anything - but i'm not sure I'm using the right search terms.
Hoping someone with more experience might know how to do this or if this functionality doesn't exist.
No, nothing exists in Visual Studio to do that.
Doing so also confers no special advantages, as VS will tell you if you have an ambiguous reference automatically and give you the possibilities to resolve it.
When that happens, just click the icon that appears when you hover over it and select the correct namespace. VS will then qualify it with that namespace.
Here's an image of the icon:
And the resulting menu:
Granted, that is for C#, but VB usually works the same way.
I was wondering if there is a plugin that allows me to jump directly to the test for the current class (Or create it if it doesn't exist).
I guess this should be based on the convention that the test project is named like the project being tested + "test" and the test class is named like the class being tester + "test".
A feature like that would really help in projects with many files and foldes, where scrolling the solution explorer to find the associated test project can be quite annoying.
how about NCrunch? This tool will show you, per method, which and how many tests are covering it:
I did manage to find a few extensions on visualstudiogallery.com, but ended up writing my own plugin for this. Its not perfect, but i does what I needed.
If anyone else would like, its available for free at testlocator.eqa.dk
In Visual Studio you can Shift+F12 on any class or method definition to find all references. Although the resulting list Studio is not very convenient, but a starting point. Using a tool like DevExpress CodeRush or ReSharper lets you sort and filter by namespace, project, file, etc.
If you happen to use ReSharper, it has a TestLinker plugin.
It does the job pretty well.
Basic shortcut: Ctrl+Alt+F7.
Goto Related Files is extended with navigation points to production/test classes.
New shortcuts ReSharper_GotoAllLinkedTypes and ReSharper_GotoLinkedTypesWithDerivedName (assignable via keyboard options) that jumps between linked types. In case of multiple linked types, a dedicated popup menu is shown, which can also be displayed in Find Results window.
If I'm looking at a method definition in Visual Studio (with Resharper) is there an easy way to find out what class it belongs to? (As of now, I've resorted to a text search in the "up" direction for the string "class".)
The Resharper command Go to containing declaration (ctrl + [) should do the trick
Edit:
Or if you have the navigation bar at the top of the code window enabled, that should display the type name. But I have that turned off, since I use keyboard navigation and the bar itself slows down Visual Studio.
You have files with more than one class in? That makes ponies sad...
Anyway, to actually answer, can't you just look at the navigation bar?
The best (direct) way specific to your question is PHeiberg's answer.
But if you ask this question I guess you don't know the File Structure window that can be enabled by ReSharper->Windows->File Structure or by shortcut Ctrl+Alt+F.
With that window you see always where you are in your file.
Aside from using ReSharper's File Structure and/or Go to Containing Declaration - options mentioned previously - there's also a tiny feature in ReSharper called Quick Documentation that in my view is better suited for this kind of task since it shows you method info in-place, without forcing you to navigate anywhere from the method you're on. Ctrl+Q, Esc, and you're done. It works on all kinds of symbols (not limited to methods), both on declarations and on usages.
For VS, right click on the function and select 'Go To Declaration'. (Ctrl + F12)
When you type the override keyword in a C# file in VS and press Space, you get a second menu offering the method to override. Can I extend this behavior with my own custom code that would use another keyword to pop up my own list of actions?
Yes it is possible to augment the list with more keywords or to even create your own list entirely. The interface you are looking for in Visual Studio 2010 is ICompletionSource. This isn't a simple interface though and it's hard to give a full sample in a stackoverflow answer but there are plenty of samples online to take a look at.
I think the best place to start is the editor samples available on codeplex
http://editorsamples.codeplex.com/
What other keyword do you want to use? If it's C#, pressing ctrl+space will open the auto-complete/intellisense menu.
If this is for writing another language using Visual Studio, perhaps this video is of use.
Here's the extending Visual Studio start page, in case it's helpful.
Oftentimes I want to bring up a system class in a source view, so that I can browse the properties and methods exposed by the class. Below is the screenshot of what I mean:
Srting from metadata http://img443.imageshack.us/img443/940/stringfrommetadata.png
Usually I do this by selecting the class name and pressing F12 (or right click>Go To Definition). However, if I haven't got it anywhere ready, i have type it up and then do Go To Definition. Most of the time I have to delete what I typed later on.
Is there a way to bring up this view without having to type the class name? The VS2010 Navigate To dialog doesn't support this.
EDIT: When I posted the question I didn't use any Visual Studio plugins. Now that I realised that I have full CodeRush license (thanks to StackOverflow promotion for users with 10K rep) I will accept answers that use CodeRush or Refactor!.
EDIT: At this stage I haven't really got anywhere with trying to answer this question. I am going to leave it open and let the bounty auto-award itself to Rory as he explained what's happening the best. In the meantime(schedule allowing) I will investigate doing this with DXCore as I think it should be possible.
The view you're looking at appears to have been built by some sort of analysis of the IL of the framework. Without knowing the type you intend to look at, no deconstruction can be done. Therefore I feel that, you are unlikely to find exactly what you have said you are looking for.
Allow me to suggest a few alternatives though.
Disclaimer: I work for DevExpress as a CodeRush Community Evangelist.
The Object Browser (Ctrl+Alt+J) This screen will load without attempting to show you any particular type, it will therefore be down to you to find the type in question. However all types are available and full search functionality is provided. once the type you're looking or is found, all members are listed and available.
Update: If you use the (Ctrl+K, Ctrl+R) shortcut to launch the object browser, then it will launch focused on the Search box. This is invaluable.
There are a number of CodeRush features which can prove useful when trying to locate code.
TabToNextReference (Tab) Whilst the caret is positioned within a type, strike the tab key and the next reference to that type will be located. More Details
References ToolWindow (Shift+F12) When activated the References ToolWindow will show you any references to the current type or member. This toolwindow can also be used to navigate said references. The References Toolwindow can be used in both on demand and Live mode. this allows you to have the window update as you navigate your code (via mouse or keyboard) and locate all references of any symbol the caret lands upon.
QuickNav (Ctrl+Shift+Q): This feature is closest in style to VS2010's NavigateTo feature. QuickNav will locate symbols matching whatever you type into it's filter box. This facility also supports Camel Case search. More details
QuickNav is also much more configurable than it's VS counterpart
Finally
Please also keep in mind that CodeRush is build upon the DXCore, a framework which allows users to create their own plugins for use alongside each other and CodeRush.
This framework has been repeatedly been leveraged by the community to add additional functionality. So even if you don't see any thing quite to your needs, consider suggesting something to the community by way of the forums or even contact me directly RoryB at DevExpress dot Com
I'm sure there's something we can do to help you out :)
I was not aware of that new "Navigate To" feature, but I used to use Reflector for this sort of things. The pro version offers some integration with Visual Studio (Right clicking the method and selecting "Open In .NET Reflector"). It will open the reflector window and won't show the code in the VS itself. You can watch the demo that shows this feature and some others.
This is not the best answer that I'd expect but is a good option to know.
There is no way that I know of to do this in Visual Studio 2010. However, you can do this in ReSharper via the 'navigate to' menu. I suggest you try the 30 day trial from them, then if you really do need this then purchase it.
A number of add-ins allow you to browse objects (though usually in an object-browser treeview manner rather than in a "header" file form - I believe Resharper, CodeRush and Visual Assist X all have variations on this theme).
However, one add-in to consider (as it's free) is the VS Productivity Power Tools. It adds a Solution Navigator window that gives a view onto your solution just like Solution Explorer, but (among other enhancements):
can search & filter the files listed, e.g. show only those files that are named Test.
can "expand" any file entry to show the types and members within it.