Reputation: 15887
Is it possible to create a code refactoring for ReSharper like the one that checks a parameter for null.
This will generate the following guard check if we apply that to the method below
public void Method(string value)
{
if (value == null) throw new ArgumentNullException(nameof(value));
}
Is it possible to create a refactoring like "Check string parameter for not null or white space" that will be suggested on string parameters only?
public void Method(string value)
{
if (string.IsNullOrWhiteSpace(value)) throw new ArgumentNullException(nameof(value));
}
Upvotes: 1
Views: 41
Reputation: 16209
That is possible using context action. I don't know with what exact version this was introduced, but at least with 2016.1 it should be there.
Besides that, you can use 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 for instance.
Upvotes: 2