diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index 55fd1bf6ef700c8a687c63ce2dbc8e79806ce7ec..c1ef16c9e2de114af9861ed48db87b98f71ba005 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -30,8 +30,6 @@ public sealed class VisualStudioInstanceFactory : IDisposable /// private VisualStudioInstance _currentlyRunningInstance; - private bool _hasCurrentlyActiveContext; - static VisualStudioInstanceFactory() { var majorVsProductVersion = VsProductVersion.Split('.')[0]; @@ -103,8 +101,6 @@ private static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs e /// public async Task GetNewOrUsedInstanceAsync(ImmutableHashSet requiredPackageIds) { - ThrowExceptionIfAlreadyHasActiveContext(); - try { bool shouldStartNewInstance = ShouldStartNewInstance(requiredPackageIds); @@ -122,10 +118,6 @@ public async Task GetNewOrUsedInstanceAsync(Immutab internal void NotifyCurrentInstanceContextDisposed(bool canReuse) { - ThrowExceptionIfAlreadyHasActiveContext(); - - _hasCurrentlyActiveContext = false; - if (!canReuse) { _currentlyRunningInstance?.Close(); @@ -145,14 +137,6 @@ private bool ShouldStartNewInstance(ImmutableHashSet requiredPackageIds) || !_currentlyRunningInstance.IsRunning; } - private void ThrowExceptionIfAlreadyHasActiveContext() - { - if (_hasCurrentlyActiveContext) - { - throw new Exception($"The previous integration test failed to call {nameof(VisualStudioInstanceContext)}.{nameof(Dispose)}. Ensure that test does that to ensure the Visual Studio instance is correctly cleaned up."); - } - } - /// /// Starts up a new , shutting down any instances that are already running. /// @@ -331,9 +315,6 @@ public void Dispose() _currentlyRunningInstance?.Close(); _currentlyRunningInstance = null; - // We want to make sure everybody cleaned up their contexts by the end of everything - ThrowExceptionIfAlreadyHasActiveContext(); - AppDomain.CurrentDomain.FirstChanceException -= FirstChanceExceptionHandler; AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolveHandler; }