未验证 提交 0438792d 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #30421 from sharwell/close-window

Fix failure to close the C# Interactive window in tests
......@@ -8,9 +8,11 @@ namespace Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess
internal class CSharpInteractiveWindow_InProc : InteractiveWindow_InProc
{
private const string ViewCommand = "View.C#Interactive";
private const string WindowTitle = "C# Interactive";
private CSharpInteractiveWindow_InProc(): base(ViewCommand, WindowTitle) { }
private CSharpInteractiveWindow_InProc()
: base(ViewCommand, CSharpVsInteractiveWindowPackage.Id)
{
}
public static CSharpInteractiveWindow_InProc Create()
=> new CSharpInteractiveWindow_InProc();
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using Microsoft.VisualStudio.InteractiveWindow;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess
{
......@@ -23,14 +23,14 @@ internal abstract class InteractiveWindow_InProc : TextViewWindow_InProc
private const int DefaultTimeoutInMilliseconds = 10000;
private readonly string _viewCommand;
private readonly string _windowTitle;
private readonly Guid _windowId;
private int _timeoutInMilliseconds;
private IInteractiveWindow _interactiveWindow;
protected InteractiveWindow_InProc(string viewCommand, string windowTitle)
protected InteractiveWindow_InProc(string viewCommand, Guid windowId)
{
_viewCommand = viewCommand;
_windowTitle = windowTitle;
_windowId = windowId;
_timeoutInMilliseconds = DefaultTimeoutInMilliseconds;
}
......@@ -163,16 +163,14 @@ public void SubmitText(string text)
public void CloseWindow()
{
var dte = GetDTE();
foreach (EnvDTE.Window window in dte.Windows)
InvokeOnUIThread(() =>
{
if (window.Caption == _windowTitle)
var shell = GetGlobalService<SVsUIShell, IVsUIShell>();
if (ErrorHandler.Succeeded(shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFrameOnly, _windowId, out var windowFrame)))
{
window?.Close();
break;
ErrorHandler.ThrowOnFailure(windowFrame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave));
}
}
});
}
public void ShowWindow(bool waitForPrompt = true)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册