Skip to content

Use newer free-threaded language service API#6979

Merged
drewnoakes merged 2 commits intodotnet:mainfrom
drewnoakes:fix-353-avoid-language-service-ui-thread-switch
Feb 22, 2021
Merged

Use newer free-threaded language service API#6979
drewnoakes merged 2 commits intodotnet:mainfrom
drewnoakes:fix-353-avoid-language-service-ui-thread-switch

Conversation

@drewnoakes
Copy link
Copy Markdown
Member

@drewnoakes drewnoakes commented Feb 21, 2021

Fixes #353

Roslyn recently implemented a free-threaded version of this API, meaning we no longer need to switch to the UI thread before calling it.

This commit bumps the package version, removes the thread switch and calls the new API.

cc @CyrusNajmabadi @jasonmalinowski

Microsoft Reviewers: Open in CodeFlow

@drewnoakes drewnoakes added Tenet-Performance This issue affects the "Performance" tenet. Performance-Scenario-Solution-Open This issue affects solution open performance. labels Feb 21, 2021
@drewnoakes drewnoakes added this to the 16.10 milestone Feb 21, 2021
@drewnoakes drewnoakes requested a review from a team as a code owner February 21, 2021 23:44
@ghost ghost added the Feature-Language-Service Populating the Roslyn workspace with references, source files, analyzers, etc label Feb 21, 2021
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't believe we have anything to pass here for cancellation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

that's fine. we'll continue to have the parameter though in case this is something you hookup in the future. for example, i could imagine a world where the user decides to close VS while we're still loading everything. This would allow youto thread though cancellation if you wanted us to abort.

Our positionhere is: we will support cancellation up through the point where we're still doing computation but haven't done any mutation. once we mutate our actual internal state, we ignore caller-requested cancellation and finish what we're doing. That way our internal models are always in a consistent state.

@drewnoakes drewnoakes force-pushed the fix-353-avoid-language-service-ui-thread-switch branch from 4c5c568 to 7df3513 Compare February 22, 2021 01:47
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't expliictly reference the StreamJsonRpc package anywhere in this solution, so this line had no effect.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A package upgrade must have introduced a Debugger class into a Microsoft.* namespace, as this broke. A using alias didn't help either, hence the fully qualified name here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you put using System.Diagnostics; inside the namespace (not above it like it is now), it would have used the right debugger class as an alternative to fully qualifying it.

Fixes #353

Roslyn recently implemented a free-threaded version of this API, meaning we no longer need to switch to the UI thread before calling it.

This commit bumps the package version, removes the thread switch and calls the new API.
@drewnoakes drewnoakes force-pushed the fix-353-avoid-language-service-ui-thread-switch branch from 7df3513 to 7a7f781 Compare February 22, 2021 02:54
Copy link
Copy Markdown
Contributor

@jjmew jjmew left a comment

Choose a reason for hiding this comment

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

:shipit:

@drewnoakes drewnoakes merged commit 4bf7fcc into dotnet:main Feb 22, 2021
@drewnoakes drewnoakes deleted the fix-353-avoid-language-service-ui-thread-switch branch February 22, 2021 07:42
dmonroym added a commit to dmonroym/project-system that referenced this pull request Mar 3, 2021
…language-service-ui-thread-switch"

This reverts commit 4bf7fcc, reversing
changes made to 8226af9.
dmonroym added a commit to dmonroym/project-system that referenced this pull request Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature-Language-Service Populating the Roslyn workspace with references, source files, analyzers, etc Performance-Scenario-Solution-Open This issue affects solution open performance. Tenet-Performance This issue affects the "Performance" tenet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Responsiveness] Roslyn initialization is forced onto the UI thread, forcing the project system to synchronize initialize it (6.9% of solution open)

4 participants