为 ReSharper 创建新的代码重构
Create new code refactoring for ReSharper
是否可以为 ReSharper 创建代码重构,例如检查参数是否为 null 的重构。
如果我们将其应用于下面的方法,这将生成以下保护检查
public void Method(string value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
}
是否可以创建一个像 "Check string parameter for not null or white space" 这样的重构,它只建议在字符串参数上使用?
public void Method(string value)
{
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentNullException(nameof(value));
}
这可以使用上下文操作。我不知道它是在哪个版本中引入的,但至少在 2016.1 中它应该存在。
除此之外,您可以使用 live templates for some needs. They have some limitations though. If you reach them, you can create a custom plugin that implements a context action 例如。
是否可以为 ReSharper 创建代码重构,例如检查参数是否为 null 的重构。
如果我们将其应用于下面的方法,这将生成以下保护检查
public void Method(string value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
}
是否可以创建一个像 "Check string parameter for not null or white space" 这样的重构,它只建议在字符串参数上使用?
public void Method(string value)
{
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentNullException(nameof(value));
}
这可以使用上下文操作。我不知道它是在哪个版本中引入的,但至少在 2016.1 中它应该存在。
除此之外,您可以使用 live templates for some needs. They have some limitations though. If you reach them, you can create a custom plugin that implements a context action 例如。