When i rightclick something in visual studio and press Find all references i get a list of all locations where this object occur.
Is there any way to also show the scope of this location (Namespace.Class.Method) instead of just a line-number. Now i have to doubleclick all of the results to see where it actually is.
One more vote for ReSharper. Check here for some screenshots as to the type of results. You can change how the results are presented (My favourite is Project+Namespace+Member, so I can see which methods the references are coming from.)
You also have a few options to refine your searches. For example:
Search project / file or even include referenced libraries
Search for Read or Write usages
Search for "text" matches
They have a free trial available... try it out.
Sorry, for this you'll need a productivity tool, like Reshaper. (Other productivity tools, such as DevExpress, do exist, however I don't know if they also provide such a feature.)
Using the default feature in Visual Studio, you can't achieve that. The Find All References seems to use the same search engine as the Find In File.
As M.Chohan said, a plugin like Reshaper or DevExpress CodeRush might have the feature you are seeking.
Related
Edit: Vidual Studio Code and Visual Studio are 2 different things. Yes it's confusing but I know that VS has this feature, I'm asking about VS code.
Is there some extension/setting that makes Visual Studio Code's c# have Intellisense for all available namespaces, including those that were not yet imported, and then imports them when selected?
Example: Collections are not yet imported and I want to type IEnumerable and import it. Being the average programmer this is quite tedious and I might screw up the spelling or capitalization, and then have to press ctrl+.. I would like to just be able to type "ienu" and then IEnumerable would pop up and would be autocompleted and auto imported.
This feature exists for Typescript in VScode (thanks to an extension), and even for C# but in Visual Studio with the Resharper extension.
I have searched everywhere for this feature but it seems to me like it doesn't exist. It honestly feels insane to code without this.
If you use "C# extension" for VSCode (this https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
you can try follow next steps:
Right click on C# extension
"Extension settings"
In opened "Settings" tab, add import in search area
Enable Checkbox
(Screenshot of this step)
Enjoy autoimport without "special" extension (Screenshot)
I just went ahead and made the extension:
https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using#overview
Currently it supports only the base C# libraries but I can make it use additional nugget libraries as well if there is demand for that.
As of 24/11/2020 the official C# extension supports this feature, see other answer.
There are some sort of solution for your problem that might help if you write the complete key word and don't want to write the using system or any library you can just put cursor on your key word and press alt+enter it will automatically add the library .but if you are not using library and want to auto complete key word of that library it's possible with re-sharper. you can also use Ctrl+space if your visual studio is not giving you auto recommendation
I need to generate a custom type of wrapper class from any existing one. An existing C# application is doing this very well, but its usage is quite annoying as it involves opening the application with the right file path, moving the generated file to the target location, modify the namespace and adding it to the Visual Studio solution.
I know that there might be other solutions, but I decided that I want an extension to do this (also for educational purpose). Target IDE is Visual Studio 2017 and it does not need to be backwards compatible.
For the usability it would be best to somehow extend the quick action menu when a class name is focused. There should be a possibility to do it, but I failed to find any resources on it.
Okay, for everyone that struggled like me:
My problem was that I searched for "quick action" instead of "light bulb". So after browsing the msdn documentation on extensibility, I finally found what I was looking for:
https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-displaying-light-bulb-suggestions?view=vs-2022
I have a need to identify if I'm referencing a specific assembly in my project/solution. I've not found an easy way to do this (I want to do it at design time and not run time if possible).
Seems this should be easy, but I'm not finding a way in VS, directly. Ideally, if I could see what/where I'm referencing (assuming that I am) would be great, too, so I can remove such references from my code.
Simply searching for "Assembly." in my code turns up nothing, now, for example.
A concrete example is in order: I want to know if I use anything in System.Reflection.Assembly. And I'd like to find the code that does it (in my source) if I do.
Do you want something like Assembly.GetReferencedAssemblies Method ?
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getreferencedassemblies(v=vs.110).aspx
In Visual Studio (almost all versions) open the Solution Explorer window the second "folder" is the References section. If you expand that you'll be able to see the referenced assemblies.
Image from robowiki
I have just installed VS2010 in order to do some XNA development and I have noticed, coming from using Eclipse on a day to day basis, that one very useful feature appears to be missing. When I start typing a class name from another namespace, intellisense doesn't display it so I cannot autocomplete. I have to type in the full name, hover over the typed class name with my cursor, then click the menu that appears in order for the using directive to be added.
Is there a way to get a similar behaviour like in Eclipse where it shows all class names in the current project and automatically adds the import when you autocomplete?
you must use visual studio + resharper.
Resharper is the best addin for vs. It's a productivity booster! Although it's not free, It's worth it and there's also a free 30 days trial.
When you start working with resharper, you can't leave it.
Also, i recommend you to use stylecop too. It's an open soucee code rule validations and enforcement
I would like to see all references of a given method. I mean references in C# sources and views (.aspx, .ascx, .cshtml). Is there a way to do that? A VS2012 setting or a plugin?
If you changed a method and you use it in your Views and don't know which one, you can always change the MvcBuildViews attribute in .csproj.
<MvcBuildViews>true</MvcBuildViews>
Resharper is an excellent tool that allows you to find all usages (this includes Views) in your solution.
http://www.jetbrains.com/resharper/
There are also some alternatives to resharper:
CodeRush: http://www.devexpress.com/Home/Try.xml
JustCode: http://blogs.telerik.com/blogs/posts/09-11-18/code-just-code-justcode.aspx
VisualAssistX: http://www.wholetomato.com/
The only one free is VSCommands:
http://visualstudiogallery.msdn.microsoft.com/d491911d-97f3-4cf6-87b0-6a2882120acf/ , but i don't know for sure if it has that functionality.
There is also a customer feedback here: http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/3090767-make-find-all-references-search-in-mvc-views, in case you want to track it's status.