locked
Why the user interface to Visual Studio's Find All References feature is unusable RRS feed

  • Question

  • Visual Studio 2008/2010, C++. Create a C++ solution with dozens of classes, each of which overrides a virtual function CBase::DoSomething(). Right-click on a call to one of the overridden virtual functions (CDerived157::DoSomething()) and select Find all references.

    Result:

    1. the matches in the Find Symbol Results window relate to all the overridden flavours of the function - not the particular one I searched for.

    2. I cannot do Edit | Find in the Find Symbol Results window to help me narrow my search down to the particular one I'm looking for.

    3. I cannot multi-select all the matches to copy and paste into a text editor where I could search within the matches for the one I want.

    4. The Find All References functionality is not available via macros, so it's necessary to write a full-blown addin to access it.

    5. There are no addin samples provided to show how an addin might be used to access it, just a few MSDN snippets in response to a trail of users trying to write such an add-in.

     

    Tuesday, May 25, 2010 2:06 PM

Answers

  • Hi Gerard - Did you read through the Improvements to Find all references in Visual Studio 2010 post that Nancy referred to in her first reply? What you are seeing is indeed the new default behavior in Visual Studio 2010, but by modifying the default behavior for Find All References as described in this article, I am able to get results only for the specific DoSomething method I selected from your example. Unless I'm not understanding something in your description.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Nancy Shao Friday, June 4, 2010 9:14 AM
    • Marked as answer by Nancy Shao Monday, June 14, 2010 5:32 AM
    Thursday, June 3, 2010 7:41 PM

