Skip to content

Commit

Permalink
Add in Logging.Debug for extension tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGrote committed Nov 14, 2024
1 parent 3335b32 commit 557ddbe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" />
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.6" />
Expand Down
1 change: 0 additions & 1 deletion src/PowerShellEditorServices/Server/PsesDebugServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<bool> initialized = new();
Expand All @@ -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((_, _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="xunit" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ protected ServerProcess(ILoggerFactory loggerFactory)

Exited = _exitedSubject = new AsyncSubject<System.Reactive.Unit>();

_inStreamLazy = new Lazy<Stream>(() => new LoggingStream(GetInputStream()));
_outStreamLazy = new Lazy<Stream>(() => new LoggingStream(GetOutputStream()));
_inStreamLazy = new Lazy<Stream>(GetInputStream);
_outStreamLazy = new Lazy<Stream>(GetOutputStream);
}

/// <summary>
Expand Down

0 comments on commit 557ddbe

Please sign in to comment.