views:

42

answers:

1

Is it possible to generate a list of all the variables used in a visual studio project?

A: 

This can be done easily in add-in or macro. The code would be the same but creating macro is much easier. First, you need to iterate all source code files (ProjectItem objects) in a project. Then you will iterate all code elements in each project item. In ShowCodeElement method, you can test objCodeElement.Kind property. If it's vsCMElementVariable, it's what you need. You have all info you need. You cannot retrieve local variables inside methods this way. Variables inside methods need to be parsed from method source code.

Peter Macej