0

My goal is to create a Visual Studio extension, macro, or addin that would give the user a list of all their variables and parameters. The user would then be able to rename any given variable in that list.

How can I get a list of all variables and method parameters in a Visual Studio project within an addin, macro, or extension? Further, which is more appropriate for this, between an extension, macro, or addin?

p.campbell
  • 98,673
  • 67
  • 256
  • 322

1 Answers1

1

You can get most (if not all) information you're looking for through the CodeModel API. This gives a high-level overview. What you'll want to do is get the code model objects for files and projects and loop through to find CodeVariables and CodeParameters. Note this will only get you fields -- local variables aren't expressed through the API. If you also need locals, you might want to try the Roslyn CTPs, with the obvious caveats that it's not done yet.

As far as which technology to build on -- it doesn't have any effect on the actual code you're going to write, since you're going to be using the same APIs no matter how you start. It's mostly a difference of deployment. That said, macros are no longer supported in Visual Studio 2012, and addins can be a huge pain (and are a relatively legacy technology at this point). Do an extension, it'll be the easiest.

Jason Malinowski
  • 18,148
  • 1
  • 38
  • 55