Method to remove specific obsolete lines of code from an entire codebase?
I have some code:
#if SILOG
SiAu开发者_如何学Cto.Main.LogException(ex);
// some other lines
#endif
What would be the easiest way to remove surrounding #if from my entire codebase, i.e., end up with just:
SiAuto.Main.LogException(ex);
I'm using Visual Studio 2010. I'll accept the first answer that I can test to see if it works. Looking forward to your ideas!
Assuming your codebase is all in one solution file, and you don't have nested preprocessor directives, You can do a find and replace with a regexp:
\#if SILOG{(.*\n)@}\#endif
For the replacement string, use this:
\1
Make sure have are using the "Regular expressions" find option checked.
Step by step:
- Open the find and replace dialog (ctrl+H)
- Under "Find what:", enter "#if SILOG{(.*\n)@}#endif" without the quotes
- Under "Replace with:", enter "\1" without the quotes
- Under "Look in", select "Entire Solution"
- Expand "Find options"
- Check "Use:" and select "Regular expressions" from the combobox
- Click "Find Next" to see if it worked
- Click "Replace All" if you're brave
This won't fix the indentation of the code that was between the #if / #endif, however.
精彩评论