/// <summary> /// Returns the list of invocations from the given symbol. /// </summary> /// <param name="symbol">Symbol</param> /// <param name="method">Method</param> /// <returns>List of invocations</returns> private List<InvocationExpressionSyntax> GetInvocationsFromSymbol(ISymbol symbol, MethodDeclarationSyntax method) { var invocations = new List<InvocationExpressionSyntax>(); var locations = SymbolFinder.FindReferencesAsync(symbol, this.AnalysisContext.Solution). Result.First().Locations; foreach (var loc in locations) { SyntaxNode node = null; try { node = method.FindNode(loc.Location.SourceSpan); } catch { continue; } var invocation = node.AncestorsAndSelf().OfType<InvocationExpressionSyntax>().FirstOrDefault(); if (invocation != null && invocation.DescendantNodes().OfType<IdentifierNameSyntax>(). First().Identifier.ValueText.Equals(symbol.Name)) { invocations.Add(invocation); } } return invocations; }