private async Task UpdateSymbolTreeInfoAsync(Project project, CancellationToken cancellationToken) { if (!project.SupportsCompilation) { return; } // Check the semantic version of this project. The semantic version will change // if any of the source files changed, or if the project version itself changed. // (The latter happens when something happens to the project like metadata // changing on disk). var version = await project.GetSemanticVersionAsync(cancellationToken).ConfigureAwait(false); ProjectInfo projectInfo; if (!_projectToInfo.TryGetValue(project.Id, out projectInfo) || projectInfo.VersionStamp != version) { var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); // Update the symbol tree infos for metadata and source in parallel. var referencesTask = UpdateReferencesAync(project, compilation, cancellationToken); var projectTask = SymbolTreeInfo.GetInfoForSourceAssemblyAsync(project, cancellationToken); await Task.WhenAll(referencesTask, projectTask).ConfigureAwait(false); // Mark that we're up to date with this project. Future calls with the same // semantic version can bail out immediately. projectInfo = new ProjectInfo(version, await projectTask.ConfigureAwait(false)); _projectToInfo.AddOrUpdate(project.Id, projectInfo, (_1, _2) => projectInfo); } }
private async Task UpdateSourceSymbolTreeInfoAsync( Project project, CancellationToken cancellationToken ) { var checksum = await SymbolTreeInfo .GetSourceSymbolsChecksumAsync(project, cancellationToken) .ConfigureAwait(false); if ( !_projectIdToInfo.TryGetValue(project.Id, out var projectInfo) || projectInfo.Checksum != checksum ) { projectInfo = await SymbolTreeInfo .GetInfoForSourceAssemblyAsync( project, checksum, loadOnly : false, cancellationToken ) .ConfigureAwait(false); Contract.ThrowIfNull(projectInfo); Contract.ThrowIfTrue( projectInfo.Checksum != checksum, "If we computed a SymbolTreeInfo, then its checksum much match our checksum." ); // Mark that we're up to date with this project. Future calls with the same // semantic version can bail out immediately. _projectIdToInfo[project.Id] = projectInfo; } }
public async Task <SymbolTreeInfo> TryGetSourceSymbolTreeInfoAsync( Project project, CancellationToken cancellationToken ) { // See if the last value produced matches what the caller is asking for. If so, return that. var checksum = await SymbolTreeInfo .GetSourceSymbolsChecksumAsync(project, cancellationToken) .ConfigureAwait(false); if ( _projectIdToInfo.TryGetValue(project.Id, out var projectInfo) && projectInfo.Checksum == checksum ) { return(projectInfo); } // If we didn't have it in our cache, see if we can load it from disk. // Note: pass 'loadOnly' so we only attempt to load from disk, not to actually // try to create the index. var info = await SymbolTreeInfo .GetInfoForSourceAssemblyAsync( project, checksum, loadOnly : true, cancellationToken ) .ConfigureAwait(false); return(info); }
private async Task UpdateSourceSymbolTreeInfoAsync(Project project, CancellationToken cancellationToken) { var checksum = await SymbolTreeInfo.GetSourceSymbolsChecksumAsync(project, cancellationToken).ConfigureAwait(false); if (!_projectToInfo.TryGetValue(project.Id, out var projectInfo) || projectInfo.Checksum != checksum) { projectInfo = await SymbolTreeInfo.GetInfoForSourceAssemblyAsync( project, checksum, cancellationToken).ConfigureAwait(false); // 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); } }
private async Task UpdateSymbolTreeInfoAsync(Project project, CancellationToken cancellationToken) { if (project.Solution.Workspace.Kind != "Test" && project.Solution.Workspace.Kind != WorkspaceKind.RemoteWorkspace && project.Solution.Workspace.Options.GetOption(NavigateToOptions.OutOfProcessAllowed)) { // if GoTo feature is set to run on remote host, then we don't need to build inproc cache. // remote host will build this cache in remote host. return; } if (!project.SupportsCompilation) { return; } // Check the semantic version of this project. The semantic version will change // if any of the source files changed, or if the project version itself changed. // (The latter happens when something happens to the project like metadata // changing on disk). var version = await project.GetSemanticVersionAsync(cancellationToken).ConfigureAwait(false); if (!_projectToInfo.TryGetValue(project.Id, out var projectInfo) || projectInfo.VersionStamp != version) { var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); // Update the symbol tree infos for metadata and source in parallel. var referencesTask = UpdateReferencesAync(project, compilation, cancellationToken); var projectTask = SymbolTreeInfo.GetInfoForSourceAssemblyAsync(project, cancellationToken); await Task.WhenAll(referencesTask, projectTask).ConfigureAwait(false); // Mark that we're up to date with this project. Future calls with the same // semantic version can bail out immediately. projectInfo = new ProjectInfo(version, await projectTask.ConfigureAwait(false)); _projectToInfo.AddOrUpdate(project.Id, projectInfo, (_1, _2) => projectInfo); } }