Есть ли способ удалить параметр из всех вызовов метода в Visual Studio 2022?C#

Место общения программистов C#
Гость
Есть ли способ удалить параметр из всех вызовов метода в Visual Studio 2022?

Сообщение Гость »


Разработка API ZWCad с использованием .NET и C#, Visual Studio.
Я начал с этого конструктора классов.

Код: Выделить всё

internal class Foo
{
public List BarFromThisFoo { get; set; }

public double MaxYBar { get; set; } = 0;

// Some other properties

public Foo(bool autoGetBar)
{
if(autoGetBar)
{
BarFromThisFoo = GetBarFromThisFoo();
}

// Get some other properties
}
}
Теперь я перегружаю конструктор и один из методов следующим образом:

Код: Выделить всё

internal class Foo
{
public List BarFromThisFoo { get; set; }

public double MaxYBar { get; set; } = 0;

// Some other properties

public Foo()
{
BarFromThisFoo = GetBarFromThisFoo();

// Get some other properties
}

public Foo(ObjectId[] selectedObjets)
{
BarFromThisFoo = GetBarFromThisFoo(selectedObjets);

// Get some other properties
}

}
The problem is that I have 12 calls to this method and naturally getting errors in all off them since I don't have anymore the bool parameter in the constructor. And all the refactoring options that I have from visual studio point me to add the bool parameter the constructor, wich i don't want.
Is there some refactoring option or tool to this situations?
For now I'm using the Find and Replace tool, but it is kind of slow when having multiple files.
I also have looked for Visual Studio extensions but haven't tried none since none of them seems to cover this situation.


Источник: https://stackoverflow.com/questions/781 ... ual-studio

Вернуться в «C#»