How can I find out exactly which rule is applying syntax highlighting to a particular code element in VS2022 with Resharper? - resharper

I'm running Visual Studio 2022 with Resharper (EAP) and the "Cyberpunk" theme from the VS marketplace (https://marketplace.visualstudio.com/items?itemName=T0uchM3.CTVS19)
Something is applying a white background to the syntax highlighting, but only on strings in JavaScript code which contain jQuery/CSS selectors - see this example:
Regular strings (e.g. the "click" in event handler declarations) are fine. I've been through the VS color list looking for anything with a white background but haven't found out where this is coming from.
Any way to highlight a code snippet and see what rules/plugins are applying syntax highlighting to that specific code snippet?

The specific setting here is Resharper Injected Language Background in Visual Studio Options > Environment > Fonts and Colors:
(Thank you #buhakmeh for figuring this one out!)

Related

Disable Highlighting of Strings in Visual Studio

All of my strings in visual studio are highlighted (see screenshot)
This makes it very difficult when i'm actually highlighting something or using the find functionality.
I cannot find an option for this anywhere, anyone know how to disable this?
This is Visual Studio Community 2017
Go to Tools > Options > Fonts and Colors. On the Display Items, find String and change the Item background color to whatever the color of your editor background is.

IntelliJ - Collapsable blocks

I've used Php for quiet some time and really liked/got used to the feature to collapse code blocks surrounded by curly brackets, with a click on the little plus/minus icons next to the linenumbers.
PhpStorm
Now I'm doing a Java project with IntelliJ and would like to have this feature too. It works for certain cases like classes, functions and custom regions, but not for if/else, switch statements.
IntelliJ without icons
Already tried changing the Folding options, but without success. I know I can achieve the same result by some keyboard-shortcut, but I would like to have those little plus/minus icons next to the linenumbers.
After using the shortcut the little icons appear though.
IntelliJ with icons
Am I missing some options or is there a plugin that can do that?
Currently it's shown for classes, functions, and custom regions. Please vote for this request to change default behavior: https://youtrack.jetbrains.com/issue/IDEA-144819
It is not clear from your question if you tried to enable "code folding outline" feature in the settings, which is under Editor -> General -> Code Folding -> Show code folding outline which does what you want basically.

List of Resharper Default Formatting and Rules

I'm trying to find a list of all the default formatting and rules that Resharper enforces.
Unfortunately, I'm not having any luck.
We use the tool, but want to provide a document of standards to new hires so they can view the standards prior to coding.
Under the ReSharper menu, then Options, you'll find the current rules and conventions ReSharper is using for this solution. Of particular importance are:
Code Inspection->Inspection Severity: Shows the severity of things that ReSharper detects in code. The more things that are warnings or errors, the more closely you will have to conform code to ReSharper's conventions in order to get the file to "go green", or even to compile. The hierarchy is:
Do Not Show - self-explanatory, ignores the inspection
Hint - Does not show on sidebar, shows as dotted line under code in question. Good example: using "var" when the line of code doesn't otherwise explicitly specify the type being assigned.
Suggestion - Shows on sidebar as green tick, code in question has green underline. Good examples: use of "var" when type is explicitly defined in the assignment, member visibility.
Warning - Shows on sidebar as yellow tick, code in question underlined blue, or text is faded color. Naming convention violations, redundant keywords or qualifiers, unused code members.
Error - Red sidebar tick, code in question either red text or underlined red. By default, nothing that wouldn't cause a compilation error is marked as a ReSharper error, but you can prevent compilation by "promoting" lower-priority inspections to errors.
Languages->Naming Style: This section shows you how ReSharper will expect various types of code member names to be formatted. The "Advanced settings" option also contains the "abbreviations list", which is basically a list of exceptions to the normal camel-casing conventions. By default, all format inconsistencies are warnings, and I do not see a way in 5.1 (the version I use) to change the severity of this.
EDIT: Here's a list of inspections and their default severities for RS 4.5, which is a few versions back but should still have the "meat" of ReSharper's C# inspections. http://unintelligible.org/blog/2010/05/24/resharper-45-inspection-severity-list/
Beyond this, even JetBrains simply refers you to the Options window if you want to see the list of inspections for your current language. So, if you want something more up-to-date, you may have to do it yourself. If you do, be sure to post it somewhere so others don't have to repeat your work.
IMHO company coding standard is more than just formatting. It usually includes project organization conventions, library usage guidelines, etc. Listing every possible formatting rule ReSharper knows about will make it quite long and boring. Few examples for common constructs (which you can copy from bottom part of formatting setup window) should suffice. Providing them with short rationale should not be too hard to do manually.

Moving from coderush to resharper

I am about to make the switch to resharper from coderush after using it for 30 days and have some questions I would like to see if I can get some help on.
1: Can you change the resharper code colors? I tend to prefer dark themes so I would like to be able to migrate to a dark theme once the change is complete.
2: Do any other addin provide the member icon paint functionality of Coderush? It is the only feature that I do actually miss as it is handy for scanning. I don't mind paying for the functionality if it works.
EDIT: Found out how to change syntax colors.
There's no direct replacement of "paint member icons" in ReSharper.
I suggest that you use the File Structure window instead, with "Track caret in editor" and/or "Automatically scroll to source" options on to synchronize between focus in File Structure and the caret in the text editor.
As to other VS plug-ins, to my knowledge there aren't any prominent plug-ins that have that - neither VS10x CodeMap nor Productivity Power Tools provide anything similar.
1: Can you change the resharper code colors? I tend to prefer dark
themes so I would like to be able to migrate to a dark theme once the
change is complete.
As well as being able to change Resharper colours (In Tools->Options->Fonts and Colours, look for the "Resharper *" related options), R# supports Visual Studio light and dark themes:
http://www.jetbrains.com/resharper/webhelp/Managing_Color_Themes.html

Plugin for R# similar to CodeRush "statement highlight"

See here http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx - for want of a better description - the statement block highlighting - eg in the pics on the link the "statement blocks" are grouped with a vertical line. I understand this is a feature of CodeRush - does R# have either anything similar, or a plugin to do the same?
I use the latest version of ReSharper that is currently available — ReSharper 4.5 — but unfortunately I don't believe there is any feature for drawing a vertical line between matching braces, as in the screen-shots you referenced.
The feature I find useful, which Ben mentioned, is the matching brace highlighting, however this only takes effect when your cursor is adjacent to an opening or closing brace.
R# has a feature called Highlight current line, which you have to enable in the ReSharper options. This looks like crap on dark background, high contrast themes, so if you use one I'd suggest going into the Visual Studio options, under Fonts & Colors and going to "ReSharper - current Line" and making the background color a darker shade that doesn't have as much contrast with the background.
R# also has matching brace highlighting, which is color-configurable as well under the same VS option dialog.
Does that answer you question?
Notepad ++ has a nice brace matching feature, with vertical lines matching the braces. It's not VS, so I only use it when I am faced with some confusing JS, cut and paste, figure out the braces and go back to VS. It would be GREAT if this sort of feature existed in VS, or R#.

Resources