Prevent ReSharper removes the existing region while doing file formatting - resharper

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

You have to ensure several things:
Set Remove Regions to None in the Default Pattern
Enable Apply file layout in the code cleanup profile of your choice
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.

Related

What is this yellow-orange color bar at the top of Sublime Text?

What is this yellow-orange color bar at the top of Sublime Text?
Hi all,
I've used sublime text before, but last time I used it I think I tinkered with the theme among other things, but I cannot figure out what this orange bar is at the top of the window or how to remove it. I've looked at the documentation but I've had no luck.
TIA
That image is the placeholder image that Sublime uses when a theme references a texture image whose underlying image file can't be found. That can happen if the file is missing or if the .sublime-theme file is using the wrong name, for example.
The only way to get rid of it is thus to either:
Fix the theme to use the correct image name
Put the missing image in place
Switch to an alternate theme (e.g. Default or Adaptive, which ship with Sublime)
If you're using a custom theme it should be an easy thing to check your sublime-theme file to see what images it's referencing and compare that to images you've added to the theme package to see what's missing.
The most expedient would be the theme switch to one of the ones that ship with Sublime.
If you're already using one of those two themes and you're having this problem, then the issue is that you're augmenting the existing theme and causing it to break. In that case, there are two things to check.
Use Preferences > Browse Packages from the menu or command palette; do you see a folder named Theme - Default? If so, move it away, the files in it are overriding the default themes (including Adaptive; they're both in the same package).
Using the same command as above, look in the User package; look for sublime-theme files and move them away; such files will be combined with other files of the same name, which allows you to add rules to an existing theme in a way that could be breaking it.

prevent resharper from automatically fixing issues

I noticed that Resharper automatically applies fixes (e.g. removing unnecessary namespace prefixes) in methods that I am not working on within the file I'm working on. How do I turn this off? (I only want to fix things if I take specific action).
After reading your question, I'm not sure whether it is about disabling automatic fixes, or just make them more local.
What you're talking about, is called Code Cleanup. You can disable parts of that in the ReSharper options, including the "Optimize Using directives", which you were talking about.
If you just want to cleanup/format a part of a file, you have the option to first select the method/code part, and then hit the shortcut to cleanup. Then, all modifications will just apply to the selected area, not the file.

Stop ReSharper cleanup from reordering unit tests

Currently when I run Full Cleanup on a file with NUnit tests R# totally ruins it. For some reason it reorders the methods with [Test] in alphabetical order. How can I turn this "feature" off?
I'm using version 9.2.
This is explained in the documentation here
you need to go to Code Editing | C# | File Layout page of ReSharper options and then remove the default NUnit layout pattern (or change it so that it doesn't reorder alphabetically)
The simplest way to do this via the ui (which seems to be very confusing) is to double click each Type Pattern and make sure you are in composition view (click the icon in the top right corner until its a cog) then double click the method Entry elements until you find the one which has the constraint for the attribute for NUnit framework (somethign like this):
and then change the Sort By option in the bottom right of the main settings window to be none

How do I configure an ultisnip to override an existing snippet?

I use rails.vim but would like to override one or two snippets with my own using ultisnips.
I've created the snippets but since they're already defined by rails.vim a menu now appears when triggered. I'd like my snippets to override the existing one to avoid the menu.
The solution is to use priority directive. All snippets default to a priority of 0. Therefore, adding this to the top of my custom snippets solved the issue:
# top of custom snippets file
priority 1

ReSharper - Is there a disable command I can add to a file that will not allow reorder of type members?

Much like
// ReSharper disable ConvertToAutoProperty
I would like to know what, if existing, I can add to particular files (and only particular files) so that fields are not sorted on code cleanup.
For more information:
I know there are settings one can set in R# itself. This needs to work even where I don't control settings (like on other people's computers)
I know I can make a setting to disable sorting for particular types in TypeMembersLayout. This also will not work due to the same reason.
I only want this to happen on files I care that it doesn't happen with, not a global setting.
I've been using Resharper for years, and can say with confidence this option doesn't exist. Good idea though..
Maybe Generated Code options can help you. But I didn't try it.
Go to ReSharper->Options->Code Inspection->Generated Code and add your files.
I think ReSharper leaves such files untouched.

Resources