Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to set the scan code for KEYBDINPUT #33434

Closed
wants to merge 12 commits into from
Closed
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<FakeSignVersion>0.9.2</FakeSignVersion>
<HumanizerCoreVersion>2.2.0</HumanizerCoreVersion>
<ICSharpCodeDecompilerVersion>4.0.0.4285-beta1</ICSharpCodeDecompilerVersion>
<InputSimulatorPlusVersion>1.0.7</InputSimulatorPlusVersion>
<MicrosoftBuildVersion>15.1.548</MicrosoftBuildVersion>
<MicrosoftBuildFrameworkVersion>15.1.548</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildLocatorVersion>1.0.13</MicrosoftBuildLocatorVersion>
Expand Down
5 changes: 3 additions & 2 deletions src/Tools/Source/RunTests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ private void Print(List<TestResult> testResults)
private void PrintFailedTestResult(TestResult testResult)
{
// Save out the error output for easy artifact inspecting
var outputLogPath = Path.Combine(_options.LogFilesOutputDirectory, $"xUnit Failure: {testResult.DisplayName}.log");
File.WriteAllText(outputLogPath, testResult.StandardOutput ?? "");
var outputLogPath = Path.Combine(_options.LogFilesOutputDirectory, $"xUnitFailure-{testResult.DisplayName}.log");

ConsoleUtil.WriteLine($"Errors {testResult.AssemblyName}");
ConsoleUtil.WriteLine(testResult.ErrorOutput);
Expand All @@ -170,6 +169,8 @@ private void PrintFailedTestResult(TestResult testResult)
ConsoleUtil.WriteLine($"Command: {testResult.CommandLine}");
ConsoleUtil.WriteLine($"xUnit output log: {outputLogPath}");

File.WriteAllText(outputLogPath, testResult.StandardOutput ?? "");

if (!string.IsNullOrEmpty(testResult.ErrorOutput))
{
ConsoleUtil.WriteLine(testResult.ErrorOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Harness;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using WindowsInput.Native;
using Xunit;

namespace Roslyn.VisualStudio.IntegrationTests
Expand Down Expand Up @@ -96,13 +97,13 @@ protected virtual void Dispose(bool disposing)
}
}

protected KeyPress Ctrl(VirtualKey virtualKey)
=> new KeyPress(virtualKey, ShiftState.Ctrl);
protected KeyPress Ctrl(VirtualKeyCode virtualKey)
=> new KeyPress(virtualKey, VirtualKeyCode.CONTROL);

protected KeyPress Shift(VirtualKey virtualKey)
=> new KeyPress(virtualKey, ShiftState.Shift);
protected KeyPress Shift(VirtualKeyCode virtualKey)
=> new KeyPress(virtualKey, VirtualKeyCode.SHIFT);

protected KeyPress Alt(VirtualKey virtualKey)
=> new KeyPress(virtualKey, ShiftState.Alt);
protected KeyPress Alt(VirtualKeyCode virtualKey)
=> new KeyPress(virtualKey, VirtualKeyCode.MENU);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
Expand Down Expand Up @@ -32,7 +32,7 @@ void Goo() {
VisualStudio.Editor.SendKeys("if (true) {");
VisualStudio.Editor.Verify.CurrentLineText("if (true) { $$}", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.SendKeys(VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("if (true) { }$$", assertCaretPosition: true);
}

Expand Down Expand Up @@ -65,7 +65,7 @@ void Goo() {

VisualStudio.Editor.SendKeys(
"if (true) {",
VirtualKey.Enter,
VirtualKeyCode.RETURN,
"var a = 1;");

VisualStudio.Editor.Verify.TextContains(@"
Expand All @@ -92,7 +92,7 @@ void Goo() {

VisualStudio.Editor.SendKeys(
"if (true) {",
VirtualKey.Enter,
VirtualKeyCode.RETURN,
"var a = 1;",
'}');

Expand All @@ -114,7 +114,7 @@ public void Braces_OnReturnWithNonWhitespaceSpanInside()
{
VisualStudio.Editor.SendKeys(
"class A { int i;",
VirtualKey.Enter);
VirtualKeyCode.RETURN);

VisualStudio.Editor.Verify.TextContains(@"class A { int i;
$$}",
Expand All @@ -132,7 +132,7 @@ class C {
VisualStudio.Editor.SendKeys("void Goo(");
VisualStudio.Editor.Verify.CurrentLineText("void Goo($$)", assertCaretPosition: true);

VisualStudio.Editor.SendKeys("int x", VirtualKey.Tab);
VisualStudio.Editor.SendKeys("int x", VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("void Goo(int x)$$", assertCaretPosition: true);
}

Expand All @@ -146,7 +146,7 @@ class C {

VisualStudio.Editor.SendKeys(
"void Goo(",
VirtualKey.Escape,
VirtualKeyCode.ESCAPE,
")");

VisualStudio.Editor.Verify.CurrentLineText("void Goo()$$", assertCaretPosition: true);
Expand Down Expand Up @@ -184,7 +184,7 @@ class C {
$$
}");

VisualStudio.Editor.SendKeys("string str = \"", VirtualKey.Tab);
VisualStudio.Editor.SendKeys("string str = \"", VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("string str = \"\"$$", assertCaretPosition: true);
}

Expand Down Expand Up @@ -216,7 +216,7 @@ void M()
VisualStudio.Editor.Verify.CurrentLineText("var v = $@\"$$\"", assertCaretPosition: true);

// Backspace removes quotes
VisualStudio.Editor.SendKeys(VirtualKey.Backspace);
VisualStudio.Editor.SendKeys(VirtualKeyCode.BACK);
VisualStudio.Editor.Verify.CurrentLineText("var v = $@$$", assertCaretPosition: true);

// Undo puts them back
Expand All @@ -241,7 +241,7 @@ class C {
$$
}");

VisualStudio.Editor.SendKeys("System.Action<", VirtualKey.Tab);
VisualStudio.Editor.SendKeys("System.Action<", VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("System.Action<>$$", assertCaretPosition: true);

SetUpEditor(@"
Expand All @@ -250,7 +250,7 @@ class C {
$$
}");

VisualStudio.Editor.SendKeys("void GenericMethod<", VirtualKey.Tab);
VisualStudio.Editor.SendKeys("void GenericMethod<", VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("void GenericMethod<>$$", assertCaretPosition: true);

SetUpEditor(@"
Expand Down Expand Up @@ -290,7 +290,7 @@ class C {
VisualStudio.Editor.SendKeys("char c = '");
VisualStudio.Editor.Verify.CurrentLineText("char c = '$$'", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Delete, VirtualKey.Backspace);
VisualStudio.Editor.SendKeys(VirtualKeyCode.DELETE, VirtualKeyCode.BACK);
VisualStudio.Editor.SendKeys("'\u6666", "'");

VisualStudio.Editor.Verify.CurrentLineText("char c = '\u6666'$$", assertCaretPosition: true);
Expand All @@ -311,14 +311,14 @@ void M()

VisualStudio.Editor.SendKeys(
"var arr=new object[,]{{Goo(0",
VirtualKey.Tab,
VirtualKey.Tab,
VirtualKeyCode.TAB,
VirtualKeyCode.TAB,
",{Goo(Goo(\"hello",
VirtualKey.Tab,
VirtualKey.Tab,
VirtualKey.Tab,
VirtualKey.Tab,
VirtualKey.Tab,
VirtualKeyCode.TAB,
VirtualKeyCode.TAB,
VirtualKeyCode.TAB,
VirtualKeyCode.TAB,
VirtualKeyCode.TAB,
';');

VisualStudio.Editor.Verify.CurrentLineText("var arr = new object[,] { { Goo(0) }, { Goo(Goo(\"hello\")) } };$$", assertCaretPosition: true);
Expand Down Expand Up @@ -361,12 +361,12 @@ class C {
VisualStudio.Editor.SendKeys("string s = \"{([<'");
VisualStudio.Editor.Verify.CurrentLineText("string s = \"{([<'\"$$", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.End, ';', VirtualKey.Enter);
VisualStudio.Editor.SendKeys(VirtualKeyCode.END, ';', VirtualKeyCode.RETURN);

VisualStudio.Editor.SendKeys("string y = @\"{([<'");
VisualStudio.Editor.Verify.CurrentLineText("string y = @\"{([<'\"$$", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.End, ';', VirtualKey.Enter);
VisualStudio.Editor.SendKeys(VirtualKeyCode.END, ';', VirtualKeyCode.RETURN);

VisualStudio.Editor.SendKeys("char ch = '{([<\"");
VisualStudio.Editor.Verify.CurrentLineText("char ch = '{([<\"'$$", assertCaretPosition: true);
Expand Down Expand Up @@ -492,7 +492,7 @@ void M()
}
");

VisualStudio.Editor.SendKeys("new Li(", VirtualKey.Tab);
VisualStudio.Editor.SendKeys("new Li(", VirtualKeyCode.TAB);
VisualStudio.Editor.Verify.CurrentLineText("List<int> li = new List<int>($$)", assertCaretPosition: true);
}

Expand Down Expand Up @@ -544,7 +544,7 @@ class $$
VisualStudio.Editor.Verify.CurrentLineText("class C { $$}", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(
VirtualKey.Enter,
VirtualKeyCode.RETURN,
"int Prop {");
VisualStudio.Editor.Verify.TextContains(@"
class C
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 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.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
Expand All @@ -11,8 +9,8 @@
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

Expand Down Expand Up @@ -311,7 +309,7 @@ static void Main(string[] args)

public class P2 { }");

VisualStudio.Editor.SendKeys(VirtualKey.Backspace, VirtualKey.Backspace, "Stream");
VisualStudio.Editor.SendKeys(VirtualKeyCode.BACK, VirtualKeyCode.BACK, "Stream");

VisualStudio.Editor.InvokeCodeActionList();
var expectedItems = new[]
Expand Down Expand Up @@ -351,7 +349,7 @@ static void Main(string[] args)
}
}
}");
VisualStudio.Editor.SendKeys(VirtualKey.Backspace, VirtualKey.Backspace,
VisualStudio.Editor.SendKeys(VirtualKeyCode.BACK, VirtualKeyCode.BACK,
"Foober");

VisualStudio.Editor.InvokeCodeActionList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Common;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using WindowsInput.Native;
using Xunit;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
Expand Down Expand Up @@ -121,7 +121,7 @@ static void Main(string[] args)

VisualStudio.Editor.Activate();
VisualStudio.Editor.PlaceCaret("aa = aa", charsOffset: -1);
VisualStudio.Editor.SendKeys(VirtualKey.Delete);
VisualStudio.Editor.SendKeys(VirtualKeyCode.DELETE);
VisualStudio.ErrorList.ShowErrorList();
expectedContents = new ErrorListItem[] { };
actualContents = VisualStudio.ErrorList.GetErrorListContents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
Expand Down Expand Up @@ -72,7 +72,7 @@ public int Method()
VisualStudio.Workspace.WaitForAsyncOperations(FeatureAttribute.Rename);
AssertEx.SetEqual(spans, VisualStudio.Editor.GetTagSpans(VisualStudio.InlineRenameDialog.ValidRenameTag));

VisualStudio.Editor.SendKeys("SayHello", VirtualKey.Enter);
VisualStudio.Editor.SendKeys("SayHello", VirtualKeyCode.RETURN);
VisualStudio.Editor.Verify.TextContains(@"private static void SayHello()
{
Console.WriteLine(""Hello World"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Common;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

Expand Down Expand Up @@ -44,7 +44,7 @@ void M()
}
");

VisualStudio.Editor.SendKeys(Shift(VirtualKey.F12));
VisualStudio.Editor.SendKeys(Shift(VirtualKeyCode.F12));

const string programReferencesCaption = "'Program' references";
var results = VisualStudio.FindReferencesWindow.GetContents(programReferencesCaption);
Expand Down Expand Up @@ -87,7 +87,7 @@ static void Main()
}
");

VisualStudio.Editor.SendKeys(Shift(VirtualKey.F12));
VisualStudio.Editor.SendKeys(Shift(VirtualKeyCode.F12));

const string localReferencesCaption = "'local' references";
var results = VisualStudio.FindReferencesWindow.GetContents(localReferencesCaption);
Expand Down Expand Up @@ -130,7 +130,7 @@ static void Main()
}
");

VisualStudio.Editor.SendKeys(Shift(VirtualKey.F12));
VisualStudio.Editor.SendKeys(Shift(VirtualKeyCode.F12));

const string findReferencesCaption = "'\"1\"' references";
var results = VisualStudio.FindReferencesWindow.GetContents(findReferencesCaption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

Expand Down Expand Up @@ -63,7 +64,7 @@ void Goo()
}
}");

VisualStudio.Editor.SendKeys(VirtualKey.Backspace, ";");
VisualStudio.Editor.SendKeys(VirtualKeyCode.BACK, ";");
VisualStudio.Editor.Verify.TextContains(@"
public class C
{
Expand Down Expand Up @@ -257,7 +258,7 @@ object M(object bar)
}
}");
VisualStudio.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace);
VisualStudio.Editor.SendKeys("(ba", new KeyPress(VirtualKey.Enter, ShiftState.Shift), "// comment");
VisualStudio.Editor.SendKeys("(ba", new KeyPress(VirtualKeyCode.RETURN, VirtualKeyCode.SHIFT), "// comment");
VisualStudio.Editor.Verify.TextContains(@"
class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using WindowsInput.Native;
using Xunit;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

Expand Down Expand Up @@ -50,7 +50,7 @@ static void Main(string[] args)
VisualStudio.ImmediateWindow.ShowImmediateWindow(clearAll: true);
VisualStudio.SendKeys.Send("?n");
VisualStudio.Workspace.WaitForAsyncOperations(FeatureAttribute.CompletionSet);
VisualStudio.SendKeys.Send("1", VirtualKey.Tab, VirtualKey.Enter);
VisualStudio.SendKeys.Send("1", VirtualKeyCode.TAB, VirtualKeyCode.RETURN);
Assert.Contains("?n1Var\r\n42", VisualStudio.ImmediateWindow.GetText());
}
}
Expand Down
Loading