diff options
author | David Karlaš <david.karlas@microsoft.com> | 2019-07-18 21:09:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 21:09:18 +0300 |
commit | c6d6d59c2c4797f6b7e74129c692feb350131407 (patch) | |
tree | 38a762f292dc5f5dc51640647de6aa6c2e47148a /main | |
parent | 01d3b0da719e10ae3385a8792234f440e2176685 (diff) | |
parent | ad32fc411e984eb188254ceef2f32730064727e0 (diff) |
Merge pull request #8222 from mono/pr-david-fixGetCodeAnalysisProjectAsync
Make `TypeSystemService.GetCodeAnalysisProjectAsync` return actual value when solution is still loading
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs index f77ef9a3ed..f35f5ac560 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService_WorkspaceHandling.cs @@ -431,18 +431,22 @@ namespace MonoDevelop.Ide.TypeSystem var parentSolution = project.ParentSolution; var workspace = await GetWorkspaceAsync (parentSolution, cancellationToken); var projectId = workspace.GetProjectId (project); - if (projectId == null) - return null; - var proj = workspace.CurrentSolution.GetProject (projectId); - if (proj != null) - return proj; + Microsoft.CodeAnalysis.Project proj = null; + if (projectId != null) { + proj = workspace.CurrentSolution.GetProject (projectId); + if (proj != null) + return proj; + } //We assume that since we have projectId and project is not found in solution //project is being loaded(waiting MSBuild to return list of source files) var taskSource = new TaskCompletionSource<Microsoft.CodeAnalysis.Project> (); var registration = cancellationToken.Register (() => taskSource.TrySetCanceled ()); EventHandler<WorkspaceChangeEventArgs> del = (s, e) => { if (e.Kind == WorkspaceChangeKind.SolutionAdded || e.Kind == WorkspaceChangeKind.SolutionReloaded) { - proj = workspace.CurrentSolution.GetProject (projectId); + projectId = workspace.GetProjectId (project); + if (projectId == null) + return; + var proj = workspace.CurrentSolution.GetProject (projectId); if (proj != null) { registration.Dispose (); taskSource.TrySetResult (proj); |