diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs index a661d4befffa3..bb8393f5a32cc 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/EditorInProcess.cs @@ -425,6 +425,17 @@ public async Task InvokeCodeActionListAsync(CancellationToken cancellationToken) await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.SolutionCrawler, cancellationToken); await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.DiagnosticService, cancellationToken); + if (Version.Parse("17.1.31916.450") > await TestServices.Shell.GetVersionAsync(cancellationToken)) + { + // Workaround for extremely unstable async lightbulb prior to: + // https://devdiv.visualstudio.com/DevDiv/_git/VS-Platform/pullrequest/361759 + await TestServices.Input.SendAsync(new KeyPress(VirtualKey.Period, ShiftState.Ctrl)); + await Task.Delay(5000, cancellationToken); + + await TestServices.Editor.DismissLightBulbSessionAsync(cancellationToken); + await Task.Delay(5000, cancellationToken); + } + await ShowLightBulbAsync(cancellationToken); await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.LightBulb, cancellationToken); } diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/ShellInProcess.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/ShellInProcess.cs new file mode 100644 index 0000000000000..e09a972477332 --- /dev/null +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/ShellInProcess.cs @@ -0,0 +1,40 @@ +// 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 file in the project root for more information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.VisualStudio.Shell.Interop; + +namespace Roslyn.VisualStudio.IntegrationTests.InProcess +{ + internal class ShellInProcess : InProcComponent + { + public ShellInProcess(TestServices testServices) + : base(testServices) + { + } + + public async Task GetVersionAsync(CancellationToken cancellationToken) + { + await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + + var shell = await GetRequiredGlobalServiceAsync(cancellationToken); + shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out var versionProperty); + + var fullVersion = versionProperty?.ToString() ?? ""; + var firstSpace = fullVersion.IndexOf(' '); + if (firstSpace >= 0) + { + // e.g. "17.1.31907.60 MAIN" + fullVersion = fullVersion[..firstSpace]; + } + + if (Version.TryParse(fullVersion, out var version)) + return version; + + throw new NotSupportedException($"Unexpected version format: {versionProperty}"); + } + } +} diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/TestServices.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/TestServices.cs index d63a1383bc618..2c4607e0bf62f 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/TestServices.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/TestServices.cs @@ -17,6 +17,7 @@ protected TestServices(JoinableTaskFactory joinableTaskFactory) EditorVerifier = new EditorVerifierInProcess(this); ErrorList = new ErrorListInProcess(this); Input = new InputInProcess(this); + Shell = new ShellInProcess(this); SolutionExplorer = new SolutionExplorerInProcess(this); SolutionVerifier = new SolutionVerifierInProcess(this); StateReset = new StateResetInProcess(this); @@ -33,6 +34,8 @@ protected TestServices(JoinableTaskFactory joinableTaskFactory) public InputInProcess Input { get; } + public ShellInProcess Shell { get; } + public SolutionExplorerInProcess SolutionExplorer { get; } public SolutionVerifierInProcess SolutionVerifier { get; }