【发布时间】:2021-03-08 09:23:26
【问题描述】:
我已经实现了将 Asp.Net WebApi 迁移到 Asp.Net Core 3.1 的项目。我已经开始学习 Rosyln 解析器。使用 Rosyln,我必须将“ApiController”属性更改为类名中的属性。
Sample.cs
namespace TestFile.TestData.Target
{
public class SampleFile: ApiController
{
}
}
进入
namespace TestFile.TestData.Target
{
[ApiController]
public class SampleFile: ControllerBase
{
}
}
我已点击链接: Adding custom attributes to C# classes using Roslyn。但没看懂。
请就如何使用 Roslyn 的替代解决方案提出建议。
【问题讨论】:
-
哪部分没看懂?
-
不知道我们如何以及在哪里调用 addattribute 方法,而且 SyntaxTree 不包含 ParseCompilationUnit 的定义
标签: c# asp.net-core-webapi roslyn asp.net-core-3.1