Is there a way to write my own refactorings or code transformations for Visual Studio?
Example: I have a codebase with a billion instances:
DbConnection conn = null;
conn = new DbConnection();
conn.Open();
...a number of statements using conn...
conn.Close();
conn = null;
I would like to convert this to:
using (DbConnection conn = GetConnection()){
...statements...
}
The above template appears everywhere.
Edit: the above example. The thing is, I need to make a series of code transformations that are too complex to perform with text search-replace. I wonder if I can connect to the same mechanism underlying the built-in refactoring to write my own code transformations.
source
share