Home:ALL Converter>Roslyn not finding all references

Roslyn not finding all references

Ask Time:2017-03-03T01:33:31         Author:John Rutherford

Json Formatter

I'm using Roslyn to rewrite some methods used throughout a solution.

I was able to find and fix many instances. However, it's not finding all references. Many more show up in Visual Studio with CodeLens or using "Find All References." The solution compiles with no errors.

The references it's not finding seem to be only overloaded methods called from web applications in the solution. But it finds references to non-overloaded methods in these web applications.

I'm finding the symbols for the necessary methods and looping through them, searching for references like this:

MSBuildWorkspace workspace = MSBuildWorkspace.Create();
Solution solution = await workspace.OpenSolutionAsync(@"..\Solutions\Main.sln");

var symbols = await FindSymbols(solution);

foreach (var symbol in symbols)
{
    var callers = await SymbolFinder.FindCallersAsync(symbol, solution);
    // Modify code
}

workspace.TryApplyChanges(solution);

I've also tried SymbolFinder.FindReferencesAsync() and it also does not find the remaining references.

I can't figure out what to do to allow Roslyn to find these additional references that are found in Visual Studio.

Author:John Rutherford,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/42562142/roslyn-not-finding-all-references
yy