// Internal for testing internal void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e) { Project project; switch (e.Kind) { case WorkspaceChangeKind.ProjectAdded: { project = e.NewSolution.GetProject(e.ProjectId); Debug.Assert(project != null); _projectManager.WorkspaceProjectAdded(project); break; } case WorkspaceChangeKind.ProjectChanged: case WorkspaceChangeKind.ProjectReloaded: { project = e.NewSolution.GetProject(e.ProjectId); Debug.Assert(project != null); _projectManager.WorkspaceProjectChanged(project); break; } case WorkspaceChangeKind.ProjectRemoved: { project = e.OldSolution.GetProject(e.ProjectId); Debug.Assert(project != null); _projectManager.WorkspaceProjectRemoved(project); break; } case WorkspaceChangeKind.SolutionAdded: case WorkspaceChangeKind.SolutionChanged: case WorkspaceChangeKind.SolutionCleared: case WorkspaceChangeKind.SolutionReloaded: case WorkspaceChangeKind.SolutionRemoved: if (e.OldSolution != null) { foreach (var p in e.OldSolution.Projects) { _projectManager.WorkspaceProjectRemoved(p); } } InitializeSolution(e.NewSolution); break; } }
// Internal for testing internal void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e) { Project project; switch (e.Kind) { case WorkspaceChangeKind.ProjectAdded: { project = e.NewSolution.GetProject(e.ProjectId); Debug.Assert(project != null); _projectManager.WorkspaceProjectAdded(project); break; } case WorkspaceChangeKind.ProjectChanged: case WorkspaceChangeKind.ProjectReloaded: { EnqueueUpdate(e.ProjectId); break; } case WorkspaceChangeKind.ProjectRemoved: { project = e.OldSolution.GetProject(e.ProjectId); Debug.Assert(project != null); _projectManager.WorkspaceProjectRemoved(project); break; } case WorkspaceChangeKind.DocumentChanged: case WorkspaceChangeKind.DocumentReloaded: { // This is the case when a component declaration file changes on disk. We have an MSBuild // generator configured by the SDK that will poke these files on disk when a component // is saved, or loses focus in the editor. project = e.OldSolution.GetProject(e.ProjectId); var document = project.GetDocument(e.DocumentId); // Using EndsWith because Path.GetExtension will ignore everything before .cs // Using Ordinal because the SDK generates these filenames. if (document.FilePath != null && document.FilePath.EndsWith(".cshtml.g.cs", StringComparison.Ordinal)) { EnqueueUpdate(e.ProjectId); } break; } case WorkspaceChangeKind.SolutionAdded: case WorkspaceChangeKind.SolutionChanged: case WorkspaceChangeKind.SolutionCleared: case WorkspaceChangeKind.SolutionReloaded: case WorkspaceChangeKind.SolutionRemoved: if (e.OldSolution != null) { foreach (var p in e.OldSolution.Projects) { _projectManager.WorkspaceProjectRemoved(p); } } InitializeSolution(e.NewSolution); break; } }