Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/OmniSharp.MSBuild/ProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,47 @@ public void Initalize(IConfiguration configuration)

_manager.QueueProjectUpdate(projectFilePath, allowAutoRestore: true, projectIdInfo);
}

if(!string.IsNullOrEmpty(_solutionFileOrRootPath))
{
_fileSystemWatcher.Watch(_solutionFileOrRootPath, OnSolutionFileUpdate);
}
}

private void OnSolutionFileUpdate(string filePath, FileChangeType changeType)
{
if(changeType == FileChangeType.Change)
{
var afterChange = GetProjectPathsAndIdsFromSolution(filePath);
var current = _manager.GetAllProjects().Select(x => x.ProjectIdInfo);

var projectsToAdd = afterChange
.Select(x => x.info.Id)
.Except(current.Select(x => x.Id))
.Select(projectId => afterChange.Single(af => af.info.Id == projectId));

var projectsToRemove = current
.Select(x => x.Id)
.Except(afterChange.Select(x => x.info.Id))
.Select(projectId => current.Single(af => af.Id == projectId));

foreach(var (path, info) in projectsToAdd)
{
_logger.LogInformation($"Project {path} added to solution, adding project to queue.");
_manager.QueueProjectUpdate(path, true, info);
}

// foreach(var projectToRemove in projectsToRemove)
// {
// _manager.QueueProjectUpdate(path, true, info);
// }
}
else if(changeType == FileChangeType.Delete)
{
}
}

private IEnumerable<(string, ProjectIdInfo)> GetInitialProjectPathsAndIds()
private IEnumerable<(string path, ProjectIdInfo info)> GetInitialProjectPathsAndIds()
{
// If a solution was provided, use it.
if (!string.IsNullOrEmpty(_environment.SolutionFilePath))
Expand Down Expand Up @@ -156,7 +194,7 @@ public void Initalize(IConfiguration configuration)
});
}

private IEnumerable<(string, ProjectIdInfo)> GetProjectPathsAndIdsFromSolution(string solutionFilePath)
private IEnumerable<(string path, ProjectIdInfo info)> GetProjectPathsAndIdsFromSolution(string solutionFilePath)
{
_logger.LogInformation($"Detecting projects in '{solutionFilePath}'.");

Expand Down