Skip to content

Commit 9358709

Browse files
authored
Merge pull request PowerShell#852 from PowerShell/2.0.0
[Ignore] Bring master forward to 2.0.0
2 parents 161a3ed + 91f9b1a commit 9358709

File tree

151 files changed

+4970
-2053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+4970
-2053
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ registered_data.ini
2929
.dotnet/
3030
module/Plaster
3131
module/PSScriptAnalyzer
32+
module/PSReadLine
3233
docs/_site/
3334
docs/_repo/
3435
docs/metadata/

.travis.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ language: cpp
33
git:
44
depth: 1000
55

6-
os:
7-
- linux
8-
- osx
9-
sudo: required
10-
dist: trusty
11-
osx_image: xcode8.3
6+
matrix:
7+
include:
8+
- os: linux
9+
dist: trusty
10+
sudo: required
11+
- os: osx
12+
osx_image: xcode9.4
1213

1314
before_install:
1415
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then

NuGet.Config

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,4 @@
33
<solution>
44
<add key="disableSourceControlIntegration" value="true" />
55
</solution>
6-
<packageSources>
7-
<clear />
8-
<add key="CI Builds (dotnet-core)" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
9-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
10-
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
11-
</packageSources>
12-
</configuration>
6+
</configuration>

PowerShellEditorServices.Common.props

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.10.3</VersionPrefix>
3+
<VersionPrefix>2.0.0</VersionPrefix>
44
<Company>Microsoft</Company>
55
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
66
<PackageTags>PowerShell;editor;development;language;debugging</PackageTags>
@@ -9,6 +9,5 @@
99
<RepositoryType>git</RepositoryType>
1010
<RepositoryUrl>https://github.com/PowerShell/PowerShellEditorServices</RepositoryUrl>
1111
<DebugType>portable</DebugType>
12-
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
1312
</PropertyGroup>
1413
</Project>

PowerShellEditorServices.build.ps1

+214-92
Large diffs are not rendered by default.

appveyor.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
version: '1.10.3{build}'
1+
version: '2.0.0-{build}'
22
image: Visual Studio 2017
33
clone_depth: 10
44
skip_tags: true
55

66
branches:
77
only:
88
- master
9+
- 2.0.0
910

1011
environment:
1112
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Don't download unneeded packages
1213
DOTNET_CLI_TELEMETRY_OPTOUT: true # Don't send telemetry
1314

1415
install:
1516
- ps: |
16-
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
17+
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
18+
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -force -confirm:$false -verbose }
19+
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force -Confirm:$false -Verbose }
20+
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
21+
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
22+
Install-PackageProvider -Name NuGet -Force | Out-Null
1723
Import-PackageProvider NuGet -Force | Out-Null
1824
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
1925
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force | Out-Null

module/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.psm1

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
#
55

6-
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
7-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.VSCode.dll"
8-
}
9-
else {
10-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.VSCode.dll"
11-
}
6+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.VSCode.dll"
127

