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

Move to instantiating and setting up the language service on a bg thread #73351

Merged
merged 13 commits into from
May 6, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 6, 2024

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 6, 2024 18:00
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 6, 2024
this.EditorOptionsService = this.Package.ComponentModel.GetService<EditorOptionsService>();
this.Workspace = this.Package.ComponentModel.GetService<VisualStudioWorkspaceImpl>();
this.EditorAdaptersFactoryService = this.Package.ComponentModel.GetService<IVsEditorAdaptersFactoryService>();
this.AnalyzerFileWatcherService = this.Package.ComponentModel.GetService<AnalyzerFileWatcherService>();
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined GetServices


// TODO: Is the below access to component model required or can be removed?
_ = this.Package.ComponentModel;
this.LanguageDebugInfo = CreateLanguageDebugInfo();
Copy link
Member Author

Choose a reason for hiding this comment

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

moved this to here so it can happen on the BG, instead of on the UI thread when the debugger calls into us.

{
var formatter = this.Workspace.Services.GetLanguageServices(RoslynLanguageName).GetService<ISyntaxFormattingService>();
formatter?.GetDefaultFormattingRules();
}, cancellationToken).Forget();
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to normal Task.Run here. Could switch back to VsTaskLibraryHelper. Need to understand the value of that type.

Copy link
Member

Choose a reason for hiding this comment

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

Fire and forget operations need to be tracked


_isSetUp = true;
}

private object CreateComAggregate()
=> Interop.ComAggregate.CreateAggregatedObject(this);
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined this.

@CyrusNajmabadi CyrusNajmabadi changed the title Defer instantiating debugger related feature components until needed Move to instantiating and setting up the language service on a bg thread May 6, 2024
@@ -273,9 +232,6 @@ private VsLanguageDebugInfo CreateLanguageDebugInfo()
this.Package.ComponentModel.GetService<IUIThreadOperationExecutor>());
}

private void UninitializeLanguageDebugInfo()
Copy link
Member Author

Choose a reason for hiding this comment

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

this uninitialize stuff doesn't appear to serve any purpose. nulling out simple managed types doesnt' buy us anything.

{
this.EditorAdaptersFactoryService = null;
this.Workspace = null;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this doesn't seem to serve any purpose. nulling out these simple managed types serves no purpose.

this.EditorOptionsService = this.Package.ComponentModel.GetService<EditorOptionsService>();
this.Workspace = this.Package.ComponentModel.GetService<VisualStudioWorkspaceImpl>();
this.EditorAdaptersFactoryService = this.Package.ComponentModel.GetService<IVsEditorAdaptersFactoryService>();
this.AnalyzerFileWatcherService = this.Package.ComponentModel.GetService<AnalyzerFileWatcherService>();
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined into constructor.

@@ -117,9 +128,6 @@ internal void TearDown()

_isSetUp = false;
GC.SuppressFinalize(this);

this.Uninitialize();
this.RemoveServices();
Copy link
Member Author

Choose a reason for hiding this comment

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

no need for these. all they did was null out managed objects. something unnecessary with managed types and disposal.

internal VisualStudioWorkspaceImpl Workspace { get; private set; }
internal IVsEditorAdaptersFactoryService EditorAdaptersFactoryService { get; private set; }
internal AnalyzerFileWatcherService AnalyzerFileWatcherService { get; private set; }
internal readonly EditorOptionsService EditorOptionsService;
Copy link
Contributor

Choose a reason for hiding this comment

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

internal readonly EditorOptionsService EditorOptionsService;

by init'ing these in the ctor and not nulling them out, could this file be made nullable without too much effort now?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. will do in followup.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 01a23ff into dotnet:main May 6, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the bgLanguageService branch May 6, 2024 22:08
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 6, 2024
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants