roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS1043 should also remove calls to partial methods

Open nvmkpk opened this issue 3 years ago • 5 comments

Product and Version Used: Visual Studio Extension 3.1.0

Steps to Reproduce: Consider the class below:

public partial class Foo
{
    public Foo()
    {
        this.Initialize();
    }

    partial void Initialize();
}

Actual Behavior: When there is no other partial class is defined for Foo in the project, this analyzer provides an option to remove the partial keyword. When it is selected, it removed the keyword as well as the partial method. But does not remove call to it resulting into a compiler error.

public class Foo
{
    public Foo()
    {
        this.Initialize();
    }
}

Expected Behavior: The code fix should also remove calls to the partial method.

public class Foo
{
    public Foo()
    {
    }
}

nvmkpk avatar Apr 01 '21 19:04 nvmkpk

I came across RCS1043 in a Blazor app with a partial class. Roslynator gives me the option to remove the partial modifier, but it is needed for code-behind Blazor class.

image

ryanbuening avatar May 27 '21 13:05 ryanbuening

@ryanbuening I think it would be possible to suppress the diagnostic if a class is derived from ComponentBase. Can you please create a new issue for it?

josefpihrt avatar May 28 '21 12:05 josefpihrt

Created #807

ryanbuening avatar May 28 '21 15:05 ryanbuening

@ryanbuening I think it would be possible to suppress the diagnostic if a class is derived from ComponentBase. Can you please create a new issue for it?

What about when we don't have a razor file and are defining the component entirely in c#?

nvmkpk avatar May 29 '21 15:05 nvmkpk

What about when we don't have a razor file and are defining the component entirely in c#?

In that case you have to suppress diagnostic or disable the analyzer.

josefpihrt avatar May 29 '21 20:05 josefpihrt