相关疑难解决方法(0)

如何使用Roslyn(Microsoft CodeAnalysis)获取范围内的所有可见局部变量名称

(请注意:这不是关于运行时反射/ metainfo)

我正在编写Roslyn CSharpSyntaxVisitor的具体实现

实现VisitIdentifierName时

public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax name)
{
   var symbolInfo = _semanticModel.GetSymbolInfo(name);
   var fieldSymbol = symbolInfo.Symbol as IFieldSymbol;
   if (fieldSymbol != null)
   {
       // Here I would like to get all the local variable names what are visible
       // in the very same scope where this field IdentifierNameSyntax under visiting resides
       // We can suppose that _semanticNodel for the Document is available.
   }
}
Run Code Online (Sandbox Code Playgroud)

c# roslyn

4
推荐指数
1
解决办法
1738
查看次数

标签 统计

c# ×1

roslyn ×1