views:

45

answers:

2

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).

A: 

You could try using 'View Call Hierarchy' (Ctrl-K + Ctrl-T (VS2010)) for certain things instead. It sorts alphabetically by the looks of things. Or tools like CodeRush Express or ReSharper (not free) usually have nicer search facilities than those offered by visual studio.

http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/

KJN
"View Call Hierarchy" is a viable option for functions and properties, but it does not work if you want to find references to a simple variable, or a class for that matter.
Nailuj
ReSharper's 'Find Usages' is probably the best option I have ever come across for a replacement to 'Find all references'.
KJN
+2  A: 

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.

zainnab
Doh, I never even noticed... Now when I look closer, I of course see that the search results are ordered by line number, but sorted using string comparison instead of integer comparison. Quite a ridiculous bug from Microsoft's side, if I might add ;)
Nailuj
Yeah it's some legacy stuff the product team has on their plate to fix they don't like it much either :)
zainnab