From 11d6aeec78616d64477da10ffb413485ac73fbec Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 22:23:34 +0000 Subject: [PATCH 01/32] Bump OmniSharp.Extensions.LanguageServer from 0.18.3 to 0.19.0 Bumps [OmniSharp.Extensions.LanguageServer](https://github.com/OmniSharp/csharp-language-server-protocol) from 0.18.3 to 0.19.0. - [Release notes](https://github.com/OmniSharp/csharp-language-server-protocol/releases) - [Changelog](https://github.com/OmniSharp/csharp-language-server-protocol/blob/master/GitReleaseManager.yaml) - [Commits](https://github.com/OmniSharp/csharp-language-server-protocol/compare/v0.18.3...v0.19.0) Signed-off-by: dependabot-preview[bot] --- src/PowerShellEditorServices/PowerShellEditorServices.csproj | 2 +- .../PowerShellEditorServices.Test.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 345e928c1..773059aee 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -39,7 +39,7 @@ - + diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 6f47ad923..4410289fc 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -27,7 +27,7 @@ - + From cf349c63780b8db1fe1f983193ab6b33974cdedd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 00:40:11 +0000 Subject: [PATCH 02/32] Bump OmniSharp.Extensions.DebugAdapter.Client from 0.18.3 to 0.19.0 Bumps [OmniSharp.Extensions.DebugAdapter.Client](https://github.com/OmniSharp/csharp-language-server-protocol) from 0.18.3 to 0.19.0. - [Release notes](https://github.com/OmniSharp/csharp-language-server-protocol/releases) - [Changelog](https://github.com/OmniSharp/csharp-language-server-protocol/blob/master/GitReleaseManager.yaml) - [Commits](https://github.com/OmniSharp/csharp-language-server-protocol/compare/v0.18.3...v0.19.0) Signed-off-by: dependabot-preview[bot] --- .../PowerShellEditorServices.Test.E2E.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 837a6a8fd..097934e01 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -10,7 +10,7 @@ - + From f1df5ba323ee89a4b76e20c3729f07d16eeea637 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 00:40:12 +0000 Subject: [PATCH 03/32] Bump OmniSharp.Extensions.LanguageClient from 0.18.3 to 0.19.0 Bumps [OmniSharp.Extensions.LanguageClient](https://github.com/OmniSharp/csharp-language-server-protocol) from 0.18.3 to 0.19.0. - [Release notes](https://github.com/OmniSharp/csharp-language-server-protocol/releases) - [Changelog](https://github.com/OmniSharp/csharp-language-server-protocol/blob/master/GitReleaseManager.yaml) - [Commits](https://github.com/OmniSharp/csharp-language-server-protocol/compare/v0.18.3...v0.19.0) Signed-off-by: dependabot-preview[bot] --- .../PowerShellEditorServices.Test.E2E.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 097934e01..baa14a84e 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -9,7 +9,7 @@ - + From d4d7216ea28a4561c3c3e05568a60cfa82d3f5de Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 8 Mar 2021 15:46:50 -0800 Subject: [PATCH 04/32] Bump OmniSharp.Extensions.DebugAdapter.Server from 0.18.3 to 0.19.0 --- src/PowerShellEditorServices/PowerShellEditorServices.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 773059aee..0cf5474aa 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -40,7 +40,7 @@ - + From fbcdc2351443ebd11368a95d5595a96e54318845 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 24 Mar 2021 16:11:10 -0700 Subject: [PATCH 05/32] Bump tests' dependency on xUnit to 2.4.1 (not pre-release) --- .../PowerShellEditorServices.Test.E2E.csproj | 2 +- .../PowerShellEditorServices.Test.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index baa14a84e..c06cb976c 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 4410289fc..aff271a6a 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -24,7 +24,7 @@ - + From 5e92f612a0504b4d2817ad94c1db04fb530e5d07 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 17:51:13 -0800 Subject: [PATCH 06/32] Fix missing update to `PowerShellStandard.Library` 5.1.1 --- .../PowerShellEditorServices.VSCode.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj b/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj index fc5fc85dd..b6022679f 100644 --- a/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj +++ b/src/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.csproj @@ -17,7 +17,7 @@ - + All From 2dcd995e3d4da2ba569ade6678b22862ef907623 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 8 Mar 2021 15:26:40 -0800 Subject: [PATCH 07/32] Fix rename of `Serializer` to `LspSerializer` --- .../Services/CodeLens/PesterCodeLensProvider.cs | 8 ++++---- .../Services/CodeLens/ReferencesCodeLensProvider.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs index e6e025286..5aa1a349c 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs @@ -55,7 +55,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile Data = JToken.FromObject(new { Uri = scriptFile.DocumentUri, ProviderId = nameof(PesterCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Command = new Command() { Name = "PowerShell.RunPesterTests", @@ -66,7 +66,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile false /* No debug */, pesterSymbol.TestName, pesterSymbol.ScriptRegion?.StartLineNumber - }, Serializer.Instance.JsonSerializer) + }, LspSerializer.Instance.JsonSerializer) } }, @@ -76,7 +76,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile Data = JToken.FromObject(new { Uri = scriptFile.DocumentUri, ProviderId = nameof(PesterCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Command = new Command() { Name = "PowerShell.RunPesterTests", @@ -88,7 +88,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile pesterSymbol.TestName, pesterSymbol.ScriptRegion?.StartLineNumber }, - Serializer.Instance.JsonSerializer) + LspSerializer.Instance.JsonSerializer) } } }; diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index f630c7979..1277bcb7f 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs @@ -68,7 +68,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile) { Uri = scriptFile.DocumentUri, ProviderId = nameof(ReferencesCodeLensProvider) - }, Serializer.Instance.JsonSerializer), + }, LspSerializer.Instance.JsonSerializer), Range = sym.ScriptRegion.ToRange() }); } @@ -145,7 +145,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) codeLens.Range.Start, referenceLocations }, - Serializer.Instance.JsonSerializer) + LspSerializer.Instance.JsonSerializer) } }; } From 571b8c5c89cbb166a9d38a24de18b133ce1b92d7 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:08:39 -0800 Subject: [PATCH 08/32] `AddLanguageProtocolLogging` no longer takes a log level argument --- src/PowerShellEditorServices/Server/PsesLanguageServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs index 52eb2dec4..0626f1235 100644 --- a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs +++ b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs @@ -67,7 +67,7 @@ public async Task StartAsync() .AddPsesLanguageServices(_hostDetails)) .ConfigureLogging(builder => builder .AddSerilog(Log.Logger) - .AddLanguageProtocolLogging(_minimumLogLevel) + .AddLanguageProtocolLogging() .SetMinimumLevel(_minimumLogLevel)) .WithHandler() .WithHandler() From 65e232fe3f84288dd613750c755ba343d1f2e792 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:12:56 -0800 Subject: [PATCH 09/32] Fix creation of `Breakpoint` since `Verified` is init-only now --- .../Services/DebugAdapter/DebugEventHandlerService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs b/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs index d91295d76..1a49277fc 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/DebugEventHandlerService.cs @@ -146,7 +146,11 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven break; } - OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint; + var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint + { + Verified = e.UpdateType != BreakpointUpdateType.Disabled + }; + if (e.Breakpoint is LineBreakpoint) { breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint)); @@ -162,8 +166,6 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven return; } - breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled; - _debugAdapterServer.SendNotification(EventNames.Breakpoint, new BreakpointEvent { From d808201e8fb33c3cc7c81b5730baec4446d9a3e3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:15:23 -0800 Subject: [PATCH 10/32] Fix use of `ContinueHandlerBase` (has `Base` suffix now) --- .../Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs index fd5a4f9ba..1f3322e88 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebuggerActionHandlers.cs @@ -13,6 +13,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Inherit from ABCs instead of satisfying interfaces. internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler { private readonly ILogger _logger; @@ -22,7 +23,7 @@ public DebuggerActionHandlers( ILoggerFactory loggerFactory, DebugService debugService) { - _logger = loggerFactory.CreateLogger(); + _logger = loggerFactory.CreateLogger(); _debugService = debugService; } From d518f1f63e542c10ecdd7688774efa3aa8964541 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:16:07 -0800 Subject: [PATCH 11/32] Fix use of `LaunchRequestArguments` and `AttachRequestArguments` (now a `record`) --- .../Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs index 0f065baa8..954dc6b0e 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs @@ -22,7 +22,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesLaunchRequestArguments : LaunchRequestArguments + internal record PsesLaunchRequestArguments : LaunchRequestArguments { /// /// Gets or sets the absolute path to the script to debug. @@ -70,7 +70,7 @@ internal class PsesLaunchRequestArguments : LaunchRequestArguments public Dictionary Env { get; set; } } - internal class PsesAttachRequestArguments : AttachRequestArguments + internal record PsesAttachRequestArguments : AttachRequestArguments { public string ComputerName { get; set; } From 327061fbc56bd484df030296bee82dd77748c1d7 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:18:00 -0800 Subject: [PATCH 12/32] Fix use of `ThreadsResponse` (type changed for threads container) --- .../Services/DebugAdapter/Handlers/ThreadsHandler.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs index 800494a2a..f788f3b9c 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ThreadsHandler.cs @@ -16,13 +16,8 @@ public Task Handle(ThreadsArguments request, CancellationToken { return Task.FromResult(new ThreadsResponse { - // TODO: What do I do with these? - Threads = new Container( - new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread - { - Id = 1, - Name = "Main Thread" - }) + // TODO: This is an empty container of threads...do we need to make a thread? + Threads = new Container() }); } } From c8fac5db67635571cd25ede5b3d86caeb63d4c09 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:20:07 -0800 Subject: [PATCH 13/32] Remove use of `Proposals` (gone) --- .../TextDocument/Handlers/PsesSemanticTokensHandler.cs | 5 ++--- .../Services/TextDocument/SemanticToken.cs | 2 +- .../LanguageServerProtocolMessageTests.cs | 1 - .../Language/SemanticTokenTest.cs | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs index eacd4665e..7dfea1603 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // @@ -13,9 +13,8 @@ using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Utility; using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; -using OmniSharp.Extensions.LanguageServer.Protocol.Document.Proposals; +using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; namespace Microsoft.PowerShell.EditorServices.Handlers { diff --git a/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs b/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs index a687690b2..c777af4f5 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; +using OmniSharp.Extensions.LanguageServer.Protocol.Models; namespace Microsoft.PowerShell.EditorServices.Services.TextDocument { diff --git a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs index d2b68d302..f69bfeb03 100644 --- a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs @@ -21,7 +21,6 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Workspace; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; using Xunit; using Xunit.Abstractions; using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; diff --git a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs index 7d074557d..01ed9e046 100644 --- a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs +++ b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs @@ -11,7 +11,6 @@ using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Handlers; using OmniSharp.Extensions.LanguageServer.Protocol; -using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals; using Xunit; namespace Microsoft.PowerShell.EditorServices.Test.Language From 017b1ca7b2d0edc7deefc1cb2607cceb1df4cd20 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:20:46 -0800 Subject: [PATCH 14/32] Convert `PsesCodeActionHandler` to inherit `CodeActionHandlerBase` --- .../Handlers/CodeActionHandler.cs | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs index fc57045dd..4f6d23563 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs @@ -19,46 +19,37 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesCodeActionHandler : ICodeActionHandler + internal class PsesCodeActionHandler : CodeActionHandlerBase { - private static readonly CodeActionKind[] s_supportedCodeActions = new[] - { - CodeActionKind.QuickFix - }; - - private readonly CodeActionRegistrationOptions _registrationOptions; - private readonly ILogger _logger; - private readonly AnalysisService _analysisService; - private readonly WorkspaceService _workspaceService; - private CodeActionCapability _capability; - public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisService, WorkspaceService workspaceService) { _logger = factory.CreateLogger(); _analysisService = analysisService; _workspaceService = workspaceService; - _registrationOptions = new CodeActionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - CodeActionKinds = s_supportedCodeActions - }; } - public CodeActionRegistrationOptions GetRegistrationOptions() - { - return _registrationOptions; - } + protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions + { + // TODO: What do we do with the arguments? + DocumentSelector = LspUtils.PowerShellDocumentSelector, + CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix } + }; - public void SetCapability(CodeActionCapability capability) + public override async Task Handle(CodeAction request, CancellationToken cancellationToken) { - _capability = capability; + // TODO: How on earth do we handle a CodeAction? This is new... + if (cancellationToken.IsCancellationRequested) + { + _logger.LogDebug("CodeAction request canceled for: {0}", request.Title); + } + return request; } - public async Task Handle(CodeActionParams request, CancellationToken cancellationToken) + public override async Task Handle(CodeActionParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -101,7 +92,7 @@ public async Task Handle(CodeActionParams request, new WorkspaceEditDocumentChange( new TextDocumentEdit { - TextDocument = new VersionedTextDocumentIdentifier + TextDocument = new OptionalVersionedTextDocumentIdentifier { Uri = request.TextDocument.Uri }, From fa979b3bb48cc6734fff27e06017a6f4b73297ff Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:29:50 -0800 Subject: [PATCH 15/32] Convert `PsesDocumentSymbolHandler` to inherit `DocumentSymbolHandlerBase` --- .../Handlers/DocumentSymbolHandler.cs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs index a62985be5..a75271e37 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs @@ -23,15 +23,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDocumentSymbolHandler : IDocumentSymbolHandler + internal class PsesDocumentSymbolHandler : DocumentSymbolHandlerBase { private readonly ILogger _logger; private readonly WorkspaceService _workspaceService; - private readonly IDocumentSymbolProvider[] _providers; - private DocumentSymbolCapability _capability; - public PsesDocumentSymbolHandler(ILoggerFactory factory, ConfigurationService configurationService, WorkspaceService workspaceService) { _logger = factory.CreateLogger(); @@ -44,15 +41,12 @@ public PsesDocumentSymbolHandler(ILoggerFactory factory, ConfigurationService co }; } - public DocumentSymbolRegistrationOptions GetRegistrationOptions() + protected override DocumentSymbolRegistrationOptions CreateRegistrationOptions(DocumentSymbolCapability capability, ClientCapabilities clientCapabilities) => new DocumentSymbolRegistrationOptions { - return new DocumentSymbolRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle(DocumentSymbolParams request, CancellationToken cancellationToken) + public override Task Handle(DocumentSymbolParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -92,11 +86,6 @@ public Task Handle(DocumentSymbolPar return Task.FromResult(new SymbolInformationOrDocumentSymbolContainer(symbols)); } - public void SetCapability(DocumentSymbolCapability capability) - { - _capability = capability; - } - private IEnumerable ProvideDocumentSymbols( ScriptFile scriptFile) { From 93b2ec000e90eb0d8a79a6b956dccd83ebb1e6ae Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:31:06 -0800 Subject: [PATCH 16/32] Convert `PsesFoldingRangeHandler` to inherit `FoldingRangeHandlerBase` --- .../Handlers/FoldingRangeHandler.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs index 6ec951691..daf0c70dc 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FoldingRangeHandler.cs @@ -16,30 +16,25 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesFoldingRangeHandler : IFoldingRangeHandler + internal class PsesFoldingRangeHandler : FoldingRangeHandlerBase { private readonly ILogger _logger; private readonly ConfigurationService _configurationService; private readonly WorkspaceService _workspaceService; - private FoldingRangeCapability _capability; - public PsesFoldingRangeHandler(ILoggerFactory factory, ConfigurationService configurationService, WorkspaceService workspaceService) { - _logger = factory.CreateLogger(); + _logger = factory.CreateLogger(); _configurationService = configurationService; _workspaceService = workspaceService; } - public FoldingRangeRegistrationOptions GetRegistrationOptions() + protected override FoldingRangeRegistrationOptions CreateRegistrationOptions(FoldingRangeCapability capability, ClientCapabilities clientCapabilities) => new FoldingRangeRegistrationOptions { - return new FoldingRangeRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task> Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) + public override Task> Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -75,10 +70,5 @@ public Task> Handle(FoldingRangeRequestParam request, Ca return Task.FromResult(new Container(result)); } - - public void SetCapability(FoldingRangeCapability capability) - { - _capability = capability; - } } } From d02193df61d491dbfbdec047b5cc83f59fc6249e Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:31:42 -0800 Subject: [PATCH 17/32] Fix registration for `PsesSemanticTokensHandler` --- .../TextDocument/Handlers/PsesSemanticTokensHandler.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs index 7dfea1603..48658185d 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // @@ -20,7 +20,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase { - private static readonly SemanticTokensRegistrationOptions s_registrationOptions = new SemanticTokensRegistrationOptions + protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(SemanticTokensCapability capability, ClientCapabilities clientCapabilities) => new SemanticTokensRegistrationOptions { DocumentSelector = LspUtils.PowerShellDocumentSelector, Legend = new SemanticTokensLegend(), @@ -35,7 +35,6 @@ internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase private readonly WorkspaceService _workspaceService; public PsesSemanticTokensHandler(ILogger logger, WorkspaceService workspaceService) - : base(s_registrationOptions) { _logger = logger; _workspaceService = workspaceService; @@ -160,7 +159,7 @@ protected override Task GetSemanticTokensDocument( ITextDocumentIdentifierParams @params, CancellationToken cancellationToken) { - return Task.FromResult(new SemanticTokensDocument(GetRegistrationOptions().Legend)); + return Task.FromResult(new SemanticTokensDocument(RegistrationOptions.Legend)); } } } From c5e66688da97e81c3316e7a36e5414b25e06d8cf Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:33:08 -0800 Subject: [PATCH 18/32] Convert `PsesReferencesHandler` to inherit `ReferencesHandlerBase` --- .../Handlers/ReferencesHandler.cs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs index 2801a4d86..25af2a264 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/ReferencesHandler.cs @@ -18,12 +18,11 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - class PsesReferencesHandler : IReferencesHandler + class PsesReferencesHandler : ReferencesHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private ReferenceCapability _capability; public PsesReferencesHandler(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService) { @@ -32,15 +31,12 @@ public PsesReferencesHandler(ILoggerFactory factory, SymbolsService symbolsServi _workspaceService = workspaceService; } - public ReferenceRegistrationOptions GetRegistrationOptions() + protected override ReferenceRegistrationOptions CreateRegistrationOptions(ReferenceCapability capability, ClientCapabilities clientCapabilities) => new ReferenceRegistrationOptions { - return new ReferenceRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle(ReferenceParams request, CancellationToken cancellationToken) + public override Task Handle(ReferenceParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -73,11 +69,6 @@ public Task Handle(ReferenceParams request, CancellationToken return Task.FromResult(new LocationContainer(locations)); } - public void SetCapability(ReferenceCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range From b311d4e7199eb8a9009bc3e6d1c3febd6e09a760 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:33:32 -0800 Subject: [PATCH 19/32] Convert `PsesTextDocumentHandler` to inherit `TextDocumentSyncHandlerBase` --- .../Handlers/TextDocumentHandler.cs | 49 +++++-------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs index e5961c9a8..061dab98d 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs @@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - class PsesTextDocumentHandler : ITextDocumentSyncHandler + class PsesTextDocumentHandler : TextDocumentSyncHandlerBase { private static readonly Uri s_fakeUri = new Uri("Untitled:fake"); @@ -27,7 +27,6 @@ class PsesTextDocumentHandler : ITextDocumentSyncHandler private readonly AnalysisService _analysisService; private readonly WorkspaceService _workspaceService; private readonly RemoteFileManagerService _remoteFileManagerService; - private SynchronizationCapability _capability; public TextDocumentSyncKind Change => TextDocumentSyncKind.Incremental; @@ -43,7 +42,7 @@ public PsesTextDocumentHandler( _remoteFileManagerService = remoteFileManagerService; } - public Task Handle(DidChangeTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidChangeTextDocumentParams notification, CancellationToken token) { ScriptFile changedFile = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -62,21 +61,14 @@ public Task Handle(DidChangeTextDocumentParams notification, CancellationT return Unit.Task; } - TextDocumentChangeRegistrationOptions IRegistration.GetRegistrationOptions() + protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities) => new TextDocumentSyncRegistrationOptions() { - return new TextDocumentChangeRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - SyncKind = Change - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + Change = Change, + Save = new SaveOptions { IncludeText = true } + }; - public void SetCapability(SynchronizationCapability capability) - { - _capability = capability; - } - - public Task Handle(DidOpenTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidOpenTextDocumentParams notification, CancellationToken token) { ScriptFile openedFile = _workspaceService.GetFileBuffer( @@ -98,15 +90,7 @@ public Task Handle(DidOpenTextDocumentParams notification, CancellationTok return Unit.Task; } - TextDocumentRegistrationOptions IRegistration.GetRegistrationOptions() - { - return new TextDocumentRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - }; - } - - public Task Handle(DidCloseTextDocumentParams notification, CancellationToken token) + public override Task Handle(DidCloseTextDocumentParams notification, CancellationToken token) { // Find and close the file in the current session var fileToClose = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -121,7 +105,7 @@ public Task Handle(DidCloseTextDocumentParams notification, CancellationTo return Unit.Task; } - public async Task Handle(DidSaveTextDocumentParams notification, CancellationToken token) + public override async Task Handle(DidSaveTextDocumentParams notification, CancellationToken token) { ScriptFile savedFile = _workspaceService.GetFile(notification.TextDocument.Uri); @@ -135,18 +119,7 @@ public async Task Handle(DidSaveTextDocumentParams notification, Cancellat return Unit.Value; } - TextDocumentSaveRegistrationOptions IRegistration.GetRegistrationOptions() - { - return new TextDocumentSaveRegistrationOptions() - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - IncludeText = true - }; - } - public TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri) - { - return new TextDocumentAttributes(uri, "powershell"); - } + public override TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri) => new TextDocumentAttributes(uri, "powershell"); private static FileChange GetFileChangeDetails(Range changeRange, string insertString) { From 01366bbc9cfc200f50597db6494a483700ef5540 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 14:54:04 -0800 Subject: [PATCH 20/32] Convert `PsesWorkspaceSymbolsHandler` to inherit `WorkspaceSymbolsHandlerBase` --- .../Workspace/Handlers/WorkspaceSymbolsHandler.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs index 6c972d4e5..d87a22a7b 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs @@ -19,12 +19,11 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesWorkspaceSymbolsHandler : IWorkspaceSymbolsHandler + internal class PsesWorkspaceSymbolsHandler : WorkspaceSymbolsHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private WorkspaceSymbolCapability _capability; public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService symbols, WorkspaceService workspace) { _logger = loggerFactory.CreateLogger(); @@ -32,12 +31,9 @@ public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService _workspaceService = workspace; } - public WorkspaceSymbolRegistrationOptions GetRegistrationOptions() - { - return new WorkspaceSymbolRegistrationOptions(); - } + protected override WorkspaceSymbolRegistrationOptions CreateRegistrationOptions(WorkspaceSymbolCapability capability, ClientCapabilities clientCapabilities) => new WorkspaceSymbolRegistrationOptions { }; - public Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken) + public override Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken) { var symbols = new List(); @@ -77,11 +73,6 @@ public Task> Handle(WorkspaceSymbolParams request, return Task.FromResult(new Container(symbols)); } - public void SetCapability(WorkspaceSymbolCapability capability) - { - _capability = capability; - } - #region private Methods private bool IsQueryMatch(string query, string symbolName) From ebe218014711e5091737c256c8e0c73af4ff0193 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 15:03:06 -0800 Subject: [PATCH 21/32] Convert `PsesConfigurationHandler` to inherit `DidChangeConfigurationHandlerBase` Except for `TelemetryEventParams` changes, saving for later. --- .../Workspace/Handlers/ConfigurationHandler.cs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index f5fcdf84a..6502fde43 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -22,14 +22,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesConfigurationHandler : IDidChangeConfigurationHandler + internal class PsesConfigurationHandler : DidChangeConfigurationHandlerBase { private readonly ILogger _logger; private readonly WorkspaceService _workspaceService; private readonly ConfigurationService _configurationService; private readonly PowerShellContextService _powerShellContextService; private readonly ILanguageServerFacade _languageServer; - private DidChangeConfigurationCapability _capability; private bool _profilesLoaded; private bool _consoleReplStarted; private bool _cwdSet; @@ -50,12 +49,7 @@ public PsesConfigurationHandler( ConfigurationUpdated += analysisService.OnConfigurationUpdated; } - public object GetRegistrationOptions() - { - return null; - } - - public async Task Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) + public override async Task Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject(); if(incomingSettings == null) @@ -207,11 +201,6 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS }); } - public void SetCapability(DidChangeConfigurationCapability capability) - { - _capability = capability; - } - public event EventHandler ConfigurationUpdated; } } From ce010569dab13ea31c1bcb1789c551f16434adac Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 15:09:22 -0800 Subject: [PATCH 22/32] Convert `PsesDocumentHighlightHandler` to inherit `DocumentHighlightHandlerBase` --- .../Handlers/DocumentHighlightHandler.cs | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs index 5daa111f5..3501b8dec 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentHighlightHandler.cs @@ -17,18 +17,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDocumentHighlightHandler : IDocumentHighlightHandler + internal class PsesDocumentHighlightHandler : DocumentHighlightHandlerBase { private static readonly DocumentHighlightContainer s_emptyHighlightContainer = new DocumentHighlightContainer(); - private readonly ILogger _logger; - private readonly WorkspaceService _workspaceService; - private readonly SymbolsService _symbolsService; - private DocumentHighlightCapability _capability; - public PsesDocumentHighlightHandler( ILoggerFactory loggerFactory, WorkspaceService workspaceService, @@ -40,15 +35,12 @@ public PsesDocumentHighlightHandler( _logger.LogInformation("highlight handler loaded"); } - public DocumentHighlightRegistrationOptions GetRegistrationOptions() + protected override DocumentHighlightRegistrationOptions CreateRegistrationOptions(DocumentHighlightCapability capability, ClientCapabilities clientCapabilities) => new DocumentHighlightRegistrationOptions { - return new DocumentHighlightRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public Task Handle( + public override Task Handle( DocumentHighlightParams request, CancellationToken cancellationToken) { @@ -76,10 +68,5 @@ public Task Handle( return Task.FromResult(new DocumentHighlightContainer(highlights)); } - - public void SetCapability(DocumentHighlightCapability capability) - { - _capability = capability; - } } } From ec0c893bdfe90e4ee12537d31757eae3cd10698f Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 15:11:14 -0800 Subject: [PATCH 23/32] Convert `PsesDefinitionHandler` to inherit `DefinitionHandlerBase` --- .../Handlers/DefinitionHandler.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs index 29d519e12..52d0d74d8 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs @@ -18,14 +18,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesDefinitionHandler : IDefinitionHandler + internal class PsesDefinitionHandler : DefinitionHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private DefinitionCapability _capability; - public PsesDefinitionHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -36,15 +34,12 @@ public PsesDefinitionHandler( _workspaceService = workspaceService; } - public DefinitionRegistrationOptions GetRegistrationOptions() + protected override DefinitionRegistrationOptions CreateRegistrationOptions(DefinitionCapability capability, ClientCapabilities clientCapabilities) => new DefinitionRegistrationOptions { - return new DefinitionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public async Task Handle(DefinitionParams request, CancellationToken cancellationToken) + public override async Task Handle(DefinitionParams request, CancellationToken cancellationToken) { ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -76,11 +71,6 @@ public async Task Handle(DefinitionParams request, Canc return new LocationOrLocationLinks(definitionLocations); } - public void SetCapability(DefinitionCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range From 57c5545c40f166dbdf77f30fe9deffbd822aa9a5 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 15:33:04 -0800 Subject: [PATCH 24/32] Convert `PsesSignatureHelpHandler` to inherit `SignatureHelpHandlerBase` --- .../Handlers/SignatureHelpHandler.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs index 688e5aba7..751152a5b 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs @@ -17,15 +17,13 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesSignatureHelpHandler : ISignatureHelpHandler + internal class PsesSignatureHelpHandler : SignatureHelpHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; private readonly PowerShellContextService _powerShellContextService; - private SignatureHelpCapability _capability; - public PsesSignatureHelpHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -38,17 +36,14 @@ public PsesSignatureHelpHandler( _powerShellContextService = powerShellContextService; } - public SignatureHelpRegistrationOptions GetRegistrationOptions() + protected override SignatureHelpRegistrationOptions CreateRegistrationOptions(SignatureHelpCapability capability, ClientCapabilities clientCapabilities) => new SignatureHelpRegistrationOptions { - return new SignatureHelpRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - // A sane default of " ". We may be able to include others like "-". - TriggerCharacters = new Container(" ") - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + // A sane default of " ". We may be able to include others like "-". + TriggerCharacters = new Container(" ") + }; - public async Task Handle(SignatureHelpParams request, CancellationToken cancellationToken) + public override async Task Handle(SignatureHelpParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -95,11 +90,6 @@ await _symbolsService.FindParameterSetsInFileAsync( }; } - public void SetCapability(SignatureHelpCapability capability) - { - _capability = capability; - } - private static ParameterInformation CreateParameterInfo(ParameterInfo parameterInfo) { return new ParameterInformation From bdfa4d324c5040770d8116302dfb7364f6278778 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 12 Mar 2021 15:36:25 -0800 Subject: [PATCH 25/32] Convert `PsesHoverHandler` to inherit `HoverHandlerBase` --- .../TextDocument/Handlers/HoverHandler.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs index 6f2c83d79..031b40371 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs @@ -17,14 +17,12 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { - internal class PsesHoverHandler : IHoverHandler + internal class PsesHoverHandler : HoverHandlerBase { private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private HoverCapability _capability; - public PsesHoverHandler( ILoggerFactory factory, SymbolsService symbolsService, @@ -35,15 +33,12 @@ public PsesHoverHandler( _workspaceService = workspaceService; } - public HoverRegistrationOptions GetRegistrationOptions() + protected override HoverRegistrationOptions CreateRegistrationOptions(HoverCapability capability, ClientCapabilities clientCapabilities) => new HoverRegistrationOptions { - return new HoverRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - public async Task Handle(HoverParams request, CancellationToken cancellationToken) + public override async Task Handle(HoverParams request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -81,11 +76,6 @@ await _symbolsService.FindSymbolDetailsAtLocationAsync( }; } - public void SetCapability(HoverCapability capability) - { - _capability = capability; - } - private static Range GetRangeFromScriptRegion(ScriptRegion scriptRegion) { return new Range From 01a31f900041d63f17d9c1da56a09803671fee7d Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 15 Mar 2021 19:05:54 -0700 Subject: [PATCH 26/32] Fix `PsesCodeLensHandlers` --- .../TextDocument/Handlers/CodeLensHandlers.cs | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs index 4bcd45a91..871ae90b6 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs @@ -15,22 +15,21 @@ using Microsoft.PowerShell.EditorServices.Services; using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Utility; -using OmniSharp.Extensions.LanguageServer.Protocol; using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler { - private readonly Guid _id = new Guid(); private readonly ILogger _logger; private readonly SymbolsService _symbolsService; private readonly WorkspaceService _workspaceService; - private CodeLensCapability _capability; - public Guid Id => _id; + private readonly Guid _id = Guid.NewGuid(); + Guid ICanBeIdentifiedHandler.Id => _id; public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService, ConfigurationService configurationService) { @@ -39,13 +38,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic _symbolsService = symbolsService; } - CodeLensRegistrationOptions IRegistration.GetRegistrationOptions() + public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions { - return new CodeLensRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - ResolveProvider = true - }; + DocumentSelector = LspUtils.PowerShellDocumentSelector, + ResolveProvider = true + }; + + public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities) + { + _capability = capability; } public Task Handle(CodeLensParams request, CancellationToken cancellationToken) @@ -57,14 +58,6 @@ public Task Handle(CodeLensParams request, CancellationToken return Task.FromResult(new CodeLensContainer(codeLensResults)); } - public TextDocumentRegistrationOptions GetRegistrationOptions() - { - return new TextDocumentRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - }; - } - public bool CanResolve(CodeLens value) { CodeLensData codeLensData = value.Data.ToObject(); From 4c5b418d4ecb23d0b59f8ce2aac4528ad3e4e68b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 15 Mar 2021 19:06:04 -0700 Subject: [PATCH 27/32] Fix `PsesCompletionHandler` --- .../Handlers/CompletionHandler.cs | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs index c123da8fb..de5d01636 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs @@ -21,25 +21,22 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler { const int DefaultWaitTimeoutMilliseconds = 5000; private readonly SemaphoreSlim _completionLock = AsyncUtils.CreateSimpleLockingSemaphore(); private readonly SemaphoreSlim _completionResolveLock = AsyncUtils.CreateSimpleLockingSemaphore(); - private readonly ILogger _logger; private readonly PowerShellContextService _powerShellContextService; private readonly WorkspaceService _workspaceService; - private CompletionResults _mostRecentCompletions; - private int _mostRecentRequestLine; - private int _mostRecentRequestOffest; - private string _mostRecentRequestFile; - private CompletionCapability _capability; + private readonly Guid _id = Guid.NewGuid(); + Guid ICanBeIdentifiedHandler.Id => _id; public PsesCompletionHandler( ILoggerFactory factory, @@ -51,15 +48,12 @@ public PsesCompletionHandler( _workspaceService = workspaceService; } - public CompletionRegistrationOptions GetRegistrationOptions() + public CompletionRegistrationOptions GetRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions { - return new CompletionRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - ResolveProvider = true, - TriggerCharacters = new[] { ".", "-", ":", "\\", "$" } - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector, + ResolveProvider = true, + TriggerCharacters = new[] { ".", "-", ":", "\\", "$" } + }; public async Task Handle(CompletionParams request, CancellationToken cancellationToken) { @@ -145,10 +139,10 @@ await CommandHelpers.GetCommandInfoAsync( if (commandInfo != null) { - request.Documentation = - await CommandHelpers.GetCommandSynopsisAsync( - commandInfo, - _powerShellContextService).ConfigureAwait(false); + request = request with + { + Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false) + }; } // Send back the updated CompletionItem @@ -160,7 +154,7 @@ await CommandHelpers.GetCommandSynopsisAsync( } } - public void SetCapability(CompletionCapability capability) + public void SetCapability(CompletionCapability capability, ClientCapabilities clientCapabilities) { _capability = capability; } From ba9d416487997df90c32716028fbef5ff8f8448e Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 15 Mar 2021 19:06:17 -0700 Subject: [PATCH 28/32] Fix `PsesDocumentFormattingHandlers` --- .../Handlers/FormattingHandlers.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs index a229fbea9..71a4da380 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs @@ -17,6 +17,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { // TODO: Add IDocumentOnTypeFormatHandler to support on-type formatting. + // TODO: Use ABCs. internal class PsesDocumentFormattingHandlers : IDocumentFormattingHandler, IDocumentRangeFormattingHandler { private readonly ILogger _logger; @@ -39,21 +40,15 @@ public PsesDocumentFormattingHandlers( _workspaceService = workspaceService; } - public DocumentFormattingRegistrationOptions GetRegistrationOptions() + public DocumentFormattingRegistrationOptions GetRegistrationOptions(DocumentFormattingCapability capability, ClientCapabilities clientCapabilities) => new DocumentFormattingRegistrationOptions { - return new DocumentFormattingRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; - DocumentRangeFormattingRegistrationOptions IRegistration.GetRegistrationOptions() + public DocumentRangeFormattingRegistrationOptions GetRegistrationOptions(DocumentRangeFormattingCapability capability, ClientCapabilities clientCapabilities) => new DocumentRangeFormattingRegistrationOptions { - return new DocumentRangeFormattingRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector - }; - } + DocumentSelector = LspUtils.PowerShellDocumentSelector + }; public async Task Handle(DocumentFormattingParams request, CancellationToken cancellationToken) { From 2762feab9ec2100ceff24460f5ed1f669f1412c9 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 15 Mar 2021 19:06:41 -0700 Subject: [PATCH 29/32] Document "method lacks 'await'" warnings --- src/PowerShellEditorServices/Server/PsesLanguageServer.cs | 1 + .../Services/TextDocument/Handlers/CodeActionHandler.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs index 0626f1235..ebe936792 100644 --- a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs +++ b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs @@ -94,6 +94,7 @@ public async Task StartAsync() .WithHandler() .WithHandler() .OnInitialize( + // TODO: Either fix or ignore "method lacks 'await'" warning. async (languageServer, request, cancellationToken) => { var serviceProvider = languageServer.Services; diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs index 4f6d23563..23214989f 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs @@ -39,6 +39,7 @@ public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisSer CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix } }; + // TODO: Either fix or ignore "method lacks 'await'" warning. public override async Task Handle(CodeAction request, CancellationToken cancellationToken) { // TODO: How on earth do we handle a CodeAction? This is new... From f22259efdc5748ff17bd5d4ef3f9d956663b33d3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 15 Mar 2021 19:44:05 -0700 Subject: [PATCH 30/32] Fix tests --- .../DebugAdapterClientExtensions.cs | 10 +--------- .../DebugAdapterProtocolMessageTests.cs | 2 +- .../LanguageServerProtocolMessageTests.cs | 2 +- .../Language/SemanticTokenTest.cs | 1 + 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs index e3fc8c0cd..91d6f8fac 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs @@ -4,19 +4,11 @@ // using System; -using System.IO; -using System.Reflection; using System.Threading.Tasks; using Microsoft.PowerShell.EditorServices.Handlers; -using Xunit; using OmniSharp.Extensions.DebugAdapter.Client; using OmniSharp.Extensions.DebugAdapter.Protocol.Requests; using System.Threading; -using System.Text; -using System.Linq; -using Xunit.Abstractions; -using Microsoft.Extensions.Logging; -using OmniSharp.Extensions.DebugAdapter.Protocol.Models; namespace PowerShellEditorServices.Test.E2E { @@ -24,7 +16,7 @@ public static class DebugAdapterClientExtensions { public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string filePath, TaskCompletionSource started) { - LaunchResponse launchResponse = await debugAdapterClient.RequestLaunch(new PsesLaunchRequestArguments + LaunchResponse launchResponse = await debugAdapterClient.Launch(new PsesLaunchRequestArguments { NoDebug = false, Script = filePath, diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index a70f570f5..bd8865d5e 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -182,7 +182,7 @@ public async Task CanSetBreakpointsAsync() await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); // {"command":"setBreakpoints","arguments":{"source":{"name":"dfsdfg.ps1","path":"/Users/tyleonha/Code/PowerShell/Misc/foo/dfsdfg.ps1"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false},"type":"request","seq":3} - SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.RequestSetBreakpoints(new SetBreakpointsArguments + SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.SetBreakpoints(new SetBreakpointsArguments { Source = new Source { diff --git a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs index f69bfeb03..4fc22b58c 100644 --- a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs @@ -215,7 +215,7 @@ public async Task CanReceiveDiagnosticsFromFileChangedAsync() Text = "$a = 7" } }), - TextDocument = new VersionedTextDocumentIdentifier + TextDocument = new OptionalVersionedTextDocumentIdentifier { Version = 4, Uri = new Uri(filePath) diff --git a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs index 01ed9e046..6414d4495 100644 --- a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs +++ b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs @@ -11,6 +11,7 @@ using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Handlers; using OmniSharp.Extensions.LanguageServer.Protocol; +using OmniSharp.Extensions.LanguageServer.Protocol.Models; using Xunit; namespace Microsoft.PowerShell.EditorServices.Test.Language From f332ce18a6ebf5d2f0f593e46b1ff4600c308136 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 16 Mar 2021 11:46:54 -0700 Subject: [PATCH 31/32] Use C# version 9.0 Which we need for `record`s, and OmniSharp forces us to use. --- PowerShellEditorServices.Common.props | 1 + .../PowerShellEditorServices.Hosting.csproj | 2 +- .../PowerShellEditorServices.csproj | 10 ---------- .../PowerShellEditorServices.Test.E2E.csproj | 1 + 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/PowerShellEditorServices.Common.props b/PowerShellEditorServices.Common.props index 50222ec97..49777cc88 100644 --- a/PowerShellEditorServices.Common.props +++ b/PowerShellEditorServices.Common.props @@ -4,6 +4,7 @@ preview.1 Microsoft © Microsoft Corporation. All rights reserved. + 9.0 PowerShell;editor;development;language;debugging https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE true diff --git a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj index 72f621c02..6b6771390 100644 --- a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj +++ b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj @@ -1,9 +1,9 @@  + netcoreapp3.1;net461 Microsoft.PowerShell.EditorServices.Hosting - latest diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 0cf5474aa..5f04edec0 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -7,19 +7,9 @@ Provides common PowerShell editor capabilities as a .NET library. netstandard2.0 Microsoft.PowerShell.EditorServices - Latest Debug;Release - - latest - - - - - latest - - <_Parameter1>Microsoft.PowerShell.EditorServices.Hosting diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index c06cb976c..e78a9d322 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -1,4 +1,5 @@ + net6.0;netcoreapp3.1 From 3ae17e83ff93f0421c151f3bb72c2e28d9ed5069 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 16 Mar 2021 15:52:15 -0700 Subject: [PATCH 32/32] Fix `TelemetryEventParams` --- src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs | 4 ++-- .../Services/Workspace/Handlers/ConfigurationHandler.cs | 2 +- test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs b/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs index 4d55320be..0ee68b9e2 100644 --- a/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs +++ b/src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs @@ -9,10 +9,10 @@ namespace Microsoft.PowerShell.EditorServices.Logging { // This inheirits from Dictionary so that it can be passed in to SendTelemetryEvent() - // which takes in an IDictionary + // which takes in an IDictionary // However, I wanted creation to be easy so you can do // new PsesTelemetryEvent { EventName = "eventName", Data = data } - internal class PsesTelemetryEvent : Dictionary + internal class PsesTelemetryEvent : Dictionary { public string EventName { diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index 6502fde43..5d47f31fb 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -193,7 +193,7 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS _languageServer.Window.SendTelemetryEvent(new TelemetryEventParams { - Data = new PsesTelemetryEvent + ExtensionData = new PsesTelemetryEvent { EventName = "NonDefaultPsesFeatureConfiguration", Data = JObject.FromObject(configChanges) diff --git a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs index ebf2c4692..fb283f775 100644 --- a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs +++ b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs @@ -63,8 +63,8 @@ public async Task InitializeAsync() .OnTelemetryEvent(telemetryEventParams => TelemetryEvents.Add( new PsesTelemetryEvent { - EventName = (string) telemetryEventParams.Data["eventName"], - Data = telemetryEventParams.Data["data"] as JObject + EventName = (string)telemetryEventParams.ExtensionData["eventName"], + Data = telemetryEventParams.ExtensionData["data"] as JObject })); // Enable all capabilities this this is for testing.