Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET - Find all references of property assignment

I am using VB.NET. In Visual Studio, if I right-click a property name and click "Find All References", it searches for all instances of the property being used.

However, a property is always used either for assignment (Set method) or retrieval (Get method). Is there any way of searching for only one of these uses? e.g. search for all uses of the property in code where it is being assigned a value, not when the value is being retrieved.

like image 625
Laurent Avatar asked Oct 07 '08 06:10

Laurent


People also ask

How do I see all references in Visual Studio?

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 to show references in Visual Studio code?

Step 1: From Settings – Type CodeLens and Enable the Editor: Code Lens and JavaScript > References Code Lens to check the references in JavaScript File.

How do I enable references in Visual Studio?

Restart Visual Studio, create a new C# UWP app project, and then right-click on the project and choose Add Reference. Go to the Windows tab, then the Extensions sub-tab, and select the Extension SDK. Look at the right pane in the Reference Manager. If it has dependencies, they will be listed there.


4 Answers

Use the compiler to turn what you want to find into errors. Remove the setter to find all the places were it was going to be used.

like image 156
Hafthor Avatar answered Oct 06 '22 19:10

Hafthor


With Resharper, if you simply use the "Find Results" tool, and then there is a filter icon in the results window. You can then limit the results to only "Show Write Usages".

like image 35
James Frengel Avatar answered Oct 06 '22 19:10

James Frengel


You can also use Reflector to browse through your assembly.

like image 41
Franci Penov Avatar answered Oct 06 '22 19:10

Franci Penov


Resharper (MSVS addin) has the exact feature you are looking for. Check:

ReSharper.FindUsages

or

ReSharper.FindUsagesAdvanced

in keyboard shortcuts mapping (Tools -> Options -> Keyboard) to find out what shortcut is used.

like image 42
Dandikas Avatar answered Oct 06 '22 20:10

Dandikas