Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort order of result for "Find All References" in Visual Studio

Tags:

I'm currently using Visual Studio 2010, but I don't think this is a version specific issue (think it was the exact same way in 2008 as well).

When I want to find out where in my solution some variable/function/whatever is used, I right-click it and select "Find All References". This gives me a long list in the Find Symbol Results view over all existing references. This list however, is quite messy. The results seem to be ordered by which file they are in, but it stops there. They are neither sorted by line number nor anything else slightly logical (at least that I can see...).

If I do the same kind of operation in e.g. Eclipse, I get a nice list where the search results are nicely ordered by file, then function and line number in the file. Is there a way I can achieve the same in Visual Studio (some preference to specify perhaps)? Or is this just one of those silly things where Visual Studio is completely hopeless? Or is there simply some brilliant sort ordering logic that I'm missing?

It's not like this is a very big problem, but it makes it quite much easier when you look through the references of a variable if it is in some kind of logical order...

Update:
Just to clarify: I know there are other add-ons and tools like ReSharper etc. that does these kind of things much better than Visual Studio. I'm interested if it is possible to "sanitize" the search-output from Visual Studio's existing "Find All References". And if not - what on earth is the logic behind their current sorting order (there has to be some logic, because I seem to get the same order in the results whenever I search for the same variable).

like image 646
Julian Avatar asked Sep 27 '10 11:09

Julian


People also ask

How do you find all references in VS code?

You can use the Find All References command to find where particular code elements are referenced throughout your codebase. The Find All References command is available on the context (right-click) menu of the element you want to find references to. Or, if you are a keyboard user, press Shift + F12.

How do I sort alphabetically in Visual Studio?

Select the desired ones(supports for kind variable). Using Command Palette (CMD/CTRL + SHIFT + A) Or Cmd+Shift+P and select Alphabetical Sorter thats it.

How do I sort lines in Visual Studio?

You just select the lines you want to sort and Alt+3 or Alt+4 (asc/desc).

What is CodeLens in Visual Studio?

CodeLens lets you stay focused on your work while you find out what happened to your code–without leaving the editor. You can find references to a piece of code, changes to your code, linked bugs, work items, code reviews, and unit tests.


1 Answers

I pinged the VS team on this one and it turns out that the reason for the wierdness is that Find All References is based on strings instead of numbers. This is why you see 1,2, 25, 3, 35, 4, etc... They are tracking it as a bug and it is slated to be fixed but the timeline is unknown.

like image 122
zainnab Avatar answered Sep 28 '22 11:09

zainnab