Change HostProjectBuildComplete to persist workspace projects.
- This was missed in the VS15.7 movement to dev.
This commit is contained in:
parent
1eab654620
commit
492e958114
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
|
|
@ -218,9 +219,18 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
|
|
||||||
if (_projects.TryGetValue(hostProject.FilePath, out var original))
|
if (_projects.TryGetValue(hostProject.FilePath, out var original))
|
||||||
{
|
{
|
||||||
|
var workspaceProject = GetWorkspaceProject(hostProject.FilePath);
|
||||||
|
if (workspaceProject == null)
|
||||||
|
{
|
||||||
|
// Host project was built prior to a workspace project being associated. We have nothing to do without
|
||||||
|
// a workspace project so we short circuit.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Doing an update to the project should keep computed values, but mark the project as dirty if the
|
// Doing an update to the project should keep computed values, but mark the project as dirty if the
|
||||||
// underlying project is newer.
|
// underlying project is newer.
|
||||||
var snapshot = original.WithHostProject(hostProject);
|
var snapshot = original.WithWorkspaceProject(workspaceProject);
|
||||||
|
|
||||||
_projects[hostProject.FilePath] = snapshot;
|
_projects[hostProject.FilePath] = snapshot;
|
||||||
|
|
||||||
// Notify the background worker so it can trigger tag helper discovery.
|
// Notify the background worker so it can trigger tag helper discovery.
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,28 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
|
|
||||||
private Workspace Workspace { get; }
|
private Workspace Workspace { get; }
|
||||||
|
|
||||||
|
[ForegroundFact]
|
||||||
|
public void HostProjectBuildComplete_FindsChangedWorkspaceProject_AndStartsBackgroundWorker()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
Assert.True(Workspace.TryApplyChanges(WorkspaceProject.Solution));
|
||||||
|
ProjectManager.HostProjectAdded(HostProject);
|
||||||
|
var project = WorkspaceProject.WithAssemblyName("Test1"); // Simulate a project change
|
||||||
|
ProjectManager.WorkspaceProjectAdded(project);
|
||||||
|
ProjectManager.Reset();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
ProjectManager.HostProjectBuildComplete(HostProject);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var snapshot = ProjectManager.GetSnapshot(HostProject);
|
||||||
|
Assert.True(snapshot.IsDirty);
|
||||||
|
Assert.True(snapshot.IsInitialized);
|
||||||
|
|
||||||
|
Assert.False(ProjectManager.ListenersNotified);
|
||||||
|
Assert.True(ProjectManager.WorkerStarted);
|
||||||
|
}
|
||||||
|
|
||||||
[ForegroundFact]
|
[ForegroundFact]
|
||||||
public void HostProjectAdded_WithoutWorkspaceProject_NotifiesListeners()
|
public void HostProjectAdded_WithoutWorkspaceProject_NotifiesListeners()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue