在 Visual Studio 中为实例变量着色
是否可以在 Visual Studio 2010 中对 C# 代码中的实例(和静态)变量进行着色(也许使用轻量级扩展)?
在下面的示例中,name
和 age
应该是彩色的,但 test
不是。当然,变量突出显示的使用是一个很好的功能,但这是不同的。我希望实例变量始终被着色。许多人使用_下划线来区分实例变量,但我更喜欢使用着色。
public class Kid
{
private string name;
private int age;
public Kid()
{
name = "N/A";
string test = "XYZ";
}
}
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";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Visual Studio 2019 及更高版本:
您可以在
Tools > 中自定义每个语法分类的颜色。选项>环境>字体和颜色
并滚动到以用户成员
开头的项目。视觉工作室 2015 & 2017 年:
SemanticColorizer 在 Visual Studio 2015 中为我工作,它也可以通过 VS 中的扩展和更新获得。您可以在选项 -> 中编辑颜色环境 -> 字体和颜色 -> 文本编辑器 -> **“语义***”。最重要的扩展仅用于代码着色,它不是一些具有数千个功能的套件,会阻塞您的 VS。
Visual studio 2019 and newer:
You can customize the colors for each syntax classifications in
Tools > Options > Environment > Fonts and Colors
and scroll to the items starting withUser Members
.Visual studio 2015 & 2017:
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.
直接使用 Visual Studio 无法实现这一点。但是,如果您安装 Resharper,您将获得此选项(以及许多其他着色选项) 。
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).
这很快就会成为可能,但对于 Visual Studio 2010 来说尤其如此。有一个名为 Roslyn Colorizer 的开源 Visual Studio 扩展,它利用了新的 .NET 中的编译器平台(“Roslyn”) Visual Studio 2015 Preview 用于设置实例变量的外观样式。
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.