Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenameSymbolAsync doesn't rename the symbol in the implementing class #46663

Closed
Youssef1313 opened this issue Aug 10, 2020 · 5 comments
Closed
Labels
Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature - Rename Resolution-By Design The behavior reported in the issue matches the current design
Milestone

Comments

@Youssef1313
Copy link
Member

If I rename a method parameter in an interface through RenameSymbolAsync, it doesn't get updated in the implementing class.

For example:

public interface I
{
    void MyMethod(string oldName); // Rename this to newName
}

public class C : I
{
    public void MyMethod(string oldName) { }
}

The result is:

public interface I
{
    void MyMethod(string newName); // Rename this to newName
}

public class C : I
{
    public void MyMethod(string oldName) { }
}

I was expecting it to be:

public interface I
{
    void MyMethod(string newName); // Rename this to newName
}

public class C : I
{
    public void MyMethod(string newName) { }
}

Found this while writing code fix in roslyn-analyzers repo. (dotnet/roslyn-analyzers#3706)

@sharwell
Copy link
Member

I'm fairly certain this is by design. Code fix implementations can manually located and rename related symbols, but are not required to.

@sharwell sharwell added Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. labels Aug 10, 2020
@Youssef1313
Copy link
Member Author

@sharwell Thanks for reply.

Was there any reason in designing that API not to rename the related symbols?
It would be much easier if that work is done inside the RenameSymbolAsync method.

@CyrusNajmabadi
Copy link
Member

This was by design as cascading here was felt to be innapropriate when we originally tried it. i.e. people wanted the scope of change here to not include optional things like this. We considered an option for it, but there wasn't much demand. I would likely take a PR here that added a programattic option to the rename api to do this.

@jinujoseph jinujoseph added the Resolution-By Design The behavior reported in the issue matches the current design label Aug 18, 2020
@jinujoseph jinujoseph added this to the Backlog milestone Aug 18, 2020
@Evangelink
Copy link
Member

So what's the recommended way to rename the symbols? It seems we can do something using the workspace but as far as I understand this isn't available from the roslyn-analyzers code-fixes.

@CyrusNajmabadi
Copy link
Member

Closing out as this is by design.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature - Rename Resolution-By Design The behavior reported in the issue matches the current design
Projects
None yet
Development

No branches or pull requests

6 participants