static void NotifySolutionModified(MonoDevelop.Projects.Solution sol, SolutionId solId, MonoDevelopWorkspace workspace) { if (string.IsNullOrWhiteSpace(sol.BaseDirectory)) { return; } var locService = (MonoDevelopPersistentStorageLocationService)workspace.Services.GetService <IPersistentStorageLocationService> (); locService.NotifyStorageLocationChanging(solId, sol.GetPreferencesDirectory()); }
internal Task <SolutionInfo> CreateSolutionInfo(MonoDevelop.Projects.Solution sol, CancellationToken ct) { return(Task.Run(delegate { return CreateSolutionInfoInternal(sol, ct); })); async Task <SolutionInfo> CreateSolutionInfoInternal(MonoDevelop.Projects.Solution solution, CancellationToken token) { using (var timer = Counters.AnalysisTimer.BeginTiming()) { projections.ClearOldProjectionList(); solutionData = new SolutionData(); var projectInfos = await CreateProjectInfos(solution.GetAllProjects(), token).ConfigureAwait(false); if (IsModifiedWhileLoading(solution)) { return(await CreateSolutionInfoInternal(solution, token).ConfigureAwait(false)); } var solutionId = GetSolutionId(solution); var solutionInfo = SolutionInfo.Create(solutionId, VersionStamp.Create(), solution.FileName, projectInfos); lock (addLock) { if (!added) { added = true; solution.Modified += OnSolutionModified; NotifySolutionModified(solution, solutionId, workspace); workspace.OnSolutionAdded(solutionInfo); lock (workspace.generatedFiles) { foreach (var generatedFile in workspace.generatedFiles) { if (!workspace.IsDocumentOpen(generatedFile.Key.Id)) { workspace.OnDocumentOpened(generatedFile.Key.Id, generatedFile.Value); } } } } } // Check for modified projects here after the solution has been added to the workspace // in case a NuGet package restore finished after the IsModifiedWhileLoading check. This // ensures the type system does not have missing references that may have been added by // the restore. ReloadModifiedProjects(); return(solutionInfo); } } }
internal SolutionId GetSolutionId(MonoDevelop.Projects.Solution solution) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } lock (solutionIdMap) { if (!solutionIdMap.TryGetValue(solution, out SolutionId result)) { solutionIdMap [solution] = result = SolutionId.CreateNewId(solution.Name); } return(result); } }
protected override void Dispose(bool finalize) { base.Dispose(finalize); CancelLoad(); if (IdeApp.Workspace != null) { IdeApp.Workspace.ActiveConfigurationChanged -= HandleActiveConfigurationChanged; } if (currentMonoDevelopSolution != null) { foreach (var prj in currentMonoDevelopSolution.GetAllProjects()) { UnloadMonoProject(prj); } currentMonoDevelopSolution = null; } }
async Task <SolutionInfo> CreateSolutionInfo(MonoDevelop.Projects.Solution solution, CancellationToken token) { var projects = new ConcurrentBag <ProjectInfo> (); var mdProjects = solution.GetAllProjects(); projectionList.Clear(); solutionData = new SolutionData(); List <Task> allTasks = new List <Task> (); foreach (var proj in mdProjects) { if (token.IsCancellationRequested) { return(null); } if (!SupportsRoslyn(proj)) { continue; } var tp = LoadProject(proj, token).ContinueWith(t => { if (!t.IsCanceled) { projects.Add(t.Result); } }); allTasks.Add(tp); } await Task.WhenAll(allTasks.ToArray()); if (token.IsCancellationRequested) { return(null); } var solutionInfo = SolutionInfo.Create(GetSolutionId(solution), VersionStamp.Create(), solution.FileName, projects); lock (addLock) { if (!added) { added = true; OnSolutionAdded(solutionInfo); } } return(solutionInfo); }
internal Task <SolutionInfo> CreateSolutionInfo(MonoDevelop.Projects.Solution sol, CancellationToken ct) { return(Task.Run(delegate { return CreateSolutionInfoInternal(sol, ct); })); async Task <SolutionInfo> CreateSolutionInfoInternal(MonoDevelop.Projects.Solution solution, CancellationToken token) { using (var timer = Counters.AnalysisTimer.BeginTiming()) { projections.ClearOldProjectionList(); solutionData = new SolutionData(); var projectInfos = await CreateProjectInfos(solution.GetAllProjects(), token).ConfigureAwait(false); if (IsModifiedWhileLoading(solution)) { return(await CreateSolutionInfoInternal(solution, token).ConfigureAwait(false)); } var solutionId = GetSolutionId(solution); var solutionInfo = SolutionInfo.Create(solutionId, VersionStamp.Create(), solution.FileName, projectInfos); lock (addLock) { if (!added) { added = true; solution.Modified += OnSolutionModified; NotifySolutionModified(solution, solutionId, workspace); workspace.OnSolutionAdded(solutionInfo); lock (workspace.generatedFiles) { foreach (var generatedFile in workspace.generatedFiles) { if (!workspace.IsDocumentOpen(generatedFile.Key.Id)) { workspace.OnDocumentOpened(generatedFile.Key.Id, generatedFile.Value); } } } } } return(solutionInfo); } } }
bool IsModifiedWhileLoading(MonoDevelop.Projects.Solution solution) { List <MonoDevelop.Projects.DotNetProject> modifiedWhileLoading; lock (workspace.projectModifyLock) { modifiedWhileLoading = modifiedProjects; modifiedProjects = new List <MonoDevelop.Projects.DotNetProject> (); } foreach (var project in modifiedWhileLoading) { // TODO: Maybe optimize this so we don't do O(n^2) if (solution.ContainsItem(project)) { return(true); } } return(false); }
protected override void Dispose (bool finalize) { base.Dispose (finalize); CancelLoad (); if (IdeApp.Workspace != null) { IdeApp.Workspace.ActiveConfigurationChanged -= HandleActiveConfigurationChanged; } if (currentMonoDevelopSolution != null) { foreach (var prj in currentMonoDevelopSolution.GetAllProjects ()) { UnloadMonoProject (prj); } currentMonoDevelopSolution = null; } }
internal Task<SolutionInfo> TryLoadSolution (MonoDevelop.Projects.Solution solution, CancellationToken cancellationToken = default(CancellationToken)) { this.currentMonoDevelopSolution = solution; return CreateSolutionInfo (solution, cancellationToken); }
IEnumerable <MonoDevelop.Projects.Project> GetProjectsWithInstalledPackage(MonoDevelop.Projects.Solution solution, string packageName, string version);
public Task <SolutionInfo> TryLoadSolution(MonoDevelop.Projects.Solution solution /*, IProgressMonitor progressMonitor*/) { this.currentMonoDevelopSolution = solution; CancelLoad(); return(CreateSolutionInfo(solution, src.Token)); }
public Task<SolutionInfo> TryLoadSolution (MonoDevelop.Projects.Solution solution/*, IProgressMonitor progressMonitor*/) { this.currentMonoDevelopSolution = solution; CancelLoad (); return CreateSolutionInfo (solution, src.Token); }
protected override void Dispose (bool disposing) { CurrentSolution = null; base.Dispose (disposing); }
protected override void OnDispose(bool disposing) { CurrentSolution = null; base.OnDispose(disposing); }
public override void Dispose () { CurrentSolution = null; base.Dispose (); }
public override void Dispose() { CurrentSolution = null; base.Dispose(); }