Skip to content

Commit 7bf4299

Browse files
Merge pull request #1459 from PowerShell/async-ps-consumer
Reimplement the way PowerShell is run and hosted in PSES with a dedicated pipeline thread consumer
2 parents 14095b4 + 548fdda commit 7bf4299

File tree

188 files changed

+6177
-12029
lines changed

Some content is hidden

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

188 files changed

+6177
-12029
lines changed

.vsts-ci/azure-pipelines-ci.yml

-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ variables:
88
- name: DOTNET_CLI_TELEMETRY_OPTOUT
99
value: 'true'
1010

11-
trigger:
12-
branches:
13-
include:
14-
- master
15-
16-
pr:
17-
- master
18-
1911
jobs:
2012
- job: PS51_Win2016
2113
displayName: PowerShell 5.1 - Windows Server 2016

CHANGELOG.md

+75
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
11
# PowerShell Editor Services Release History
22

3+
## v3.0.0
4+
### Thursday, October 28, 2021
5+
6+
This preview release includes a complete overhaul of the core PowerShell engine
7+
of PowerShell Editor Services.
8+
This represents over a year's work,
9+
tracked in [PSES #1295](https://github.com/PowerShell/PowerShellEditorServices/issues/1295)
10+
and implemented in [PSES #1459](https://github.com/PowerShell/PowerShellEditorServices/pull/1459),
11+
and is our answer to many, many issues
12+
opened by users over the last few years.
13+
We're hoping you'll see a marked improvement
14+
in the reliability, performance and footprint
15+
of the extension as a result.
16+
17+
Previously the Integrated Console was run
18+
by setting threadpool tasks on a shared main runspace,
19+
and where LSP servicing was done with PowerShell idle events.
20+
This lead to overhead, threading issues
21+
and a complex implementation intended to work around
22+
the asymmetry between PowerShell as a synchronous,
23+
single-threaded runtime and a language server
24+
as an asynchronous, multi-threaded service.
25+
26+
Now, PowerShell Editor Services maintains its own dedicated pipeline thread,
27+
which is able to service requests similar to JavaScript's event loop,
28+
meaning we can run everything synchronously on the correct thread.
29+
We also get more efficiency because we can directly call
30+
PowerShell APIs and code written in C# from this thread,
31+
without the overhead of a PowerShell pipeline.
32+
33+
This change has overhauled how we service LSP requests,
34+
how the Integrated Console works,
35+
how PSReadLine is integrated,
36+
how debugging is implemented,
37+
how remoting is handled,
38+
and a long tail of other features in PowerShell Editor Services.
39+
40+
Also, in making it, while 6,000 lines of code were added,
41+
we removed 12,000,
42+
for a more maintainable, more efficient
43+
and easier to understand extension backend.
44+
45+
While most of our testing has been re-enabled
46+
(and we're working on adding more),
47+
there are bound to be issues with this new implementation.
48+
Please give this a try and let us know if you run into anything.
49+
50+
We also want to thank [@SeeminglyScience](https://github.com/SeeminglyScience)
51+
for his help and knowledge as we've made this migration.
52+
53+
Finally, a crude breakdown of the work from the commits:
54+
55+
- An initial dedicated pipeline thread consumer implementation
56+
- Implement the console REPL
57+
- Implement PSRL idle handling
58+
- Implement completions
59+
- Move to invoking PSRL as a C# delegate
60+
- Implement cancellation and <kbd>Ctrl</kbd>+<kbd>C</kbd>
61+
- Make <kbd>F8</kbd> work again
62+
- Ensure execution policy is set correctly
63+
- Implement $PROFILE support
64+
- Make nested prompts work
65+
- Implement REPL debugging
66+
- Implement remote debugging in the REPL
67+
- Hook up the debugging UI
68+
- Implement a new concurrent priority queue for PowerShell tasks
69+
- Reimplement the REPL synchronously rather than on its own thread
70+
- Really get debugging working...
71+
- Implement DSC breakpoint support
72+
- Reimplement legacy readline support
73+
- Ensure stdio is still supported as an LSP transport
74+
- Remove PowerShellContextService and other defunct code
75+
- Get integration tests working again (and improve diagnosis of PSES failures)
76+
- Get unit testing working again (except debug service tests)
77+
378
## v2.5.2
479
### Monday, October 18, 2021
580

PowerShellEditorServices.Common.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>2.5.2</VersionPrefix>
3+
<VersionPrefix>3.0.0</VersionPrefix>
44
<VersionSuffix></VersionSuffix>
55
<Company>Microsoft</Company>
66
<Copyright>© Microsoft Corporation.</Copyright>

module/PowerShellEditorServices/PowerShellEditorServices.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RootModule = if ($PSEdition -eq 'Core')
1919
}
2020

2121
# Version number of this module.
22-
ModuleVersion = '2.5.2'
22+
ModuleVersion = '3.0.0'
2323

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

modules.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"Version": "1.1.3"
77
},
88
"PSReadLine": {
9-
"Version": "2.1.0"
9+
"Version": "2.2.0-beta4",
10+
"AllowPrerelease": true
1011
}
1112
}

src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineConstructorCommand.cs

-21
This file was deleted.

src/PowerShellEditorServices.Hosting/Commands/InvokeReadLineForEditorServicesCommand.cs

-53
This file was deleted.

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ public static EditorServicesLoader Create(
120120
{
121121
AppDomain.CurrentDomain.AssemblyLoad += (object sender, AssemblyLoadEventArgs args) =>
122122
{
123+
if (args.LoadedAssembly.IsDynamic)
124+
{
125+
return;
126+
}
127+
123128
logger.Log(
124129
PsesLogLevel.Diagnostic,
125130
$"Loaded '{args.LoadedAssembly.GetName()}' from '{args.LoadedAssembly.Location}'");

src/PowerShellEditorServices/Extensions/Api/EditorContextService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Threading;
66
using System.Threading.Tasks;
7-
using Microsoft.PowerShell.EditorServices.Handlers;
7+
using Microsoft.PowerShell.EditorServices.Services.Extension;
88
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
99

1010
namespace Microsoft.PowerShell.EditorServices.Extensions.Services

src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Linq.Expressions;
66
using System.Reflection;
77
using Microsoft.Extensions.DependencyInjection;
8-
using Microsoft.PowerShell.EditorServices.Services;
8+
using Microsoft.PowerShell.EditorServices.Services.Extension;
99
using Microsoft.PowerShell.EditorServices.Utility;
1010
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
1111

src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Linq;
77
using System.Threading;
88
using System.Threading.Tasks;
9-
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
9+
using Microsoft.PowerShell.EditorServices.Services.Extension;
1010
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
1111

1212
namespace Microsoft.PowerShell.EditorServices.Extensions.Services
@@ -116,7 +116,9 @@ public async Task<string> PromptInputAsync(string message)
116116
new ShowInputPromptRequest
117117
{
118118
Name = message,
119-
}).Returning<ShowInputPromptResponse>(CancellationToken.None).ConfigureAwait(false);
119+
})
120+
.Returning<ShowInputPromptResponse>(CancellationToken.None)
121+
.ConfigureAwait(false);
120122

121123
if (response.PromptCancelled)
122124
{
@@ -142,7 +144,9 @@ public async Task<IReadOnlyList<string>> PromptMultipleSelectionAsync(string mes
142144
Message = message,
143145
Choices = choiceDetails,
144146
DefaultChoices = defaultChoiceIndexes?.ToArray(),
145-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
147+
})
148+
.Returning<ShowChoicePromptResponse>(CancellationToken.None)
149+
.ConfigureAwait(false);
146150

147151
if (response.PromptCancelled)
148152
{
@@ -168,7 +172,9 @@ public async Task<string> PromptSelectionAsync(string message, IReadOnlyList<Pro
168172
Message = message,
169173
Choices = choiceDetails,
170174
DefaultChoices = defaultChoiceIndex > -1 ? new[] { defaultChoiceIndex } : null,
171-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
175+
})
176+
.Returning<ShowChoicePromptResponse>(CancellationToken.None)
177+
.ConfigureAwait(false);
172178

173179
if (response.PromptCancelled)
174180
{

src/PowerShellEditorServices/Extensions/Api/ExtensionCommandService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using Microsoft.PowerShell.EditorServices.Services;
4+
using Microsoft.PowerShell.EditorServices.Services.Extension;
55
using System;
66
using System.Collections.Generic;
77
using System.Threading.Tasks;

src/PowerShellEditorServices/Extensions/Api/LanguageServerService.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using MediatR;
54
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
65
using System.Threading;
76
using System.Threading.Tasks;

src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Management.Automation.Language;
8-
using System.Threading.Tasks;
98

109
namespace Microsoft.PowerShell.EditorServices.Extensions.Services
1110
{

src/PowerShellEditorServices/Extensions/EditorContext.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using System;
54
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
65

76
namespace Microsoft.PowerShell.EditorServices.Extensions

src/PowerShellEditorServices/Extensions/EditorFileRanges.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using Microsoft.PowerShell.EditorServices.Handlers;
4+
using Microsoft.PowerShell.EditorServices.Services.Extension;
55
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
66
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
77
using System;

src/PowerShellEditorServices/Extensions/EditorObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Reflection;
66
using System.Threading.Tasks;
77
using Microsoft.PowerShell.EditorServices.Extensions.Services;
8-
using Microsoft.PowerShell.EditorServices.Services;
8+
using Microsoft.PowerShell.EditorServices.Services.Extension;
99

1010
namespace Microsoft.PowerShell.EditorServices.Extensions
1111
{

src/PowerShellEditorServices/Extensions/EditorWorkspace.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using System.Threading.Tasks;
5-
64
namespace Microsoft.PowerShell.EditorServices.Extensions
75
{
86
/// <summary>

src/PowerShellEditorServices/Hosting/EditorServicesServerFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
using Microsoft.Extensions.Logging;
99
using Microsoft.PowerShell.EditorServices.Logging;
1010
using Microsoft.PowerShell.EditorServices.Server;
11-
using Microsoft.PowerShell.EditorServices.Services;
1211
using Serilog;
1312
using Serilog.Events;
1413
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
14+
using Microsoft.PowerShell.EditorServices.Services.Extension;
1515

1616
#if DEBUG
1717
using Serilog.Debugging;

src/PowerShellEditorServices/Logging/HostLoggerAdapter.cs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using Microsoft.Extensions.Logging;
55
using System;
6-
using System.Collections.Generic;
7-
using System.Text;
86

97
namespace Microsoft.PowerShell.EditorServices.Logging
108
{

src/PowerShellEditorServices/PowerShellEditorServices.csproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
</ItemGroup>
4343

4444
<ItemGroup>
45-
<Compile Remove="Extensions\Api\DocumentSymbolService.cs"/>
45+
<Compile Remove="Extensions\Api\DocumentSymbolService.cs" />
46+
<Compile Remove="Services\Extension\Templating\**" />
47+
<EmbeddedResource Remove="Services\Extension\Templating\**" />
48+
<None Remove="Services\Extension\Templating\**" />
4649
</ItemGroup>
4750
</Project>

0 commit comments

Comments
 (0)