2
我正在使用SymbolFinder來查找對變量的所有引用。我想檢查這個字段是否被分配到它的定義之外。Roslyn SymbolFinder將位置轉換爲語法節點
var references = await SymbolFinder.FindReferencesAsync(equivalentSymbol,
context.GetSolution(), cancellationToken);
//Reference is grouped by variable name
var reference = references.FirstOrDefault();
foreach (var location in reference.Locations)
{
//How Do I check if the reference is an assignment?
}
如何將位置轉換爲語法節點,然後檢查節點是否爲賦值?
我想你也可以使用:'location.SourceTree.GetRoot()。FindNode(location.SourceSpan)' – JoshVarty
@JoshVarty我一直在挖掘博客的人,謝謝你是對的,與參考地點的位置。如果你把答案放在答案中,我會標記你的答案是正確的 –