dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.11k stars 4.04k forks source link

Rename class names but some will not be renamed #66873

Open NeverMore-Father opened 1 year ago

NeverMore-Father commented 1 year ago

Version Used:

Version Used: Microsoft.CodeAnalysis.Workspaces.MSBuild 4.4.0 Microsoft.CodeAnalysis.CSharp.Workspaces 4.4.0 Microsoft.Build 17.4.0 Microsoft.Build.Tasks.Core 17.4.0

class Student{
}

class Person
{
    Student _st1;
     void Foo(){
          var st = new Student();
     }
}

call Renamer.RenameSymbolAsync(solution, student symbol,BadStudent,solution.Options)

Expected Behavior:

class BadStudent{
}

class Person
{
    BadStudent _st1;
     void Foo(){
          var st = new BadStudent();
     }
}

Actual Behavior:

class BadStudent {
}

class Person
{
    BadStudent _st1;
     void Foo(){
          var st = new Student();  (Constructors are not renamed !!!!)
     }
}
CyrusNajmabadi commented 1 year ago

I do not repro this. Can you supply a fully contained repro project and all your code where you call into rename?

NeverMore-Father commented 1 year ago

@CyrusNajmabadi

I do not repro this. Can you supply a fully contained repro project and all your code where you call into rename?

reproduction project

I uploaded the reproduction project. Then there is another question I want to ask, how to speed up the renaming speed, I want to use Rosyln to confuse the source code, there may be tens of thousands of renames, and the time-consuming may exceed five hours

CyrusNajmabadi commented 1 year ago

how to speed up the renaming speed

You can contribute prs that are reasonable in size and scope that speed up the rename process.

jasonmalinowski commented 1 year ago

We were working on support for allowing the rename engine to rename multiple symbols simultaneously; @Cosifne I think you were working on that?

ryzngard commented 1 year ago

I have a local repro, will investigate further.