简体   繁体   中英

Get syntax tree nodes in order of execution using Roslyn

Is there any way or workaround to get SyntaxTree nodes in order of execution inside file/class using any means of Roslyn. Entry method is known.

Example:

class myClass 
{
    void EntryMethod() {
        CallMethod1();
        CallMethod2();
        AnotherMethod();
        CallMethod3();
    }

    void AnotherMethod() 
    {
        CallMethod4();
        CallMethod5();
    }
}

Needed result something like:

List<ExpressionStatementSyntax or InvocationExpressionSyntax> 
{CallMethod1, CallMethod2, CallMethod4, CallMethod5, CallMethod3}

There's no built in API for this, as it is in the general case impossible. You can write the code yourself using basic Roslyn APIs though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM