dotnet/roslyn

RenameSymbolAsync doesn't rename delegate references resulting in compilation errors in the code after a rename

comtronic opened this issue · 0 comments

Version Used:
CodeAnalysis 3.11.0
(MSBuild 16.11.0)

Steps to Reproduce:

Trying rename of TestMethod1 with the Roslyn Rename to AnotherMethod1 -

await Renamer.RenameSymbolAsync(newSolution, typeSymbol, "AnotherMethod1", solution.Workspace.Options, cancellationToken).ConfigureAwait(false);

C# example code down below:

` public class RenameTestClass
{
public delegate void UnityAction();

	private void TestMethod1()
	{

	}
	public void TestMethod2(UnityAction caller)
	{

	}
	public RenameTestClass()
	{
		TestMethod2(TestMethod1);
	}
}`

Expected Behavior:
I would expect the TestMethod2(TestMethod1);
to get renamed to
TestMethod2(AnotherMethod1);

Actual Behavior:
TestMethod1 delegate doesn't get renamed to AnotherMethod1 - As a result I'm still using a regex-replace instead to get my project files renamed correctly.

In Unity there are tons of UnityAction delegates like this and Roslyn in the current state can't be used for refactoring and renaming unity-code.