在ReSharper 7中,是否可以扩展字符串的语法高亮?

Gei*_*erg 3 c# resharper

ReSharper有一个奇特的功能,突出显示格式变量,例如string.Format():

的String.format

现在,我已经编写了一个扩展来格式化字符串,如:

public static string FormatWith(this string me, params object[] args) {
    return string.Format(me, args);
}
Run Code Online (Sandbox Code Playgroud)

所以我可以这样做:

在此输入图像描述

现在我想实现类似的语法高亮{0}{1}一个字符串,然后每当.FormatWith.ReSharper有可能这样吗?

Ufu*_*arı 5

您可以通过在JetBrains.Annotations包中使用StringFormatMethodAttribute来完成此操作.

[StringFormatMethod("me")]
public static string FormatWith(this string me, params object[] args) {
    return string.Format(me, args);
}
Run Code Online (Sandbox Code Playgroud)