-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix contention in Roslyn language service
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1881089 Roslyn recently introduced async API for obtaining and releasing "batch" objects for applying updates in dotnet/roslyn#72424. This change increases the package versions, uses the newer API, fixes some obsolete usages, and gets things building by adding a few package references in order to break the tie on some assembly version conflicts during build. This is another iteration of #9455, which was reverted due to issues it created during signing. Unlike that prior PR, this does not remove Microsoft.VisualStudio.Internal.MicroBuild.Swix`, so I expct the same issues about duplicated items to appear.
- Loading branch information
1 parent
a8a739f
commit c2beee0
Showing
17 changed files
with
147 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ unescape | |
unescapes | ||
ushort | ||
usings | ||
vbproj | ||
vswhidbey | ||
watson | ||
xaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...soft.VisualStudio.ProjectSystem.Managed.UnitTests/Utilities/SynchronizationContextUtil.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
||
namespace Microsoft.VisualStudio; | ||
|
||
internal static class SynchronizationContextUtil | ||
{ | ||
/// <summary> | ||
/// Sets a <see langword="null"/> <see cref="SynchronizationContext"/>, and restores | ||
/// whatever context was <see cref="SynchronizationContext.Current"/> when disposed. | ||
/// </summary> | ||
/// <remarks> | ||
/// This method is intended for use in tests where we use JTF and test code that | ||
/// wants to switch to the main thread. Some of our tests don't actually construct | ||
/// JTF in a way that creates a main thread that can be switched to. For these cases, | ||
/// whatever thread creates the <see cref="Threading.JoinableTaskContext"/> is considered | ||
/// the main thread. In unit tests, it's likely this is a thread pool thread, and | ||
/// attempting to switch to the main thread will land on another thread pool thread. | ||
/// <see cref="Threading.JoinableTaskFactory.SwitchToMainThreadAsync(CancellationToken)"/> | ||
/// attempts to validate the switch was successful, and throws when not. This causes test | ||
/// failures where we don't have a main thread to switch to. A workaround for this is | ||
/// to suppress the synchronization context, which disables the check and allows the test | ||
/// to pass. | ||
/// </remarks> | ||
/// <returns>An object that restores the previous synchronization context when disposed.</returns> | ||
public static IDisposable Suppress() | ||
{ | ||
SynchronizationContext old = SynchronizationContext.Current; | ||
|
||
SynchronizationContext.SetSynchronizationContext(null); | ||
|
||
return new SuppressionReleaser(old); | ||
} | ||
|
||
private sealed class SuppressionReleaser(SynchronizationContext old) : IDisposable | ||
{ | ||
private int _isDisposed; | ||
|
||
public void Dispose() | ||
{ | ||
if (Interlocked.Exchange(ref _isDisposed, 1) is 0) | ||
{ | ||
SynchronizationContext.SetSynchronizationContext(old); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.