我编写了根据初始状态生成新类的代码。Roslyn 为其提供了类SyntaxFactory,但我不明白如何通过调用基类来生成构造函数,如下所示:
public TestClientApi(String entryPoint) : **base(entryPoint)**
{
_entryPoint = entryPoint;
}
Run Code Online (Sandbox Code Playgroud)
https://github.com/ddydeveloper/Roslyn.ApiClient.Codegen
任何想法?
您需要使用初始值设定项创建构造函数声明。
ConstructorDeclaration("TestClientApi")
.WithInitializer(
ConstructorInitializer(SyntaxKind.BaseConstructorInitializer)
// could be BaseConstructorInitializer or ThisConstructorInitializer
.AddArgumentListArguments(
Argument(IdentifierName("entryPoint"))
)
)
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2219 次 |
| 最近记录: |