How-To's

New color highlighting features in ReSharper 2019.3

Starting from ReSharper 2019.3, we added more colors settings for highlighting code from Tools | Options | Fonts and Colors to adjust code highlighting more precisely. Let’s take a look at the new color options that are available!

Before getting started, make sure ReSharper’s Color Identifiers settings is enabled. You’ll see the setting under ReSharper | Options | Code Inspection | Settings.

General color settings

ReSharper applies color settings to all languages, unless there is a custom color setting applied to one or more languages. Under Tools | Options | Fonts And Colors in Visual Studio, scroll until you see ReSharper All Languages. Here’s where you can customize the color scheme to your liking. After the ReSharper All Languages group, there are several more groups targeting languages such as C#, CSS, C++, HTML, JavaScript and more.

ReSharper C# settings

In earlier versions of ReSharper, the color highlighting settings were stored with no relation to each other. But the team found a more efficient way to work with the settings while adding new ones. Now, the color settings work in a hierarchical manner, so changing the ReSharper C# Method identifier propagates changes to ReSharper C# Static Method Identifier, ReSharper C# Extension Method Identifier, and ReSharper C# Accessor Identifier.

Dedicated settings for C# colors

These color settings are for C# only! For those C# customizations you don’t set – they’ll fallback to their corresponding All Languages setting.

Let’s change the color settings for class identifiers in C#.

Changed color setting

And the result:

Changed color

New color Settings

We’ve implemented some fresh new color settings for constructs in different languages:

  • Static methods, fields, properties, and accessors.
  • Selectors, property names, and attribute names for CSS.
  • JavaScript, IL, and Regex.

Now you can build very precise themes with color customizations for code. Using a color palette that you enjoy plus easy to read style settings enables you to understand your code bases better, and write better code faster.

Download ReSharper now, and make a few color customizations. Perhaps create your own theme? As always, let us know your thoughts about these updates.

Discover more

Refactor code to use new C# language features

重构代码以使用新的 C# 语言功能

在使用任何语言时,向现代语言功能进行现代化改造或迁移有助于提高代码的可读性、效率和安全性。在这篇博文中,我们将研究对代码进行现代化改造的方式,从而优化代码。 利用现代语言功能 为何只为使代码现代化就要重构代码?倘若完好,何必修正?有时,人们会有充分的理由去升级或迁移到新版本的平台或语言。例如,语言逐渐演变并添加了功能,以便利用操作系统功能、设备和浏览器功能、云或其他技术。此外,语言更新还包括引入错误修正、更简洁的语法和语法糖,以及更高效的对象和数据处理方式。 对代码进行现代化改造的重构可以通过提高可读性和可维护性来显著提高代码质量。这是因为随着语言的逐渐演变,新添加的语法往往会有助于减少您必须编写的代码行数并降低代码的复杂性。 ReSharper 和 Rider 等工具可以帮助您实现代码库的现代化。它们会随时更新以支持 .NET 语言的新功能,并且可以在有机会充分利用这些功能时提供建议。附带的好处是,这些建议有助于使您的团队不断更新自身的 C# 技能。 顶级语句 顶级语句在 C# 9 中引入,使您无需恪守显式定义命名空间或类的旧规即可立即开始编写代码。在引入顶级语句之前,即使是打印单个“Hello World”风格消息的最基础应用,也需要包含三层嵌套中括号才能支持一行实际运行代码。这样就会牵扯到大量不必要的样板代码。这真的有必要吗? usi