Coloring instance variables in Visual Studio

2019-01-26 04:44发布

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";
    }
}

3条回答
Melony?
2楼-- · 2019-01-26 05:17

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

查看更多
手持菜刀,她持情操
3楼-- · 2019-01-26 05:22

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

查看更多
放我归山
4楼-- · 2019-01-26 05:33

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

查看更多
登录 后发表回答