如何从 [CSharp] 中的已知 C# 函数生成 Visual Studio 中的函数调用?

How to generate function call in Visual Studio from known C# function in [CSharp]?

Visual Studio 2017/19 的重构操作代码在哪里,例如

VS2019中的重构操作: https://docs.microsoft.com/en-us/visualstudio/ide/refactoring-in-visual-studio?view=vs-2019

我可以找到代码并为我的 Visual Studio 实例重新编译它吗?

我想创建新命令,当给定现有函数时

 private void Call(int v1, int v2, string v3, int v4, int v5) {
     throw new NotImplementedException();
 }

我可以生成调用此函数的代码

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);

要为 generating/modifying 代码编写自己的函数,您需要 Roslyn 语法转换:

https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/get-started/syntax-transformation

简而言之:

  • 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