/// <summary> /// This checks that the new project was modified whilst it was being added to the /// workspace and re-plays project modifications to the workspace as though they /// happened after the project was added. This ensures any updated references due to /// a NuGet restore are made available to the type system. /// </summary> internal void ReloadModifiedProject(MonoDevelop.Projects.Project project) { lock (workspace.projectModifyLock) { if (!workspace.modifiedProjects.Any()) { return; } int removed = workspace.modifiedProjects.RemoveAll(p => p == project); if (removed > 0) { var args = new MonoDevelop.Projects.SolutionItemModifiedEventArgs(project, "References"); workspace.OnProjectModified(project, args); } } }
/// <summary> /// This takes the modified projects that occurred during the solution load and re-plays /// the modifications to the workspace as though they occurred after the load so any updated /// references due to a NuGet restore are made available to the type system. /// </summary> void ReloadModifiedProjects() { lock (workspace.projectModifyLock) { if (!workspace.modifiedProjects.Any()) { return; } var modifiedWhileLoading = workspace.modifiedProjects; workspace.modifiedProjects = new List <MonoDevelop.Projects.DotNetProject> (); foreach (var project in modifiedWhileLoading) { var args = new MonoDevelop.Projects.SolutionItemModifiedEventArgs(project, "References"); workspace.OnProjectModified(project, args); } } }
async void OnProjectModified(object sender, MonoDevelop.Projects.SolutionItemModifiedEventArgs args) { if (internalChanges) { return; } if (!args.Any(x => x.Hint == "TargetFramework" || x.Hint == "References")) { return; } var project = (MonoDevelop.Projects.Project)sender; var projectId = GetProjectId(project); if (CurrentSolution.ContainsProject(projectId)) { OnProjectReloaded(await LoadProject(project, default(CancellationToken)).ConfigureAwait(false)); } }