如何在代码中缩进#if指令? [英] How to indent #if directives in code?
问题描述
Possible Duplicate:
How to force indentation of C# conditional directives?
Can visual studio automatically indent / format preprocessing directives?
在下面的示例代码中,有一个#if
指令,但请注意缺少缩进:
In the following sample code there is a #if
directive but notice the lack of indentation:
else
{
#if DEBUG
Debug.Print(ex.Message);
#endif
return null;
}
我知道对于某些 pure 开发实践来说可能就是这样,但是老实说,在VS.NET中,我不在乎,并且希望它与我的代码保持一致.有没有办法允许#
指令与VS.NET中的其余代码自动内联缩进?
I know this is probably like this for some pure development practice, but honestly within VS.NET I do not care and would prefer it to align with my code. Is there a way to allow #
directives be auto indented inline with the rest of the code in VS.NET?
谢谢!
推荐答案
我试图在此处搜索内容:
I tried to search something here:
选项->文本编辑器-> C#
Option -> Text Editor -> C#
,但是不幸的是,visualstudio似乎没有内置任何东西,可以让您以这种方式缩进预处理器指令.但是,我在谷歌上搜索了此答案,它建议使用 StyleCop .希望对您有帮助.
but unfortunately it seems that visualstudio doesn't have anything built in which permit you to indent the preprocessor directives in that way. However googling I found this answer and it recommends to use StyleCop. Hope this helps you.
这篇关于如何在代码中缩进#if指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!