C# · 12月 27, 2021

如何强制C#条件指令的缩进?

是否有一个选项如何禁用#if,#endif和其他指令不会在编辑后修改 – >高级 – >在Visual Studio中格式化文档?

谢谢!

解决方法 看看 StyleCop.

StyleCop analyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated into many third-party development tools.

您甚至可以添加自定义规则:Creating Custom Rules for Microsoft Source Analyzer

希望它有帮助.