Parsing function / method content using Reflection

前端 未结 3 506
一整个雨季
一整个雨季 2021-01-19 07:25

My unit testing frameworks consists of TestFixtures, TestMethods and Actions. Action is additional smaller container inside TestMethod, Actions comes from internal Dll writt

3条回答
  •  庸人自扰
    2021-01-19 08:19

    Yes to extent.

    Reflection will give you method body, than you need to disassemble the IL to read method body and obtain any information you want.

    var bytes = mi.GetMethodBody().GetILAsByteArray();
    

    One of possible tools to disassembe is Cecil

    Check out Traverse a c# method and anazlye the method body for more links.

提交回复
热议问题