Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ci:
name: dotnet
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
env:
DOTNET_NOLOGO: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dotnet
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: '**/*.csproj'
global-json-file: ./global.json

- name: Install PSResources
shell: pwsh
run: ./tools/installPSResources.ps1

- name: Build, test, and package
shell: pwsh
run: Invoke-Build -Configuration Release -TestFramework net8.0 RunTests, ZipRelease
continue-on-error: true

- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: PSReadLine-module-${{ matrix.os }}
path: bin/Release/PSReadLine.zip

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: PSReadLine-test-results-${{ matrix.os }}
path: test/TestResults/xUnitTestResults.en-US.xml
6 changes: 3 additions & 3 deletions MockPSConsole/MockPSConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>MockPSConsole</RootNamespace>
<AssemblyName>MockPSConsole</AssemblyName>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<ApplicationManifest>Program.manifest</ApplicationManifest>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
Expand All @@ -14,8 +14,8 @@
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.2.24" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.4.11" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions PSReadLine.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = (property Configuration Release),

[ValidateSet("net472", "net6.0")]
[ValidateSet("net472", "net8.0")]
[string]$TestFramework,

[switch]$CheckHelpContent
Expand All @@ -31,7 +31,7 @@ Import-Module "$PSScriptRoot/tools/helper.psm1"
$targetDir = "bin/$Configuration/PSReadLine"

if (-not $TestFramework) {
$TestFramework = $IsWindows ? "net472" : "net6.0"
$TestFramework = $IsWindows ? "net472" : "net8.0"
}

function ConvertTo-CRLF([string] $text) {
Expand All @@ -58,7 +58,7 @@ Synopsis: Build the Polyfiller assembly
#>
task BuildPolyfiller @polyFillerParams {
exec { dotnet publish -c $Configuration -f 'netstandard2.0' Polyfill }
exec { dotnet publish -c $Configuration -f 'net6.0' Polyfill }
exec { dotnet publish -c $Configuration -f 'net8.0' Polyfill }
}

<#
Expand Down Expand Up @@ -123,7 +123,7 @@ task LayoutModule BuildPolyfiller, BuildMainModule, {
}

Copy-Item "Polyfill/bin/$Configuration/netstandard2.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/netstd" -Force
Copy-Item "Polyfill/bin/$Configuration/net6.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/net6plus" -Force
Copy-Item "Polyfill/bin/$Configuration/net8.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/net6plus" -Force

$binPath = "PSReadLine/bin/$Configuration/netstandard2.0/publish"
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine.dll $targetDir
Expand Down
2 changes: 1 addition & 1 deletion PSReadLine/PlatformWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ internal static IConsole OneTimeInit(PSConsoleReadLine singleton)
_singleton = singleton;
var breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(OnBreak));
SetConsoleCtrlHandler((BreakHandler)breakHandlerGcHandle.Target, true);
_enableVtOutput = !Console.IsOutputRedirected && SetConsoleOutputVirtualTerminalProcessing();
_enableVtOutput = true; // !Console.IsOutputRedirected && SetConsoleOutputVirtualTerminalProcessing();
_terminalOwnerThreadId = GetTerminalOwnerThreadId();

return _enableVtOutput ? new VirtualTerminal() : new LegacyWin32Console();
Expand Down
6 changes: 3 additions & 3 deletions Polyfill/Polyfill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<PropertyGroup>
<AssemblyName>Microsoft.PowerShell.PSReadLine.Polyfiller</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Management.Automation" Version="7.2.24" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="System.Management.Automation" Version="7.4.11" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The build script `build.ps1` can be used to bootstrap, build and test the projec
* Build: `./build.ps1 -Configuration Debug`
* Test:
* Targeting .NET 4.7.2 (Windows only): `./build.ps1 -Test -Configuration Debug -Framework net472`
* Targeting .NET 6.0: `./build.ps1 -Test -Configuration Debug -Framework net6.0`
* Targeting .NET 6.0: `./build.ps1 -Test -Configuration Debug -Framework net8.0`

After build, the produced artifacts can be found at `<your-local-repo-root>/bin/Debug`.

Expand Down
26 changes: 0 additions & 26 deletions appveyor.yml

This file was deleted.

