'Prevent ReSharper removes the existing region while doing file formatting

I have a file layout that gonna apply when I reformat the code. It is doing well. However, I got some specific codes that I have a #region around them. The ReSharper would remove these existing #region and apply its pattern.

Is there any way to prevent that? I selected [Remove Regions] to None for the Pattern setting but it doesn't work.

Screenshot of the File Layout Setting



Solution 1:[1]

You have to ensure several things:

  1. Set Remove Regions to None in the Default Pattern
    enter image description here
  2. Enable Apply file layout in the code cleanup profile of your choice
    enter image description here
  3. Check all other R# layers to make sure that your custom layout doesn't get overridden.

Doing all these checks, the region MyRegion doesn't get removed on code cleanup.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mu88