Recently while working on a project of mine and doing some refactoring I got an idea to write a custom tool to help me analyze my code in a very specific context and perform some very custom refactoring.
What I wish to do is to interface with Visual Studio somehow and use its powers to analyze my code and do some refactoring. There is a class view which displays the logical structure of a project with its classes, methods and variables so I assume the high-level information about the code is available. The question is, does it get exposed to the user? Is there some API for me to use?
Basically I want the following:
A way to run some simple code analysis code blocks with the complexity of unit tests, nothing really fancy. Like getting the list of the classes matching a certain name pattern, iterate through their methods, filter the ones with certain attributes, look inside if there are calls to certain methods if so assert those calls having specific parameters. Then throw the analysis result into the output window, so that when I double-click there a location in the respective code file is opened in the workspace.
A possibility to command Visual Studio to perform surgical refactoring like renaming a specified variable and then applying its built-in renaming refactoring project-wide. These basic refactoring operations are available for the user in manual mode, can they be invoked from code?
Nothing that would damage the code style. Like the built-in refactoring which leaves the code style intact.
Not a static plugin for Visual Studio but solution-dependent code, so that it travels with the solution. Without installation. Perhaps like a separate analysis project in a solution, which I can set as active, uncomment the desired analysis methods and let them run.
Something very basic, without a GUI. A configuration file and the analysis code files will do.
Possibly without using any third-party tool, don't wish to introduce an extra dependency
If it is at all possible, can you please give me some clues to the names, keywords, what to google for? I'm interested in any information you can provide to the subject - outline the scope of my options, known issues, difficulties, problems? Anything to make the big picture clear.
And a million dollar question: provided it's possible, can something like that be quickly hacked together in a few hours?