How to modify code before compilation?

前端 未结 3 947
一整个雨季
一整个雨季 2021-01-30 05:22

Using Roslyn, I would like to modify my C# code before the actual compilation. For now, I will just need something like:

[MyAnotatedMethod]
public void MyMethod(         


        
3条回答
  •  天命终不由人
    2021-01-30 05:53

    As I pointed out in my comment it is not currently available. Although you could put something together using AOP techniques shown here with the Roslyn Scripting API to provide a very flexible solution.

    The correct answer at this point in time is that the Roslyn team have an open proposal/issue to support it. Thanks to the .Net Foundation and Microsoft participating in Open Source you can read about this features development here:

    https://github.com/dotnet/roslyn/issues/5561

提交回复
热议问题