138
if ($psEditor -is [Microsoft.PowerShell.EditorServices.Extensions.EditorObject]) {
149
[Microsoft.PowerShell.EditorServices.VSCode.ComponentRegistration]::Register($psEditor.Components)

module/PowerShellEditorServices/PowerShellEditorServices.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PowerShellEditorServices.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.10.3'
15+
ModuleVersion = '2.0.0'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9ca15887-53a2-479a-9cda-48d26bcb6c47'

module/PowerShellEditorServices/PowerShellEditorServices.psm1

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
#
55

6-
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
7-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.dll"
8-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.Host.dll"
9-
}
10-
else {
11-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.dll"
12-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Protocol.dll"
13-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Host.dll"
6+
# Need to load pipe handling shim assemblies in Windows PowerShell and PSCore 6.0 because they don't have WCP
7+
if ($PSEdition -eq 'Desktop') {
8+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.IO.Pipes.AccessControl.dll"
9+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.Security.AccessControl.dll"
10+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.Security.Principal.Windows.dll"
11+
} elseif ($PSVersionTable.PSVersion -ge '6.0' -and $PSVersionTable.PSVersion -lt '6.1' -and $IsWindows) {
12+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.IO.Pipes.AccessControl.dll"
13+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.Security.AccessControl.dll"
14+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.Security.Principal.Windows.dll"
1415
}
1516

17+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.dll"
18+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Host.dll"
19+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Protocol.dll"
20+
1621
function Start-EditorServicesHost {
1722
[CmdletBinding()]
1823
param(

module/PowerShellEditorServices/Start-EditorServices.ps1

+7-4
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ try {
349349
"status" = "not started";
350350
"languageServiceTransport" = $PSCmdlet.ParameterSetName;
351351
"debugServiceTransport" = $PSCmdlet.ParameterSetName;
352-
};
352+
}
353353

354354
# Create the Editor Services host
355355
Log "Invoking Start-EditorServicesHost"
@@ -368,7 +368,8 @@ try {
368368
-BundledModulesPath $BundledModulesPath `
369369
-EnableConsoleRepl:$EnableConsoleRepl.IsPresent `
370370
-DebugServiceOnly:$DebugServiceOnly.IsPresent `
371-
-WaitForDebugger:$WaitForDebugger.IsPresent
371+
-WaitForDebugger:$WaitForDebugger.IsPresent `
372+
-FeatureFlags $FeatureFlags
372373
break
373374
}
374375

@@ -392,7 +393,8 @@ try {
392393
-BundledModulesPath $BundledModulesPath `
393394
-EnableConsoleRepl:$EnableConsoleRepl.IsPresent `
394395
-DebugServiceOnly:$DebugServiceOnly.IsPresent `
395-
-WaitForDebugger:$WaitForDebugger.IsPresent
396+
-WaitForDebugger:$WaitForDebugger.IsPresent `
397+
-FeatureFlags $FeatureFlags
396398

397399
Set-PipeFileResult $resultDetails "languageServiceReadPipeName" $LanguageServiceInPipeName
398400
Set-PipeFileResult $resultDetails "languageServiceWritePipeName" $LanguageServiceOutPipeName
@@ -417,7 +419,8 @@ try {
417419
-BundledModulesPath $BundledModulesPath `
418420
-EnableConsoleRepl:$EnableConsoleRepl.IsPresent `
419421
-DebugServiceOnly:$DebugServiceOnly.IsPresent `
420-
-WaitForDebugger:$WaitForDebugger.IsPresent
422+
-WaitForDebugger:$WaitForDebugger.IsPresent `
423+
-FeatureFlags $FeatureFlags
421424

422425
Set-PipeFileResult $resultDetails "languageServicePipeName" $LanguageServicePipeName
423426
Set-PipeFileResult $resultDetails "debugServicePipeName" $DebugServicePipeName

modules.json

+5
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
"MinimumVersion":"1.0",
99
"MaximumVersion":"1.99",
1010
"AllowPrerelease":false
11+
},
12+
"PSReadLine":{
13+
"MinimumVersion":"2.0.0-beta3",
14+
"MaximumVersion":"2.1",
15+
"AllowPrerelease":true
1116
}
1217
}

scripts/travis.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
$ErrorActionPreference = 'Stop'
22

33
# Install InvokeBuild
44
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force

src/PowerShellEditorServices.Channel.WebSocket/WebsocketClientChannel.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public WebsocketClientChannel(string url)
3939
this.serverUrl = url;
4040
}
4141

42-
public override async Task WaitForConnection()
42+
public override async Task WaitForConnectionAsync()
4343
{
4444
try
4545
{
@@ -52,7 +52,7 @@ public override async Task WaitForConnection()
5252
{
5353
Logger.Write(LogLevel.Warning,
5454
string.Format("Failed to connect to WebSocket server. Error was '{0}'", wsException.Message));
55-
55+
5656
}
5757

5858
throw;
@@ -99,7 +99,7 @@ protected override void Shutdown()
9999
}
100100

101101
/// <summary>
102-
/// Extension of <see cref="MemoryStream"/> that sends data to a WebSocket during FlushAsync
102+
/// Extension of <see cref="MemoryStream"/> that sends data to a WebSocket during FlushAsync
103103
/// and reads during WriteAsync.
104104
/// </summary>
105105
internal class ClientWebSocketStream : MemoryStream
@@ -110,7 +110,7 @@ internal class ClientWebSocketStream : MemoryStream
110110
/// Constructor
111111
/// </summary>
112112
/// <remarks>
113-
/// It is expected that the socket is in an Open state.
113+
/// It is expected that the socket is in an Open state.
114114
/// </remarks>
115115
/// <param name="socket"></param>
116116
public ClientWebSocketStream(ClientWebSocket socket)
@@ -119,7 +119,7 @@ public ClientWebSocketStream(ClientWebSocket socket)
119119
}
120120

121121
/// <summary>
122-
/// Reads from the WebSocket.
122+
/// Reads from the WebSocket.
123123
/// </summary>
124124
/// <param name="buffer"></param>
125125
/// <param name="offset"></param>
@@ -138,7 +138,7 @@ public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
138138
{
139139
result = await socket.ReceiveAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
140140
} while (!result.EndOfMessage);
141-
141+
142142
if (result.MessageType == WebSocketMessageType.Close)
143143
{
144144
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", cancellationToken);

src/PowerShellEditorServices.Channel.WebSocket/WebsocketServerChannel.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
namespace Microsoft.PowerShell.EditorServices.Channel.WebSocket
1818
{
1919
/// <summary>
20-
/// Implementation of <see cref="ChannelBase"/> that implements the streams necessary for
21-
/// communicating via OWIN WebSockets.
20+
/// Implementation of <see cref="ChannelBase"/> that implements the streams necessary for
21+
/// communicating via OWIN WebSockets.
2222
/// </summary>
2323
public class WebSocketServerChannel : ChannelBase
2424
{
@@ -42,22 +42,22 @@ protected override void Initialize(IMessageSerializer messageSerializer)
4242

4343
this.MessageWriter =
4444
new MessageWriter(
45-
new WebSocketStream(socketConnection),
45+
new WebSocketStream(socketConnection),
4646
messageSerializer);
4747
}
4848

4949
/// <summary>
50-
/// Dispatches data received during calls to OnMessageReceived in the <see cref="WebSocketConnection"/> class.
50+
/// Dispatches data received during calls to OnMessageReceivedAsync in the <see cref="WebSocketConnection"/> class.
5151
/// </summary>
5252
/// <remarks>
53-
/// This method calls an overriden version of the <see cref="MessageDispatcher"/> that dispatches messages on
54-
/// demand rather than running on a background thread.
53+
/// This method calls an overriden version of the <see cref="MessageDispatcher"/> that dispatches messages on
54+
/// demand rather than running on a background thread.
5555
/// </remarks>
5656
/// <param name="message"></param>
5757
/// <returns></returns>
58-
public async Task Dispatch(ArraySegment<byte> message)
58+
public async Task DispatchAsync(ArraySegment<byte> message)
5959
{
60-
//Clear our stream
60+
//Clear our stream
6161
inStream.SetLength(0);
6262

6363
//Write data and dispatch to handlers
@@ -70,19 +70,19 @@ protected override void Shutdown()
7070
this.socketConnection.Close(WebSocketCloseStatus.NormalClosure, "Server shutting down");
7171
}
7272

73-
public override Task WaitForConnection()
73+
public override Task WaitForConnectionAsync()
7474
{
7575
// TODO: Need to update behavior here
7676
return Task.FromResult(true);
7777
}
7878
}
7979

8080
/// <summary>
81-
/// Overriden <see cref="MemoryStream"/> that sends data through a <see cref="WebSocketConnection"/> during the FlushAsync call.
81+
/// Overriden <see cref="MemoryStream"/> that sends data through a <see cref="WebSocketConnection"/> during the FlushAsync call.
8282
/// </summary>
8383
/// <remarks>
8484
/// FlushAsync will send data via the SendBinary method of the <see cref="WebSocketConnection"/> class. The memory streams length will
85-
/// then be set to 0 to reset the stream for additional data to be written.
85+
/// then be set to 0 to reset the stream for additional data to be written.
8686
/// </remarks>
8787
internal class WebSocketStream : MemoryStream
8888
{
@@ -106,7 +106,7 @@ public override async Task FlushAsync(CancellationToken cancellationToken)
106106
/// </summary>
107107
public abstract class EditorServiceWebSocketConnection : WebSocketConnection
108108
{
109-
protected EditorServiceWebSocketConnection()
109+
protected EditorServiceWebSocketConnection()
110110
{
111111
Channel = new WebSocketServerChannel(this);
112112
}
@@ -120,9 +120,9 @@ public override void OnOpen()
120120
Server.Start();
121121
}
122122

123-
public override async Task OnMessageReceived(ArraySegment<byte> message, WebSocketMessageType type)
123+
public override async Task OnMessageReceivedAsync(ArraySegment<byte> message, WebSocketMessageType type)
124124
{
125-
await Channel.Dispatch(message);
125+
await Channel.DispatchAsync(message);
126126
}
127127

128128
public override Task OnCloseAsync(WebSocketCloseStatus? closeStatus, string closeStatusDescription)

src/PowerShellEditorServices.Host/CodeLens/CodeLensFeature.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public static CodeLensFeature Create(
4949

5050
messageHandlers.SetRequestHandler(
5151
CodeLensRequest.Type,
52-
codeLenses.HandleCodeLensRequest);
52+
codeLenses.HandleCodeLensRequestAsync);
5353

5454
messageHandlers.SetRequestHandler(
5555
CodeLensResolveRequest.Type,
56-
codeLenses.HandleCodeLensResolveRequest);
56+
codeLenses.HandleCodeLensResolveRequestAsync);
5757

5858
codeLenses.Providers.Add(
5959
new ReferencesCodeLensProvider(
@@ -111,7 +111,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile)
111111
/// </summary>
112112
/// <param name="codeLensParams">Parameters on the CodeLens request that was received.</param>
113113
/// <param name="requestContext"></param>
114-
private async Task HandleCodeLensRequest(
114+
private async Task HandleCodeLensRequestAsync(
115115
CodeLensRequest codeLensParams,
116116
RequestContext<LanguageServer.CodeLens[]> requestContext)
117117
{
@@ -132,15 +132,15 @@ private async Task HandleCodeLensRequest(
132132
_jsonSerializer);
133133
}
134134

135-
await requestContext.SendResult(codeLensResponse);
135+
await requestContext.SendResultAsync(codeLensResponse);
136136
}
137137

138138
/// <summary>
139139
/// Handle a CodeLens resolve request from VSCode.
140140
/// </summary>
141141
/// <param name="codeLens">The CodeLens to be resolved/updated.</param>
142142
/// <param name="requestContext"></param>
143-
private async Task HandleCodeLensResolveRequest(
143+
private async Task HandleCodeLensResolveRequestAsync(
144144
LanguageServer.CodeLens codeLens,
145145
RequestContext<LanguageServer.CodeLens> requestContext)
146146
{
@@ -178,13 +178,13 @@ await originalProvider.ResolveCodeLensAsync(
178178
originalCodeLens,
179179
CancellationToken.None);
180180

181-
await requestContext.SendResult(
181+
await requestContext.SendResultAsync(
182182
resolvedCodeLens.ToProtocolCodeLens(
183183
_jsonSerializer));
184184
}
185185
else
186186
{
187-
await requestContext.SendError(
187+
await requestContext.SendErrorAsync(
188188
$"Could not find provider for the original CodeLens: {codeLensData.ProviderId}");
189189
}
190190
}

src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public async Task<CodeLens> ResolveCodeLensAsync(
8282
codeLens.ScriptExtent.StartLineNumber,
8383
codeLens.ScriptExtent.StartColumnNumber);
8484

85-
FindReferencesResult referencesResult = await _editorSession.LanguageService.FindReferencesOfSymbol(
85+
FindReferencesResult referencesResult = await _editorSession.LanguageService.FindReferencesOfSymbolAsync(
8686
foundSymbol,
8787
references,
8888
_editorSession.Workspace);

0 commit comments

Comments
 (0)