Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusing code highlighting in Resharper

Tags:

c#

resharper

After certain R#-recommended edits R# colors the background of blocks of code in a light royal blue and also places a mark next to the scroll bar with the same color. It is not an error or even a suggestion. It seems to be a temporary flag that clears if you close and reopen a file.

Steps to recreate:

  1. Write a line of code like: string str = string.Format("{0}", 1);
  2. Notice that R# will mark the str var with a light gray because it is never used.
  3. Press Alt+Enter on the variable and select Remove Declaration from the R# context menu
  4. See the line of code turn light royal blue...
  5. Hover your cursor over the scroll bar marker, all you see is the code...

Does anyone know the meaning/usefulness of this "flagging"?

EDIT: My Resharper version is 4.5 running in VS 2005

like image 206
Paul Sasik Avatar asked Aug 26 '09 13:08

Paul Sasik


People also ask

Does ReSharper provide syntax highlighting?

Syntax highlightingReSharper extends the default Visual Studio's symbol highlighting. Additionally, it highlights fields, local variables, types, and other identifier with configurable colors. For example, ReSharper syntax highlighting allows you to easily distinguish between local variables and fields in your code.

What is the use of syntax highlighting?

Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.


1 Answers

I've verified the behavior that you're seeing in R# 4.5 VS 2008 (build 4.5.1274.1). I've gone through the ReSharper specifc colors in Tools->Options->Environment->Fonts and Colors and found this to be "ReSharper Highlight". I searched the ReSharper defect tracking for "remove declaration" and found this report:

RSRP-68435

A "remove declaration" fix appears for the declaration of test. Selecting this removes the declaration, but ends up coloring the then and else clauses of the if statement blue and adds blue bars to the error strip.

The Jetbrain's answer is:

This fix works as designed. Removing declaration can break code, so all broken usages highlighted and you can navigate them and fix or remove code. Only simple expressions are removed automatically (strings, numbers).

like image 180
James Kolpack Avatar answered Sep 23 '22 00:09

James Kolpack