Search code examples
c#visual-studio-2017resharper

ReSharper Code Cleanup Adds Redundant Qualifiers


When I apply ReSharper's Code Cleanup, it is added qualifiers to static methods. I then see a diagnostic IDE0002 telling me the name can be simplified. This isn't a problem when I have Code Editing > General Formatter Style > Enable StyleCop support unchecked.

Example

public class Foo
{

    public void Bar()
    {
        StaticMethod();
    }

    private static void StaticMethod()
    {   
    }
}

Gets "cleaned up" to:

public class Foo
{
    public void Bar()
    {
        Foo.StaticMethod();
    }

    private static void StaticMethod()
    {

    }
}

How do I prevent ReSharper Code Cleanup from adding this qualifier and leaving the code unchanged?


Solution

  • Untick all checkboxes in Members to qualify dropdown list here ReSharper | Options | Code Editing | C# | Code Style | Static members qualifications

    enter image description here

    Since you've mentioned that unticking Enable StyleCop support checkbox in ReSharper Options helped, it looks like there is a setting in settings.stylecop file in your solution which overrides ReSharper setting (more about support for StyleCop config file you can find in Enable StyleCop support here)