如何从Roslyn中的语句获取参数到变量

时间:2014-03-06 10:01:00

标签: c# roslyn

到目前为止,我已经能够在method.body中找到Console.WriteLine(“Hello World”)语句。但我想从WriteLine(“Hello World”)收集“Hello World”字符串;声明。我怎么能这样做?我的代码:

MethodDeclarationSyntax method = syntaxTree.GetRoot()
                                           .DescendantNodes()
                                           .OfType<MethodDeclarationSyntax>()
                                           .First();
BlockSyntax statement = method.Body;
ControlFlowAnalysis controlFlow = semanticModel.AnalyzeControlFlow(statement);
StatementSyntax state = statement.Statements.First();

Console.WriteLine(state.ToString());
Console.ReadLine();

0 个答案:

没有答案