0

I'm trying to find the references to a method in the entire solution. Below is the code snippet. The same snippet works fine for all the solutions except one. I've subscribed to the workspaceFailed event and there are no workspace or solution load errors. I've even removed duplicate references programmatically.

var semanticModel = document.GetSemanticModelAsync().Result;
 var syntaxTree = semanticModel.SyntaxTree;
 var methodDeclarations = 
 syntaxTree.GetRootAsync().Result.DescendantNodes().OfType<MethodDeclarationSyntax>().Where(m => m.Identifier.ValueText.Equals(criteria.SymbolName));
 foreach(var methodDeclaration in methodDeclarations)
 {
     var node = semanticModel.GetDeclaredSymbol(methodDeclaration);
     var references = SymbolFinder.FindReferencesAsync(node, solution).Result.ToList();
     symbolReferences.AddRange(references);
 }

For all the solutions, diagnostics returns a list of errors like System.string not found, System.Object not found and so on. As it was common across solutions, I ignored it.

Is there any reason why this could be happening? Any suggestions on where to look at or how to get this working?

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
DevD
  • 41
  • 2
  • This is happening because of the diagnostics. – SLaks Oct 31 '17 at 18:42
  • Is there a way to fix it? Meanwhile the same solution builds fine with VS2015. BTW, the other solution where the references are being found also has diagnostic errors. – DevD Nov 01 '17 at 03:55

0 Answers0