提交 934fbe93 编写于 作者: C CyrusNajmabadi

Createing indices for metadata can fail. Be resilient to that.

上级 a404917e
......@@ -4,6 +4,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
......@@ -42,7 +43,7 @@ private struct MetadataInfo
/// Note: can be <code>null</code> if were unable to create a SymbolTreeInfo
/// (for example, if the metadata was bogus and we couldn't read it in).
/// </summary>
public readonly SymbolTreeInfo SymbolTreeInfo;
public readonly SymbolTreeInfo SymbolTreeInfoOpt;
/// <summary>
/// Note: the Incremental-Analyzer infrastructure guarantees that it will call all the methods
......@@ -53,7 +54,7 @@ private struct MetadataInfo
public MetadataInfo(SymbolTreeInfo info, HashSet<ProjectId> referencingProjects)
{
SymbolTreeInfo = info;
SymbolTreeInfoOpt = info;
ReferencingProjects = referencingProjects;
}
}
......@@ -114,9 +115,9 @@ private class SymbolTreeInfoCacheService : ISymbolTreeInfoCacheService
if (key != null)
{
if (_metadataPathToInfo.TryGetValue(key, out var metadataInfo) &&
metadataInfo.SymbolTreeInfo.Checksum == checksum)
metadataInfo.SymbolTreeInfoOpt?.Checksum == checksum)
{
return metadataInfo.SymbolTreeInfo;
return metadataInfo.SymbolTreeInfoOpt;
}
}
......@@ -194,11 +195,6 @@ private async Task UpdateSymbolTreeInfoAsync(Project project, CancellationToken
return;
}
if (!project.SupportsCompilation)
{
return;
}
// Produce the indices for the source and metadata symbols in parallel.
var projectTask = UpdateSourceSymbolTreeInfoAsync(project, cancellationToken);
var referencesTask = UpdateReferencesAync(project, cancellationToken);
......@@ -215,6 +211,8 @@ private async Task UpdateSourceSymbolTreeInfoAsync(Project project, Cancellation
projectInfo = await SymbolTreeInfo.GetInfoForSourceAssemblyAsync(
project, checksum, cancellationToken).ConfigureAwait(false);
Debug.Assert(projectInfo != null);
// Mark that we're up to date with this project. Future calls with the same
// semantic version can bail out immediately.
_projectToInfo.AddOrUpdate(project.Id, projectInfo, (_1, _2) => projectInfo);
......@@ -242,7 +240,7 @@ private Task UpdateReferencesAync(Project project, CancellationToken cancellatio
var checksum = SymbolTreeInfo.GetMetadataChecksum(project.Solution, reference, cancellationToken);
if (!_metadataPathToInfo.TryGetValue(key, out var metadataInfo) ||
metadataInfo.SymbolTreeInfo.Checksum != checksum)
metadataInfo.SymbolTreeInfoOpt?.Checksum != checksum)
{
var info = await SymbolTreeInfo.TryGetInfoForMetadataReferenceAsync(
project.Solution, reference, checksum, loadOnly: false, cancellationToken: cancellationToken).ConfigureAwait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册