1

I want to write a visual studio extension to find all references of a certain symbol then perform a "customized Rename". For example, I have a struct like this

struct Foo
{
    int index;
}

Now I want to replace the int index with a custom struct like this:

struct IndexContainer
{
    int index;
}

struct Foo
{
    IndexContainer indexContainer;
}

Then I want to replace all Foo.index with Foo.indexContainer.index(imagine there are tons of place where Foo.index is used).

I want to write a helper tool to automate this work. From what I understand, if I am able to find all the references of this symbol, then I can just iterate all the references and change the text for that reference.

The reason why I cannot simply use Rename is because Rename might change another symbol that is not Foo.index and it also can not make static array work(imagine IndexContainer indexContainer[5]).

Would anyone tell me if there's a method to invoke "find all references" and grab its result?

Frank Xu
  • 11
  • 1
  • Not sure about the full capabilities but this can be your starting point https://github.com/Microsoft/VSSDK-Extensibility-Samples – Soumen Mukherjee Feb 14 '19 at 04:30
  • Thanks a lot! I will take a look at it! – Frank Xu Feb 14 '19 at 21:39
  • Looks as same as this question https://stackoverflow.com/questions/32974118/c-sharp-recursively-find-references-in-all-projects-in-solution – osynavets Dec 07 '19 at 13:44
  • Does this answer your question? [C# Recursively Find References in All Projects In Solution](https://stackoverflow.com/questions/32974118/c-sharp-recursively-find-references-in-all-projects-in-solution) – Alenros Jan 05 '21 at 12:05

0 Answers0