How to use C# to find usages of a class or method?

后端 未结 3 1555
攒了一身酷
攒了一身酷 2020-12-05 20:33

In Visual Studio, I can right-click a class or method and choose \"Find usages\". That gives me a list of places in my solution where that piece of code is used. How can I d

3条回答
  •  渐次进展
    2020-12-05 21:01

    To be honest, I never did that before, as I never needed kind of thing.

    For access to kind of information you need to have access to Token Tree of the compiler, constructed for semantic analysis.

    That kind of information, for sure you can have access from Roslyn (API for C# compiler). Where you can push into the API function a C# text, run a compiler over it and recover Tokens tree.

    The Roslyn Project Overview

    Hope this helps.

提交回复
热议问题