From 9fe95f5d7e14121e054996cd2e7983a14a93d408 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 11 Mar 2015 16:10:25 -0700 Subject: [PATCH] Handle not-yet-loaded projects in GetENCBuildState VsENCRebuildableProjectImpl.GetNECBuildState was not accounting for the possibility that there might not (yet) be a roslyn project for a given VS project. If we ever encounter this, we should just report that the project is unchanged. We have a number of dumps for this issue, but no concrete repro steps. --- .../VsENCRebuildableProjectImpl.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs index 597273a3606..acde53ff1da 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs @@ -783,8 +783,23 @@ public int GetENCBuildState(ShellInterop.ENC_BUILD_STATE[] pENCBuildState) } else if (_encService.EditSession != null) { - _projectBeingEmitted = _vsProject.VisualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id); - _lastEditSessionSummary = GetProjectAnalysisSummary(_projectBeingEmitted); + // Fetch the latest snapshot of the project and get an analysis summary for any changes + // made since the break mode was entered. + var currentProject = _vsProject.VisualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id); + if (currentProject == null) + { + // If the project has yet to be loaded into the solution (which may be the case, + // since they are loaded on-demand), then it stands to reason that it has not yet + // been modified. + // TODO (https://github.com/dotnet/roslyn/issues/1204): this check should be unnecessary. + _lastEditSessionSummary = ProjectAnalysisSummary.NoChanges; + log.Write($"Project '{_vsProject.DisplayName}' has not yet been loaded into the solution"); + } + else + { + _projectBeingEmitted = currentProject; + _lastEditSessionSummary = GetProjectAnalysisSummary(_projectBeingEmitted); + } _encService.EditSession.LogBuildState(_lastEditSessionSummary); } -- GitLab