Gate the construction of the singleton RemoteWorkspace #43370
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Workspace.Dispose()
doesn't dispose of all the workspace and language services it provides. For items that exportIWorkspaceService
orILanguageService
directly, this isn't a problem because those instances are serviced by the underlying MEF catalog and it will dispose of items. However, for items provided byIWorkspaceServiceFactory
, only the factory is tracked by the underlying MEF catalog and the factory-created instances are part of each workspace. For unit tests, we're good about making sure both the workspace and the MEF catalog are disposed. However, for integration tests things are a bit more relaxed. In devenv.exe, we only have one Workspace and one MEF catalog and neither get disposed until VS is shutting down. For the OOP process, however, we have some paths by which more than oneRemoteWorkspace
can get created, and these are not disposed. If more than oneRemoteWorkspace
instance gets created, one of them will be discarded, which can lead to finalization ofSqlConnection
if the discarded workspace performed any database operations. This is an attempt to fix the issue by putting a lock around thenew RemoteWorkspace()
call inSolutionService.PrimaryWorkspace
.In addition, two cases in test code where
IPersistentStorage
was not disposed have been corrected.Fixes #22302