Search code examples
c#resharpernamed-parametersresharper-9.0

Resharper - keep named parameters when doing code cleanup


We've adopted a convention that when calling a C# function with a "non-obvious" parameter, we use a named parameter even when it's not necessary.

E.g.

obj.Process(save: true)

rather than

obj.Process(true)

While it's unnecessary, it makes it a lot easier when glancing through the code to see what's going on, particularly with booleans or magic numbers.

However, resharper's code cleanup has a habit of removing these. I haven't been able to find a way to tell it to keep named parameters - is there one?


Solution

  • Although you can achieve it by doing what @EricWalker said, I want to propose another option.

    You can start up the ReSharper options, look for Inspection Severity then go to Redundant explicit argument name specification and change this to do not show. This way you won't lose all the other good cleanups (like removing full name qualifiers) that remove redundant code offers.