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

IWorkspaceProjectContext.Dispose() still has UI thread affinity #31019

Closed
jasonmalinowski opened this issue Nov 7, 2018 · 2 comments
Closed

Comments

@jasonmalinowski
Copy link
Member

@davkean still discovered it's got one icky UI thread requirement here:

    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
@davkean
Copy link
Member

davkean commented Jan 16, 2019

@jasonmalinowski Can we remove our switch to the UI thread here?

@jasonmalinowski
Copy link
Member Author

@davkean As best as I know! Not sure if it's something I'd recommend for Preview 3 in case there is something else still subtly wrong.

xoofx pushed a commit to stark-lang/stark-roslyn that referenced this issue Apr 16, 2019
This behavior causes all sorts of problems: removing a file (which
can now happen on a background thread) then tries to call into
all sorts of UI-affinitized APIs which are unavailable there.
Practically,  there's no reason we must do this anyways: if you do
remove a file in one context, we'll update our internal structures to
point to a new context. There's no real harm in that being temporarily
out of sync: either we'll pick the right context at random and the
user won't notice, or if we pick the wrong one, they can select the one
they want and everything will be updated again.

Fixes dotnet#31019.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants