diff --git a/Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs b/Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs index 7cf38ec99..558882652 100644 --- a/Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs +++ b/Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs @@ -180,7 +180,7 @@ internal void Analyze(DDG ddg, CancellationToken cancel) { long endTime = _sw.ElapsedMilliseconds; var thisTime = endTime - startTime; _analysisTime += thisTime; - if (thisTime >= 500 || (_analysisTime / _analysisCount) > 500) { + if (thisTime >= 500 || (_analysisTime / _analysisCount) > 500) { Trace.TraceWarning("Analyzed: {0} {1} ({2} count, {3}ms total, {4}ms mean)", this, thisTime, _analysisCount, _analysisTime, (double)_analysisTime / _analysisCount); } } @@ -188,9 +188,12 @@ internal void Analyze(DDG ddg, CancellationToken cancel) { } internal virtual void AnalyzeWorker(DDG ddg, CancellationToken cancel) { - if (Tree != ProjectEntry.Tree) { - // we were enqueued and a new version became available, don't re-analyze against - // the old version. + Debug.Assert(Ast != null, "Ast has unexpected null value"); + Debug.Assert(ProjectEntry != null, "ProjectEntry has unexpected null value"); + + if (Ast == null || ProjectEntry == null || Tree != ProjectEntry.Tree) { + // analysis unit properties are invalid or we were enqueued and a new version became available + // don't re-analyze against the old version. return; } diff --git a/Nodejs/Product/Analysis/Analysis/VariableDef.cs b/Nodejs/Product/Analysis/Analysis/VariableDef.cs index 217227ecc..b50664a08 100644 --- a/Nodejs/Product/Analysis/Analysis/VariableDef.cs +++ b/Nodejs/Product/Analysis/Analysis/VariableDef.cs @@ -180,7 +180,7 @@ protected virtual void ExceedsTypeLimit() { if (type.Value == null) { continue; } - if (analyzer == null && type.Value.DeclaringModule != null) { + if (analyzer == null && type.Value != null && type.Value.DeclaringModule != null) { analyzer = type.Value.DeclaringModule.Analysis.ProjectState; } var str = type.ToString();