diff --git a/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs b/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs index 6055b079f7..1d5ae638e8 100644 --- a/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs +++ b/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs @@ -690,7 +690,6 @@ namespace Microsoft.PowerShell MethodInfo mi = typeof (PSConsoleReadLine).GetMethod(function); var keyHandler = (Action) mi.CreateDelegate(typeof (Action)); - #else var keyHandler = (Action) Delegate.CreateDelegate(typeof (Action), diff --git a/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs b/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs index 1cd3082661..7ab95732b5 100644 --- a/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs +++ b/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs @@ -6,6 +6,9 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +#if CORECLR +using System.Reflection; +#endif using System.Runtime.InteropServices; using Microsoft.PowerShell.Internal; @@ -211,7 +214,22 @@ namespace Microsoft.PowerShell { // default for unprintables and unhandled char keyChar = '\u0000'; - +#if CORECLR + Type keyType = typeof (Keys); + FieldInfo[] keyFields = keyType.GetFields(); + + foreach (FieldInfo field in keyFields) + { + if (field.FieldType == typeof(ConsoleKeyInfo)) + { + ConsoleKeyInfo info = (ConsoleKeyInfo)field.GetValue(null); + if (info.Key == key && info.Modifiers == modifiers) + { + return info.KeyChar; + } + } + } +#else // emulate GetKeyboardState bitmap - set high order bit for relevant modifier virtual keys var state = new byte[256]; state[NativeMethods.VK_SHIFT] = (byte)(((modifiers & ConsoleModifiers.Shift) != 0) ? 0x80 : 0); @@ -234,7 +252,7 @@ namespace Microsoft.PowerShell { keyChar = chars[0]; } - +#endif return keyChar; } } diff --git a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs index 54384e4383..58a9591dbe 100644 --- a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs +++ b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs @@ -490,6 +490,7 @@ namespace Microsoft.PowerShell dispatchTable.TryGetValue(key, out handler); } } + if (handler != null) { if (handler.ScriptBlock != null)