Skip to content

Fix 3267: only add project if needed - #3270

Merged
KevinRansom merged 3 commits into
dotnet:masterfrom
dsyme:fix-3267
Jun 28, 2017
Merged

KevinRansom merged 3 commits into
dotnet:masterfrom
dsyme:fix-3267

Conversation

@dsyme

@dsyme dsyme commented Jun 28, 2017 •

Copy link
Copy Markdown
Contributor

Seems to fix #3267

The problem must be that the given project already exists in the workspace if there is a DAG dependency structure, and we should not be adding it twice.

if not (workspace.ProjectTracker.ContainsProject(project)) then
workspace.ProjectTracker.AddProject(project)

for referencedSite in ProjectSitesAndFiles.GetReferencedProjectSites (site, this.SystemServiceProvider) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For perf, I would suggest adding the reference before telling the workspace about the project. That would avoid sending a bunch of ProjectChanged workspace notifications that will cancel and kick off new work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pilchie Currently we do it in this order:

            let project = projectContextFactory.CreateProjectContext(...)
            let referencedProjectId1 = workspace.ProjectTracker.GetOrCreateProjectIdForPath(...)
            project.AddProjectReference(ProjectReference referencedProjectId1)
            let referencedProjectId2 = workspace.ProjectTracker.GetOrCreateProjectIdForPath(...)
            project.AddProjectReference(ProjectReference referencedProjectId2)
            workspace.ProjectTracker.AddProject(project)
            ... then setup referencedSite1 ....
            ... then setup referencedSite 2....

Is that right? Thanks

@Pilchie

Pilchie commented Jun 28, 2017

Copy link
Copy Markdown
Member

Tagging @jasonmalinowski for his opinion here too, but I think it would probably be most efficient if you can build things bottom up - projects that don't depend on anything first, etc.

@dsyme

dsyme commented Jun 28, 2017

Copy link
Copy Markdown
Contributor Author

@Pilchie @jasonmalinowski OK, could you open a separate issue about that please (if you decide that setting up a referenced project after a referencing project is slower)?

Right now the only simple way of coding that would hit non-termination if for some reason the project graph had a cycle. We'd need to track the graph in a different way, which is not something we should add to this stabilizing PR.

This is ready, the last change was just cosmetic to avoid an extra call

@KevinRansom
KevinRansom merged commit 6b3edb6 into dotnet:master Jun 28, 2017
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* only add project if needed

* de-duplicate call

* Update LanguageService.fs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrow keys and backspace stopped working

4 participants