Roslyn SymbolFinder Convert Location to Syntax Node

Viewed 1294

I'm using a SymbolFinder to find all references to a variable. I would like to check if this Field is assigned to outside of its definition.

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?               
}

How can I Convert the location into a syntax node, and then check if the node is an assignment?

2 Answers
Related