From 557ddbee795ff4a94ec073af750fa72acfbb5be6 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Thu, 14 Nov 2024 10:39:36 -0800 Subject: [PATCH] Add in Logging.Debug for extension tests --- Directory.Packages.props | 1 + .../Server/PsesDebugServer.cs | 1 - .../DebugAdapterProtocolMessageTests.cs | 12 ++++++++++-- .../PowerShellEditorServices.Test.E2E.csproj | 1 + .../Processes/ServerProcess.cs | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6c2570600..9124e3a74 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,7 @@ + diff --git a/src/PowerShellEditorServices/Server/PsesDebugServer.cs b/src/PowerShellEditorServices/Server/PsesDebugServer.cs index f895c0798..31f6a988f 100644 --- a/src/PowerShellEditorServices/Server/PsesDebugServer.cs +++ b/src/PowerShellEditorServices/Server/PsesDebugServer.cs @@ -66,7 +66,6 @@ public async Task StartAsync() .WithOutput(_outputStream) .WithServices(serviceCollection => serviceCollection - .AddLogging() .AddOptions() .AddPsesDebugServices(ServiceProvider, this)) // TODO: Consider replacing all WithHandler with AddSingleton diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index 654001da7..a3c68eadb 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Debug; using OmniSharp.Extensions.DebugAdapter.Client; using OmniSharp.Extensions.DebugAdapter.Protocol.Models; using OmniSharp.Extensions.DebugAdapter.Protocol.Requests; @@ -33,8 +34,10 @@ public class DebugAdapterProtocolMessageTests : IAsyncLifetime, IDisposable public async Task InitializeAsync() { - LoggerFactory factory = new(); - _psesProcess = new PsesStdioProcess(factory, true); + LoggerFactory debugLoggerFactory = new(); + debugLoggerFactory.AddProvider(new DebugLoggerProvider()); + + _psesProcess = new PsesStdioProcess(debugLoggerFactory, true); await _psesProcess.Start(); TaskCompletionSource initialized = new(); @@ -50,6 +53,11 @@ public async Task InitializeAsync() options .WithInput(_psesProcess.OutputStream) .WithOutput(_psesProcess.InputStream) + .ConfigureLogging(builder => + builder + .AddDebug() + .SetMinimumLevel(LogLevel.Trace) + ) // The OnStarted delegate gets run when we receive the _Initialized_ event from the server: // https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized .OnStarted((_, _) => diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 3756f071d..2ea39d3fd 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -7,6 +7,7 @@ + diff --git a/test/PowerShellEditorServices.Test.E2E/Processes/ServerProcess.cs b/test/PowerShellEditorServices.Test.E2E/Processes/ServerProcess.cs index 8d744dc11..90ecaaf5c 100644 --- a/test/PowerShellEditorServices.Test.E2E/Processes/ServerProcess.cs +++ b/test/PowerShellEditorServices.Test.E2E/Processes/ServerProcess.cs @@ -38,8 +38,8 @@ protected ServerProcess(ILoggerFactory loggerFactory) Exited = _exitedSubject = new AsyncSubject(); - _inStreamLazy = new Lazy(() => new LoggingStream(GetInputStream())); - _outStreamLazy = new Lazy(() => new LoggingStream(GetOutputStream())); + _inStreamLazy = new Lazy(GetInputStream); + _outStreamLazy = new Lazy(GetOutputStream); } ///