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

Fix error closing source link documents in VSCode #74862

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Aug 22, 2024

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2222267/ where closing a sourcelink document would crash the server.

There were two changes that led to this issue

  1. When I implemented Adds support for metadata LSP language features in VSCode #74488, I implemented it on the assumption that IMetadataAsSourceFileService.TryAddDocumentToWorkspace and IMetadataAsSourceFileService.TryRemoveDocumentFromWorkspace actually added and removed documents from the workspace - which was true for metadata and decompilation. This meant if the document was already found in a workspace, we would skip calling TryAddDocumentToWorkspace in LSP.
  2. When I implemented Add support in DevKit for source link go to definition #74626, I failed to realize that PdbSourceDocumentMetadataAsSourceFileProvider.TryAddDocumentToWorkspace and PdbSourceDocumentMetadataAsSourceFileProvider.TryRemoveDocumentFromWorkspace did not actually add/remove from the workspace - that happened in GetGeneratedFileAsync.

So what happened was that TryAddDocumentToWorkspace was sometimes not called because the sourcelink document was already added to to the MetadataAsSource workspace when the original go to definition request was made. So closing the document would throw because the document was never opened.

There were a couple ways to fix this. I chose modifying PdbSourceDocumentMetadataAsSourceFileProvider to match the contract to add and remove the document from the WS in TryAddDocumentToWorkspace TryRemoveDocumentFromWorkspace.

@dibarbet dibarbet requested a review from a team as a code owner August 22, 2024 19:18
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants