Migrate to Microsoft.VisualStudio.Threading#28781
Merged
sharwell merged 20 commits intodotnet:masterfrom Aug 13, 2018
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change implements the first step towards Roslyn working in applications using vs-threading with reduced risk of concurrency bugs. Recommend reviewing by commit after looking at the full list to get an idea for the overall direction.
Most of the work in this change involves internal propagation of the
IThreadingContextinstance, which provides access to theJoinableTaskFactoryused in Roslyn code.Following this pull request, several diagnostics remain disabled.
FileAndForget" before enabling this diagnostic.Known follow-up issues (GitHub issues will be linked here once they are available):
WaitAndGetResultandWaitAndGetResult_CanCallOnBackgroundas problematic synchronous waits (blocked on Allow extensions for VSTHRD002 (Avoid problematic synchronous waits) microsoft/vs-threading#344)ForegroundThreadDataKind, and gut or eliminateForegroundThreadAffinitizedObjectMigrate to Microsoft.VisualStudio.Threading #28781 (comment)JoinableTaskContexta required import forThreadingContextMigrate to Microsoft.VisualStudio.Threading #28781 (comment)JoinableTaskFactoryTaskScheduler, or at least add it to the set of legacy thread switching types Migrate to Microsoft.VisualStudio.Threading #28781 (comment)AbstractPackage.ForegroundObject, and its costly initialization Migrate to Microsoft.VisualStudio.Threading #28781 (comment)ContinueWith,SafeContinueWith,StartNew,SafeStartNew, andTask.Runto identify cases where simpler approaches are viable Migrate to Microsoft.VisualStudio.Threading #28781 (comment)TestWorkspace.GetService<T>andTestWorkspace.ExportProvider.GetExportedValue<T>Migrate to Microsoft.VisualStudio.Threading #28781 (comment)Customer scenario
This is an internal code change that allows dotnet/roslyn to be more easily incorporated into applications that involve user interfaces and leverage the Microsoft.VisualStudio.Threading library for deadlock and reentrancy mitigation and overall best practices.
Bugs this fixes
N/A
Workarounds, if any
Fixing bugs as they occur.
Risk
This change has moderate risk, but I believe it's relatively low risk considering its scope since existing behaviors were preserved where possible. The primary points where I see risk are the following:
WaitAndGetResultwas weakened, the debug assertion it contained was strengthened substantially. This code does not affect release builds, but despite the work in this pull request it may continue to affect debug pull request builds.Performance impact
Performance should not change substantially as a direct result of this pull request. Over time, performance should improve by allowing more code to use asynchronous operations and more efficient task continuations.
Is this a regression from a previous update?
N/A
Root cause analysis
N/A
How was the bug found?
N/A
Test documentation updated?
N/A