How to get a Roslyn FieldSymbol from a FieldDeclarationSyntax node?

前端 未结 1 823
粉色の甜心
粉色の甜心 2020-12-10 02:00

I\'m trying to use Roslyn to determine the publically-exposed API of a project (and then do some further processing using this information, so I can\'t just use reflection).

相关标签:
1条回答
  • 2020-12-10 02:33

    You need to remember that a field declaration syntax can declare multiple fields. So you want:

    foreach (var variable in node.Declaration.Variables)
    {
        var fieldSymbol = model.GetDeclaredSymbol(variable);
        // Do stuff with the symbol here
    }
    
    0 讨论(0)
提交回复
热议问题