diff options
author | David Karlaš <david.karlas@microsoft.com> | 2019-07-17 17:48:14 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@microsoft.com> | 2019-07-17 19:57:12 +0300 |
commit | ad32fc411e984eb188254ceef2f32730064727e0 (patch) | |
tree | c507c78e34db1081bcd8b87f3c5ffa659b96114b | |
parent | a611c9842b26583daac0492b71748619dcf04bd8 (diff) |
Make `TypeSystemService.GetCodeAnalysisProjectAsync` return actual value when solution is still loading
Main difference between `TypeSystemService.GetCodeAnalysisProjectAsync` and `TypeSystemService.GetCodeAnalysisProject` should be that `Async` version can be called before project/solution is fully loaded and `await` for it to be loaded and then return correct result, `non-Async` version should return project if currently or else `null`.
-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); |