从整个代码库中删除特定过时代码行的方法?

发布于 2024-10-05 06:13:09 字数 278 浏览 0 评论 0原文

我有一些代码:

#if SILOG
    SiAuto.Main.LogException(ex);
    // some other lines
#endif

从整个代码库中删除周围的 #if 的最简单方法是什么,即最终结果是:

SiAuto.Main.LogException(ex);

我正在使用 Visual Studio 2010。我将接受我可以测试的第一个答案,看看是否有用。期待您的想法!

I have some code:

#if SILOG
    SiAuto.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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2024-10-12 06:13:09

假设您的代码库全部位于一个解决方案文件中,并且您没有嵌套的预处理器指令,您可以使用正则表达式进行查找和替换:

\#if SILOG{(.*\n)@}\#endif

对于替换字符串,请使用以下内容:

\1

确保使用“正则表达式”查找选项已选中。

分步操作:

  1. 打开查找和替换对话框 (ctrl+H)
  2. 在“查找内容:”下,输入“#if SILOG{(.*\n)@}#endif”(不带引号)
  3. 在“替换为:”下,输入不带引号的“\1”
  4. 在“查找范围”下,选择“整个解决方案”
  5. 展开“查找选项”
  6. 检查“使用:”,然后从组合框中选择“正则表达式”
  7. 单击“查找下一个”以查看它是否有效
  8. 单击“替换” All”,如果你勇敢的话

,但这不会修复 #if / #endif 之间代码的缩进。

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:

  1. Open the find and replace dialog (ctrl+H)
  2. Under "Find what:", enter "#if SILOG{(.*\n)@}#endif" without the quotes
  3. Under "Replace with:", enter "\1" without the quotes
  4. Under "Look in", select "Entire Solution"
  5. Expand "Find options"
  6. Check "Use:" and select "Regular expressions" from the combobox
  7. Click "Find Next" to see if it worked
  8. Click "Replace All" if you're brave

This won't fix the indentation of the code that was between the #if / #endif, however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文