Searching code references

When we are writing about finding something in your project, it is not only about opening the files that you are working on, but also about finding relations within your code.

Go to Declaration

When you are analyzing your code, it is a very common scenario that you need to go to a particular place where a type is declared.

With ReSharper, you can do this by pressing F12 (Go to Declaration) on your type, method, or property use/call. Another way to achieve this is by pressing Ctrl, moving your mouse cursor above a symbol, and clicking on the left mouse button.

Code usage

As you need to go to declaration, you probably also want to check where your symbol (class, method, and so on) is used. To do this, just move cursor to your symbol and press Shift + F12 (Find usages). If there is only a single instance of the symbol being used, then ReSharper will just move you there. If there are more instances, then ReSharper will display a new Find Results window with all occurrences, as shown in the following screenshot:

Code usage

The Find Results window also allows you to display a preview of the code in which your symbol is used.

ReSharper can also highlight symbol usage in the current file. This will increase the readability of your code. The sample code with the highlighted userId variable is shown in the following screenshot:

Code usage

The Navigate to feature

The Go to Declaration and Find usages are two of the most used options when analyzing code references, but they are not the only ones.

You can find more options in the Navigate to feature (Alt + `). The more important ones that you will find there are listed as follows:

  • Go to Implementation: This option is useful when your class inherits from another class or implements an interface
  • Extension methods: This option displays all the available extension methods available for your type
  • Type of Symbol: This option allows you to go to a type that your symbol has (that is, the type that is returned by your method)
  • Derived Symbols: This option displays all the derived symbols

ReSharper can also visually indicate when a method overrides or implements another one, as shown in the following screenshot:

The Navigate to feature
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.95.245