Is there a way to prevent ReSharper from formatting a specific code block in a file? Something like:
void MyMethod ()
{
// ReSharper disable formatting
PRE = { my top format } /* no rules */ ;
// ReSharper enable formatting
}
Find the name of formatting rule that you want to tweak. You can look it up on the Code Editing | [Language] | Formatting Style page of ReSharper options ( Alt+R, O ) or alternatively, you can select a code block where the desired rule applies, press Alt+Enter , and choose Format selection | Configure.
Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.
Select ReSharper | Options from the main menu or press Alt+R O . Go to the cleanup profiles settings page: Code Editing | Code Cleanup | Profiles. Select which Code Cleanup profile should be applied on save and click Set as default (the default profile is also used for silent cleanup).
Now it is possible in version 2017.3 like this:
// @formatter:off — disable formatter after this line // @formatter:on — enable formatter after this line
At the moment this is not possible. See feature request RSRP-187963.
As a workaround, if you have a big chunk of "pre-formatted" code, you could move it to an own (partial class) file and add it to the "Generated Code" configuration list. This disables R#'s "Code Cleanup" for this file. Note that it also disables the inspections! (Unfortunately the "Generated Code Region" feature only disables the inspections, not the "Code Cleanup" for a region, as of R# version 9.2.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With