8 changes: 4 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Build the main module with the default configuration (Debug) targeting 'netstandard2.0'.
.EXAMPLE
PS > .\build.ps1 -Test
Run xUnit tests with the default configuration (Debug) and the default target framework (net472 on Windows or net6.0 otherwise).
Run xUnit tests with the default configuration (Debug) and the default target framework (net472 on Windows or net8.0 otherwise).
.PARAMETER Clean
Clean the local repo, but keep untracked files.
.PARAMETER Bootstrap
Expand All @@ -28,10 +28,10 @@
.PARAMETER Framework
The target framework when testing:
- net472: run tests with .NET Framework
- net6.0: run tests with .NET 6.0
- net8.0: run tests with .NET 6.0
When not specified, the target framework is determined by the current OS platform:
- use 'net472' on Windows
- use 'net6.0' on Unix platforms
- use 'net8.0' on Unix platforms
#>
[CmdletBinding(DefaultParameterSetName = 'default')]
param(
Expand All @@ -48,7 +48,7 @@ param(
[switch] $CheckHelpContent,

[Parameter(ParameterSetName = 'test')]
[ValidateSet("net472", "net6.0")]
[ValidateSet("net472", "net8.0")]
[string] $Framework,

[Parameter(ParameterSetName = 'default')]
Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.405",
"rollForward": "latestFeature",
"allowPrerelease": false
}
}
5 changes: 1 addition & 4 deletions nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<configuration>
<packageSources>
<clear />
<add key="PowerShell_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>
84 changes: 2 additions & 82 deletions test/ConsoleFixture.cs
Original file line number Diff line number Diff line change
@@ -1,103 +1,23 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using Xunit;

namespace Test
{
public class WindowsConsoleFixtureHelper
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr LoadKeyboardLayout(string pwszKLID, uint Flags);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr GetKeyboardLayout(uint idThread);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetKeyboardLayoutList(int nBuff, [Out] IntPtr[] lpList);

// For set:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

// For get:
[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetForegroundWindow();

const int WM_INPUTLANGCHANGEREQUEST = 0x0050;

private static string GetLayoutNameFromHKL(IntPtr hkl)
{
var lcid = (int)((uint)hkl & 0xffff);
return (new CultureInfo(lcid)).Name;
}

public static IEnumerable<string> GetKeyboardLayoutList()
{
int cnt = GetKeyboardLayoutList(0, null);
var list = new IntPtr[cnt];
GetKeyboardLayoutList(list.Length, list);

foreach (var layout in list)
{
yield return GetLayoutNameFromHKL(layout);
}
}

public static string GetKeyboardLayout()
{
var layout = GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow(), out var processId));
return GetLayoutNameFromHKL(layout);
}

public static IntPtr SetKeyboardLayout(string lang)
{
var layoutId = (new CultureInfo(lang)).KeyboardLayoutId;
var layout = LoadKeyboardLayout(layoutId.ToString("x8"), 0x80);
// Hacky, but tests are probably running in a console app and the layout change
// is ignored, so post the layout change to the foreground window.
PostMessage(GetForegroundWindow(), WM_INPUTLANGCHANGEREQUEST, 0, layoutId);
Thread.Sleep(500);
return layout;
}
}

public class ConsoleFixture : IDisposable
{
public KeyboardLayout KbLayout { get; private set; }
public string Lang { get; private set; }
public string Os { get; private set; }

public ConsoleFixture()
{
Lang = "";
Os = "";
}

public void Initialize(string lang, string os)
public void Initialize()
{
if (!string.Equals(lang, Lang) || !string.Equals(os, Os))
{
Lang = lang;
Os = os;
KbLayout = new KeyboardLayout(lang, "windows");
}
KbLayout = new KeyboardLayout();
}

public void Dispose()
{
}

public override string ToString()
{
return Lang + "-" + Os;
}
}
}

2 changes: 1 addition & 1 deletion test/DeadKeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class ReadLine
[SkippableFact]
public void DeadKeyShouldBeIgnored()
{
Skip.If(this.Fixture.Lang != "fr-FR", "The dead key test requires Keyboard layout to be set to 'fr-FR'");
Skip.If(true, "The dead key test requires Keyboard layout to be set to 'fr-FR'");
TestSetup(KeyMode.Cmd);

Test("aa", Keys("aa", _.DeadKey_Caret));
Expand Down
Loading
Loading