Hello,
is there an option how to disable that #if, #endif and other directives are not indended after Edit -> Advanced -> Format document in Visual Studio?
Thank you!
Hello,
is there an option how to disable that #if, #endif and other directives are not indended after Edit -> Advanced -> Format document in Visual Studio?
Thank you!
I'm afraid there's no direct setting in Visual Studio. If you find it, anyway, let me know :)
As an alternative, you might try to use an external tool to format your code (e.g. AStyle). You could create a macro in VS that closes the current file, runs the external tool on the file and re-opens it (and maybe re-positions the cursor at the previous position), so you would be able to format your code from Visual Studio.
I'm not sure if the task is worth the effort, anyway...
Otherwise, you might write your own macro to indent the preprocessor directives in the current file after it has been formatted by VS, without even using external tools (which would probably be rather painful to configure in order to obtain exactly the same formatting as in VS).
Look at 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 "
You can even add custom rules: Creating Custom Rules for Microsoft Source Analyzer
Hope it helps.