简体   繁体   中英

Can I find variable's references and its mapping's references in C#/VS2019?

Often times, when I need to make changes to a variable, I need to know how my changes will impact the code downstream. I would normally do so by right-clicking on the variable, clicking on " Find All References ", and analyze the downstream code. Often times the value of that reference gets copied (ie: mapped) to another variable, and then I would have to repeat the same process of right-clicking on that mapped variable, clicking on "Find All References", and analyze more downstream code. This same process can be repeated several times.

Is there a framework/extension that allows me to find all references and its mapping's references in one user action (ie: a button that says " Find All References and Mappings ")?

Let's say I have the following classes/interface

public class Order {
   public int Id {set; get;}
   ...
}

public class ICreateOrder {
   int OrderId {set; get;}
   ...
}

public class CreateOrder : ICreateOrder {
   public int OrderId {set; get;}
   ...
}

It would be awesome if I can right-click on Order.Id , click on "Find All References and Mappings" and VS2019 would effectively give me all references of Order.Id , ICreateOrder.OrderIdId and CreateOrder.OrderId in one go.

Use the find feature in visual studio. It's pretty powerful.

Just do Ctrl+Shift+F and type \\..*Id into Find what: field and pick the scope of the search to be Entire Solution in Look in: field...

You need to check Match case and use regex expressions in Find options section.

You might also get some extras but for sure you won't miss any of your references.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM