By default, Visual Studio applies its auto-formatting rules to all code within a #region block. However, you can turn off auto-formatting for a #region block by using the #pragma directive.
Here's an example of how to turn off auto-formatting for a #region block in Visual Studio:
#region MyRegion #pragma warning disable SA1503 // Braces should not be omitted // Your code goes here #pragma warning restore SA1503 // Braces should not be omitted #endregion
In the above code, the #pragma directive is used to disable the SA1503 rule, which is the rule that enforces brace style for C# code. This effectively turns off auto-formatting for the #region block.
You can replace SA1503 with the rule ID for any other formatting rule that you want to disable. You can find the rule ID by hovering over the warning icon in the Visual Studio error list or by looking it up in the Visual Studio documentation.
After you have disabled the formatting rule using #pragma, you can write your code within the #region block without worrying about auto-formatting interfering with your preferred coding style. Once you're done, you can re-enable the formatting rule using another #pragma directive, as shown in the example above.
"Visual Studio disable auto-formatting for #region"
#region Disable Auto-Formatting // Disable auto-formatting for the code inside this region #pragma warning disable format // Your code here #pragma warning restore format #endregion
"Visual Studio turn off #region formatting"
#region NoAutoFormat // Your code here #endregion
"Visual Studio disable formatting within #region"
#region NoFormatting // Disable auto-formatting for the code inside this region #pragma warning disable format // Your code here #pragma warning restore format #endregion
"Visual Studio disable auto-indentation in #region"
#region NoAutoIndent // Your code here #endregion
"Visual Studio preserve formatting inside #region"
#region PreserveFormatting // Your code here #endregion
"Visual Studio disable formatting for specific code block"
// Disable auto-formatting for specific code block #pragma warning disable format // Your code here #pragma warning restore format
"Visual Studio #region disable indentation"
#region NoAutoIndent // Your code here #endregion
tintcolor phantomjs textureview fpga cpu jenkins-api postgresql-11 triangle-count full-text-search pyqt4