Skip to content

Commit e750196

Browse files
committed
Revert some overzealous deleting.
1 parent b672186 commit e750196

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/VisualStudio/Core/Def/ProjectSystem/VisualStudioProjectFactory.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ public VisualStudioProjectFactory(
5151
_dynamicFileInfoProviders = fileInfoProviders.AsImmutableOrEmpty();
5252
_analyzerAssemblyRedirectors = analyzerAssemblyRedirectors.AsImmutableOrEmpty();
5353
_solution = solution;
54+
55+
_threadingContext.JoinableTaskFactory.RunAsync(
56+
async () =>
57+
{
58+
var cancellationToken = _threadingContext.DisposalToken;
59+
60+
// HACK: Fetch this service to ensure it's still created on the UI thread; once this is
61+
// moved off we'll need to fix up it's constructor to be free-threaded.
62+
63+
// yield if on the main thread, as the VisualStudioMetadataReferenceManager construction can be fairly expensive
64+
// and we don't want the case where VisualStudioProjectFactory is constructed on the main thread to block on that.
65+
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
66+
_visualStudioWorkspaceImpl.Services.GetRequiredService<VisualStudioMetadataReferenceManager>();
67+
68+
_visualStudioWorkspaceImpl.SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents();
69+
_visualStudioWorkspaceImpl.SubscribeToSourceGeneratorImpactingEvents();
70+
});
5471
}
5572

5673
public Task<ProjectSystemProject> CreateAndAddToWorkspaceAsync(string projectSystemName, string language, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)