I’m trying to find a way to write a visual studio “thing”, or use a tool out there, that allows me to parse each line so I can add custom code around other code that I would be checking with my own algorithm.
Basically, I want to have a readtext of the current file from the visual studio code editor, and then replace it with the new verson with my modified code.
Looked at resharper, macros, can’t figure out a way to do this and I dont want to have to copy all code from a file, paste it into a windows application form that I would write,and then copy paste back. Any ideas?
Thanks
I would suggest using Roslyn for this task. It provides the facilities to read solutions, projects, and then realize the source files inside as their constituent syntax or semantic trees. Eric Lippert covered the CTP on his blog (emphasis mine):
You can also use Roslyn to create IDE Extensions, including creating your own refactoring tools:
In another question I demonstrated substituting type names (e.g.
intwithInt32) in a minimal amount of code, with this main loop: