Skip to content

Commit 557ddbe

Browse files
committed
Add in Logging.Debug for extension tests
1 parent 3335b32 commit 557ddbe

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

Directory.Packages.props

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
44
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
55
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
6+
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
67
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
78
<PackageVersion Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" />
89
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.6" />

src/PowerShellEditorServices/Server/PsesDebugServer.cs

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public async Task StartAsync()
6666
.WithOutput(_outputStream)
6767
.WithServices(serviceCollection =>
6868
serviceCollection
69-
.AddLogging()
7069
.AddOptions()
7170
.AddPsesDebugServices(ServiceProvider, this))
7271
// TODO: Consider replacing all WithHandler with AddSingleton

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading;
1010
using System.Threading.Tasks;
1111
using Microsoft.Extensions.Logging;
12+
using Microsoft.Extensions.Logging.Debug;
1213
using OmniSharp.Extensions.DebugAdapter.Client;
1314
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
1415
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
@@ -33,8 +34,10 @@ public class DebugAdapterProtocolMessageTests : IAsyncLifetime, IDisposable
3334

3435
public async Task InitializeAsync()
3536
{
36-
LoggerFactory factory = new();
37-
_psesProcess = new PsesStdioProcess(factory, true);
37+
LoggerFactory debugLoggerFactory = new();
38+
debugLoggerFactory.AddProvider(new DebugLoggerProvider());
39+
40+
_psesProcess = new PsesStdioProcess(debugLoggerFactory, true);
3841
await _psesProcess.Start();
3942

4043
TaskCompletionSource<bool> initialized = new();
@@ -50,6 +53,11 @@ public async Task InitializeAsync()
5053
options
5154
.WithInput(_psesProcess.OutputStream)
5255
.WithOutput(_psesProcess.InputStream)
56+
.ConfigureLogging(builder =>
57+
builder
58+
.AddDebug()
59+
.SetMinimumLevel(LogLevel.Trace)
60+
)
5361
// The OnStarted delegate gets run when we receive the _Initialized_ event from the server:
5462
// https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized
5563
.OnStarted((_, _) =>

test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1112
<PackageReference Include="Newtonsoft.Json" />
1213
<PackageReference Include="xunit" />

test/PowerShellEditorServices.Test.E2E/Processes/ServerProcess.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ protected ServerProcess(ILoggerFactory loggerFactory)
3838

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

41-
_inStreamLazy = new Lazy<Stream>(() => new LoggingStream(GetInputStream()));
42-
_outStreamLazy = new Lazy<Stream>(() => new LoggingStream(GetOutputStream()));
41+
_inStreamLazy = new Lazy<Stream>(GetInputStream);
42+
_outStreamLazy = new Lazy<Stream>(GetOutputStream);
4343
}
4444

4545
/// <summary>

0 commit comments

Comments
 (0)