This project is read-only.
1
Vote

SymbolFinder.FindReferencesAsync throwing NullReferenceException

description

After upgrading Microsoft.CodeAnalysis to version 0.7.4052301 the method SymbolFinder.FindReferencesAsync started throwing an Exception that was not happening on the previous version.
public static List<ReferencedSymbol> FindAllReferences(this Solution objSolutionToSearch, ISymbol symbol)
{
       List<ReferencedSymbol> references = null;
       var result = SymbolFinder.FindReferencesAsync(symbol, objSolutionToSearch).Result;
       if (result != null && result.Any()) references = result.ToList();
       return references;
}
$exception.ToString() returns:
"System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Microsoft.CodeAnalysis.Shared.Extensions.DocumentExtensions.GetLinkedDocumentIds(Document document)\r\n   at Microsoft.CodeAnalysis.FindSymbols.Finders.LinkedFileReferenceFinder.<DetermineCascadedSymbolsAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass28.<<DetermineAllSymbolsCoreAsync>b__35>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter
.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.Compiler
Services.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__3.MoveNext()\r\n   --- End of inner exception stack trace ---\r\n   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n   at System.Threading.Tasks.Task`1.get_Result
()\r\n   at MyProject.TableMap.Engine.StaticCodeAnalysisService.FindAllReferences(Solution objSolutionToSearch, ISymbol symbol) in C:\\Users\\Guilherme\\Desktop\\TCC\\MyProject.TableMap\\MyProject.TableMap.Engine\\StaticCodeAnalysisService.cs:line 327\r\n   at MyProject.TableMap.Engine.StaticCodeAnalysisService.ScanMethodSymbol(Solution objSvdSolution, List`1 nodes, IMethodSymbol methodSymbol) in C:\\Users\\Guilherme\\Desktop\\TCC\\MyProject.TableMap\\MyProject.TableMap.Engine\\StaticCodeAnalysisService.cs:line 56\r\n   at MyProject.TableMap.Engine.StaticCodeAnalysisService.Scan() in C:\\Users\\Guilherme\\Desktop\\TCC\\MyProject.TableMap\\MyProject.TableMap.Engine\\StaticCodeAnalysisService.cs:line 47\r\n   at MyProject.TableMap.Presentation.Default.Page_Load(Object sender, EventArgs e) in C:\\Users\\Guilherme\\Desktop\\TCC\\MyProject.TableMap\\MyProject.TableMap.Presentation\\Default.aspx.cs:line 15\r\n   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n   
at System.Web.UI.Control.OnLoad(EventArgs e)\r\n   at System.Web.UI.Control.LoadRecursive()\r\n   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)\r\n---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Microsoft.CodeAnalysis.Shared.Extensions.DocumentExtensions.GetLinkedDocumentIds(Document document)\r\n   at Microsoft.CodeAnalysis.FindSymbols.Finders.LinkedFileReferenceFinder.<DetermineCascadedSymbolsAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass28.<<
DetermineAllSymbolsCoreAsync>b__35>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__1.MoveNext()\r\n--- End o
f stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__3.MoveNext()<---\r\n"

comments