Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coloring instance variables in Visual Studio

Is it possible to color instance (and static) variables in C# code in Visual Studio 2010, perhaps using a lightweight extension?

In following example name and age should be colored but test not. Of course, usages of variable highlighting is grat feature but this is something different. I want instance variables to be colored all and always. Many people use _underscores to distinguish instance variables but I prefer to use coloring.

public class Kid 
{
    private string name;
    private int age;

    public Kid() 
    {
        name = "N/A";
        string test = "XYZ";
    }
}
like image 293
Pol Avatar asked Apr 07 '11 01:04

Pol


People also ask

How do I change the color of a variable in Visual Studio?

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK. The color theme for the entire Visual Studio development environment (IDE) changes to Dark.

What do the different colors mean in Visual Studio?

Here's your quick reference to the colors and icons in the editor window's right-hand margin: Yellow: The line has been changed but not yet saved. Green: The line has been changed and saved. Orange: The line has been changed, saved, and the change undone. Little square dots in the middle of the margin: Break points.

How do I create a custom color in Visual Studio?

Within the Visual Studio Designer, under the properties window you are able to select the ForeColor , BackColor etc using color picker. When you want to pick a color, a color picker comes up with the tabs 'Custom, Web, System'.

What is a variable color?

A color variable is a visual variable that defines the color of a symbol based on a numeric data value returned from a field or expression. If an expression is used, the color can be defined from a color ramp with a set of pre-defined color ranges.


3 Answers

SemanticColorizer is working for me in Visual Studio 2015, it is also available through Extensions and Updates in VS. You can edit colors in Options -> Environment -> Fonts and Colors -> Text Editor -> "Semantic *****". Most important extension is only used for code coloring, it is not some suite with thousands of features which will clog your VS. enter image description here

like image 108
watbywbarif Avatar answered Oct 11 '22 06:10

watbywbarif


This is not possible directly with Visual Studio. However, if you install Resharper, you will get this option (as well as many other coloration options).

like image 28
Reed Copsey Avatar answered Oct 11 '22 08:10

Reed Copsey


This will soon be possible, though not for Visual Studio 2010 in particular. There is an open source Visual Studio extension called Roslyn Colorizer which makes use of the new .NET Compiler Platform ("Roslyn") in Visual Studio 2015 Preview to style the appearance of instance variables.

enter image description here

like image 24
Mr. Smith Avatar answered Oct 11 '22 06:10

Mr. Smith