Skip to content

Commit 8115173

Browse files
authored
New colors supported by PS7 (#1064) (#1077)
* New colors supported by PS7 (#1064) * Rework .NET SDK handling
1 parent 809d244 commit 8115173

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

PowerShellEditorServices.build.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if ($PSVersionTable.PSEdition -ne "Core") {
3434

3535
task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi {
3636

37-
$requiredSdkVersion = "2.0.0"
37+
$minRequiredSdkVersion = "2.0.0"
3838

3939
$dotnetPath = "$PSScriptRoot/.dotnet"
4040
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
@@ -54,8 +54,11 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
5454
if ($dotnetExePath) {
5555
# dotnet --version can return a semver that System.Version can't handle
5656
# e.g.: 2.1.300-preview-01. The replace operator is used to remove any build suffix.
57-
$version = (& $dotnetExePath --version) -replace '[+-].*$',''
58-
if ([version]$version -ge [version]$requiredSdkVersion) {
57+
$version = [version]((& $dotnetExePath --version) -replace '[+-].*$','')
58+
$maxRequiredSdkVersion = [version]::Parse("3.0.0")
59+
60+
# $minRequiredSdkVersion <= version < $maxRequiredSdkVersion
61+
if ($version -ge [version]$minRequiredSdkVersion -and $version -lt $maxRequiredSdkVersion) {
5962
$script:dotnetExe = $dotnetExePath
6063
}
6164
else {
@@ -70,7 +73,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
7073

7174
if ($script:dotnetExe -eq $null) {
7275

73-
Write-Host "`n### Installing .NET CLI $requiredSdkVersion...`n" -ForegroundColor Green
76+
Write-Host "`n### Installing .NET CLI $minRequiredSdkVersion...`n" -ForegroundColor Green
7477

7578
# The install script is platform-specific
7679
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" }
@@ -81,10 +84,10 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
8184
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet"
8285

8386
if (!$script:IsUnix) {
84-
& $installScriptPath -Version $requiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
87+
& $installScriptPath -Version $minRequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
8588
}
8689
else {
87-
& /bin/bash $installScriptPath -Version $requiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
90+
& /bin/bash $installScriptPath -Version $minRequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
8891
$env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH
8992
}
9093

src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,38 @@ internal ConsoleColorProxy(EditorServicesPSHostUserInterface hostUserInterface)
8787
_hostUserInterface = hostUserInterface;
8888
}
8989

90+
/// <summary>
91+
/// The Accent Color for Formatting
92+
/// </summary>
93+
public ConsoleColor FormatAccentColor
94+
{
95+
get
96+
{
97+
return _hostUserInterface.FormatAccentColor;
98+
}
99+
100+
set
101+
{
102+
_hostUserInterface.FormatAccentColor = value;
103+
}
104+
}
105+
106+
/// <summary>
107+
/// The Accent Color for Error
108+
/// </summary>
109+
public ConsoleColor ErrorAccentColor
110+
{
111+
get
112+
{
113+
return _hostUserInterface.ErrorAccentColor;
114+
}
115+
116+
set
117+
{
118+
_hostUserInterface.ErrorAccentColor = value;
119+
}
120+
}
121+
90122
/// <summary>
91123
/// The ForegroundColor for Error
92124
/// </summary>

src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ private void WriteDebuggerBanner(DebuggerStopEventArgs eventArgs)
690690

691691
internal static ConsoleColor BackgroundColor { get; set; }
692692

693+
internal ConsoleColor FormatAccentColor { get; set; } = ConsoleColor.Green;
694+
internal ConsoleColor ErrorAccentColor { get; set; } = ConsoleColor.Cyan;
695+
693696
internal ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.Red;
694697
internal ConsoleColor ErrorBackgroundColor { get; set; } = BackgroundColor;
695698

0 commit comments

Comments
 (0)