All replies

  • Hi Gerard_odonnell,

    Thanks for your post.

    Find All References in Visual C++ project works fine in my side. And in Visual C++ 2010 Find All Reference have made some changes to provide more flexibility. For more information, please see:

    Improvements to Find all references in Visual Studio 2010

    If you say you can't find the functions you want to find, you can also try to use Edit> Find and Replace > Find Symbol or Edit> Find and Replace > Find in Files.

    If you want to write a Macro to do the things Find All Reference do, you can directly use Edit.FindAllReferences command, or write your code to do this, for detailed, please see: How to implement find all reference?

    If I misunderstood you, or you have any comments, please feel free to let me know.

     

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, May 26, 2010 7:33 AM
  • Hi Nancy, thanks for your quick response.

    For simplicity, create a Win32 console application using Visual Studio 2010.

    Paste this in to replace the contents of the main .cpp file:

    #include "stdafx.h"
    
    class CBase { public: CBase() {}; virtual void DoSomething() {}; };
    
    class CDerived1 : public CBase { public: CDerived1() {}; virtual void DoSomething() {}; };
    class CDerived2 : public CBase { public: CDerived2() {}; virtual void DoSomething() {}; };
    class CDerived3 : public CBase { public: CDerived3() {}; virtual void DoSomething() {}; };
    class CDerived4 : public CBase { public: CDerived4() {}; virtual void DoSomething() {}; }; // <---- right-click on DoSomething() here and select Find All References
    
    
    class CCompletelySeparate { public : CCompletelySeparate() {}; float DoSomething(float f) { return f; }; };
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	CDerived1 derived1;
    	derived1.DoSomething();
    	CDerived2 derived2;
    	derived2.DoSomething();
    	CDerived3 derived3;
    	derived3.DoSomething();
    	CDerived4 derived4;
    	derived4.DoSomething(); // <---- right-click on DoSomething() here and select Find All References
    
    
    	CCompletelySeparate completelySeparate;
    	completelySeparate.DoSomething(1.0); // <---- right-click on DoSomething() here and select Find All References
    
    	return 0;
    }
    Find Symbol Results pane:
    CDerived4::DoSomething
    	findallreferences.cpp(3): class CBase { public: CBase() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(5): class CDerived1 : public CBase { public: CDerived1() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(6): class CDerived2 : public CBase { public: CDerived2() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(7): class CDerived3 : public CBase { public: CDerived3() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(8): class CDerived4 : public CBase { public: CDerived4() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(8): class CDerived4 : public CBase { public: CDerived4() {}; virtual void DoSomething() {}; };
    	findallreferences.cpp(11): class CCompletelySeparate { public : CCompletelySeparate() {}; float DoSomething(float f) { return f; }; };
    	findallreferences.cpp(16): derived1.DoSomething();
    	findallreferences.cpp(18): derived2.DoSomething();
    	findallreferences.cpp(20): derived3.DoSomething();
    	findallreferences.cpp(22): derived4.DoSomething();
    	findallreferences.cpp(22): derived4.DoSomething();
    	findallreferences.cpp(26): completelySeparate.DoSomething(1.0);
    	findallreferences.cpp(26): completelySeparate.DoSomething(1.0);
    Imagine a class hierarchy more complex than this, with references spread over dozens or hundreds of files. 
    All I want to find out is where CCompletelySeparate::DoSomething() is used. Instead I get every line where any function called DoSomething() is called. 
    And I have to visually scan through the matches to identify the ones that relate to the class I'm interested in, as the Find Symbol Results pane does not allow searching.

    I can call Edit.FindAllReferences from a macro, but the macro cannot use the results.
    And the results can be copied to the Clipboard but only one by one (no multi-select allowed in this pane).

    Wednesday, May 26, 2010 8:58 PM
  • Hi Gerard_odonnell,

    Sorry for the delay.

    Yes, when you click "Find All Reference" in code editor, Find Symbol Results window will list all functions which have some name, no matter they belong to different class. It's by design. Usually, we pick up the function we need by scaning the lists in Find Symbol Results windows.

    If you want to use macro to get the function you want in Find Symbol Results window, in my opinion, you can get the text of Find Symbol Results Windows after executing Edit.FindAllReferences command, and get the function you want in this text. About getting the text of Find Symbol Results Window, please see:

    Getting “Find in Files” Search Results programmatically

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, June 2, 2010 9:08 AM
  • Thanks Nancy, but that means Find All References is effectively useless in Visual Studio 2010, as it's no different from Find In Files with whole-word matching.

    Here's the output from the Find Symbol Results window in Visual Studio 2008 - which works perfectly:

    CCompletelySeparate::DoSomething
    findallreferences.cpp(11): class CCompletelySeparate { public : CCompletelySeparate() {}; float DoSomething(float f) { return f; }; };
    findallreferences.cpp(26): completelySeparate.DoSomething(1.0);

     

    As far as I can determine, the contents of the Find Symbol Results window are not accessible from macros: http://social.msdn.microsoft.com/forums/en-us/vsx/thread/33C752C0-FB9B-42DE-8BB6-B2A45C6B68B0.

     

    Wednesday, June 2, 2010 2:50 PM
  • Hi Gerard - Did you read through the Improvements to Find all references in Visual Studio 2010 post that Nancy referred to in her first reply? What you are seeing is indeed the new default behavior in Visual Studio 2010, but by modifying the default behavior for Find All References as described in this article, I am able to get results only for the specific DoSomething method I selected from your example. Unless I'm not understanding something in your description.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Nancy Shao Friday, June 4, 2010 9:14 AM
    • Marked as answer by Nancy Shao Monday, June 14, 2010 5:32 AM
    Thursday, June 3, 2010 7:41 PM
  • Hi Gerard,

    I am writing to follow up this issue. Please let me know what I can help. Thanks.

     

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, June 10, 2010 8:41 AM
  • Thanks, Nancy, and apologies - right-clicking on a particular result and selecting "Resolve Results" does indeed filter the matches down to those requested - guess I should read the manual :).

    That still leaves a few other points though...

    1. the inability to search within the Find Symbol Results pane - user has to visually scan down to the relevant result, in order to use "Resolve Results". With 10 matches this is fine, with hundreds it's next to impossible.

    2. the text of the Find Symbol Results pane can only be copied one line at a time.

    3. No way via a macro to use the contents of the Find Symbol pane - user needs to create an add-in to do this.

    Thursday, June 10, 2010 12:19 PM
  • Hi Gerard,

    I'm afraid to say it's by design. If you have concern on it, please submit your feedback on our Connect Site with following link:

    https://connect.microsoft.com/?wa=wsignin1.0

    Every feedback submitted will be evaluated carefully by our engineers. Thanks for your understanding.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, June 11, 2010 6:22 AM