Reputation: 993
Where are code located for Visual Studio 2017/19 for refactor operations like
Introduce Constant
Change Signature
Rename method
Refactor operation in VS2019: https://learn.microsoft.com/en-us/visualstudio/ide/refactoring-in-visual-studio?view=vs-2019
Can I locate code and recompile it for my instance of Visual Studio?
I want to make new command, when Given existing function like
private void Call(int v1, int v2, string v3, int v4, int v5) {
throw new NotImplementedException();
}
I can generate code which calls this function
int v1 = default(int);
int v2 = default(int);
string v3 = default(string);
int v4 = default(int);
int v5 = default(int);
Call(v1: v1, v2: v2, v3: v3, v4: v4, v5: v5);
Upvotes: 0
Views: 734
Reputation: 5746
To write your own functions for generating/modifying code, you want Roslyn syntax transformation:
https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/get-started/syntax-transformation
In short:
- Install the .NET Compiler Platform SDK
- Create a new C# Stand-Alone Code Analysis Tool project. In Visual Studio, right-click the
SyntaxTransformationQuickStart
solution node. Choose Add > New Project to display the New Project dialog. Under Visual C# > Extensibility, choose Stand-Alone Code Analysis Tool.- Create and transform trees
Upvotes: 1