Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn on language-service integration rewrite #4419

Merged
merged 71 commits into from
Jan 4, 2019

Conversation

davkean
Copy link
Member

@davkean davkean commented Dec 29, 2018

This merges the language-service integration rewrite into master and makes it replace the existing integration. All of these changes have already been reviewed or are out for review, with exception to e4b0c17 and a7e646f.

This fixes: #2733.

Currently broken in Preview 2 bits (unrelated to this change):

Roslyn

Roslyn leaking AbstractProjects
Project Context switch icon changes when moving caret
Multi-targeting context is broken in 16.0 Preview 1
With "Full Solution Analysis" turned on, certain syntax errors get duplicated
Analyzers warning/errors/messages are not correctly grouped for multi-targeting projects

Project System

Build warnings & errors from build always get applied to the first TFM in the project

Testing done

Performance

  • Solution-load time loading Roslyn.sln
  • Solution-load time loading ProjectSystem.sln
  • Solution-load time File -> New -> Console App

Error List

Project manipulation

  • Add/remove a reference and Roslyn sees change (single-TFM)
  • Add/remove a reference and Roslyn sees change (multi-TFM)
  • Add/remove a source file and Roslyn sees change (single-TFM)
  • Add/remove a source file and Roslyn sees change (multi-TFM)
  • Add/remove a Razor file and Roslyn sees change (single-TFM)
  • Add/remove an analyzer and Roslyn sees change (single-TFM)
  • Add/remove an analyzer and Roslyn sees change (multi-TFM)
  • Add/remove an additional file and Roslyn sees change (single-TFM)
  • Add/remove an additional file and Roslyn sees change (multi-TFM)
  • Change conditional compilation symbols and Roslyn sees change (single-TFM)
  • Change conditional compilation symbols and Roslyn sees change (multi-TFM)
  • Retarget project from one TFM -> another
  • Change configuration (single-TFM) [note, this and next scenario are affected by https://github.com/Roslyn leaking AbstractProjects roslyn#32036]
  • Change configuration (multi-TFM)

Features

This lets consumers (error list, edit & continue, etc) run code against context while protecting against being disposed.
Rename ILanguageServiceHost -> IActiveWorkspaceProjectContextHost
Add IWorkspaceProjectContextHost
Unneeded dependency here, just parent the files with the current project file.
Unneeded dependency here, just parent the files with the current project file.
Provides access to IWorkspaceProjectContext and associated services.
Add IWorkspaceProjectContextAccessor to let services use error list/edit & continue services under a lock.
…Host

This moves all consumers of the old language service APIs over to the new APIs and shims the old language service under them.
Stop using IWorkspaceProjectContext version of the project file name
 Merge IActiveWorkspaceProjectContextHost and IWorkspaceProjectContextHost
This class needs to be made async, which prevents lock from being used in async methods. It does not need to be thread-safe as the only consumer of it, WorkspaceContextHostInstance, prevents overlap.
In preparation of making IWorkspaceProjectContext async, plumb through async in ApplyChangesToWorkspaceContext. Handlers will come next.
Remove thread-safeness from ApplyChangesToWorkspaceContext
 Make IApplyChangesToWorkspaceContext async
We can use the new IWorkspaceProjectContext.Id property.
Populate/Dispose context on a background thread
Roslyn will avoid updating VisualStudioWorkspace until after a batch has finished.
Wrap context usage in a batch
Roslyn will avoid updating VisualStudioWorkspace until after a batch has finished.
IWorkspaceProjectContext.Dispose is not actually free-threaded:

Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.Contract.ThrowIfFalse(bool condition, string message)    Unknown
    Microsoft.CodeAnalysis.EditorFeatures.dll!Microsoft.CodeAnalysis.Editor.Shared.Utilities.ForegroundThreadAffinitizedObject.AssertIsForeground()    Unknown
    Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.SetDocumentContext(Microsoft.CodeAnalysis.DocumentId documentId)    Unknown
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.ClearOpenDocument(Microsoft.CodeAnalysis.DocumentId documentId, bool isSolutionClosing)    Unknown
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.ClearOpenDocuments(Microsoft.CodeAnalysis.ProjectId projectId)    Unknown
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.ClearProjectData(Microsoft.CodeAnalysis.ProjectId projectId)    Unknown
    Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Workspace.OnProjectRemoved(Microsoft.CodeAnalysis.ProjectId projectId)    Unknown
    Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.OnProjectRemoved(Microsoft.CodeAnalysis.ProjectId projectId)    Unknown
    Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProject.RemoveFromWorkspace.AnonymousMethod__86_0(Microsoft.CodeAnalysis.Workspace w)    Unknown
    Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyChangeToWorkspace(System.Action<Microsoft.CodeAnalysis.Workspace> action)    Unknown
    Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProject.RemoveFromWorkspace()    Unknown
    Microsoft.VisualStudio.LanguageServices.Implementation.dll!Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProject.Dispose()    Unknown
Components that were calling through accessor where hitting the UI-thread check.
This ensures that the project is loaded before project load has completed. This brings back the original experience of the previous language-service integration.
 Add an implemention of IActiveWorkspaceProjectContext for new language service
We weren't waiting for changes to be applied before we closed the batch. This path is currently synchronous so it's just by change that this currently works.
…Dev16

Allow design-time build logging to be turned on Dev16/suffixes
 Make sure to apply changes under batch
@davkean davkean requested a review from a team as a code owner December 29, 2018 03:31
@davkean davkean added this to the 16.0 Preview 2 milestone Dec 29, 2018
ClearAllErrors was the only method calling this method and would never break out.
@davkean davkean added the Blocked This issue is blocked from making progress due to another issue. label Dec 29, 2018
@davkean
Copy link
Member Author

davkean commented Dec 29, 2018

This is blocked by dotnet/roslyn#31365.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

Nice work 👍

When we've never been set an active editor context, just return the one based on the active configuration.

This combined with dotnet/roslyn#32153, unblocks Razor.
@davkean davkean force-pushed the LanguageServiceMerge branch from e0cf5a5 to 196a145 Compare January 4, 2019 13:41
jasonmalinowski pushed a commit to dotnet/roslyn that referenced this pull request Jan 4, 2019
CPS-based projects have moved from a "fake" IVsHierarchy being passed to the Roslyn to returning the "real" hiearchy representing the project. This results in GetItemContext actually returning a real implementation of "IWebApplicationCtxSvc" instead of previously failing.

This implementation returns S_OK and an "empty" project name - to indicate that it doesn't actually handle the call (with a giant TODO). Handle that situation and treated it as failed, so that we proceed onto IVsContainedLanguageProjectNameProvider which provides the real underlying value.

This is blocking dotnet/project-system#4419.
@jmarolf
Copy link
Contributor

jmarolf commented Jan 4, 2019

@davkean I assume you are asleep but I plan to merge this in the next 15 minutes unless I hear from you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked This issue is blocked from making progress due to another issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor doesn't handle conditional compilation symbol with netstandard or .net core
4 participants