Skip to content

Commit c562479

Browse files
committed
Release build was broken because of an #if DEBUG for System.Diagnostics
1 parent 4e73bf3 commit c562479

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ protected override void BeginProcessing()
204204
{
205205
// NOTE: Ignore the suggestion to use Environment.ProcessId as it doesn't work for
206206
// .NET 4.6.2 (for Windows PowerShell), and this won't be caught in CI.
207-
Console.WriteLine($"Waiting for debugger to attach, PID: {Process.GetCurrentProcess().Id}");
207+
Console.WriteLine($"Waiting for debugger to attach, PID: {s_currentPID}");
208208
while (!Debugger.IsAttached)
209209
{
210210
Thread.Sleep(1000);

src/PowerShellEditorServices/Hosting/EditorServicesServerFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Diagnostics;
56
using System.IO;
67
using Microsoft.Extensions.DependencyInjection;
78
using Microsoft.Extensions.Logging;
@@ -13,7 +14,6 @@
1314
using Microsoft.PowerShell.EditorServices.Services.Extension;
1415

1516
#if DEBUG
16-
using System.Diagnostics;
1717
using Serilog.Debugging;
1818
#endif
1919

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ internal record PsesAttachRequestArguments : AttachRequestArguments
8787

8888
internal class LaunchAndAttachHandler : ILaunchHandler<PsesLaunchRequestArguments>, IAttachHandler<PsesAttachRequestArguments>, IOnDebugAdapterServerStarted
8989
{
90-
private static readonly int currentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
90+
private static readonly int s_currentPID = System.Diagnostics.Process.GetCurrentProcess().Id;
9191
private static readonly Version s_minVersionForCustomPipeName = new(6, 2);
9292
private readonly ILogger<LaunchAndAttachHandler> _logger;
9393
private readonly BreakpointService _breakpointService;
@@ -275,7 +275,7 @@ void RunspaceChangedHandler(object s, RunspaceChangedEventArgs _)
275275

276276
if (processIdIsSet)
277277
{
278-
if (request.ProcessId == currentProcessId)
278+
if (request.ProcessId == s_currentPID)
279279
{
280280
throw new RpcErrorException(0, null, $"Attaching to the Extension Terminal is not supported!");
281281
}

src/PowerShellEditorServices/Services/PowerShell/Handlers/PSHostProcessAndRunspaceHandlers.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class PSHostProcessAndRunspaceHandlers : IGetPSHostProcessesHandler, IG
1919
private readonly ILogger<PSHostProcessAndRunspaceHandlers> _logger;
2020
private readonly IInternalPowerShellExecutionService _executionService;
2121
private readonly IRunspaceContext _runspaceContext;
22-
private static readonly int currentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
22+
private static readonly int s_currentPID = System.Diagnostics.Process.GetCurrentProcess().Id;
2323

2424
public PSHostProcessAndRunspaceHandlers(
2525
ILoggerFactory factory,
@@ -50,7 +50,7 @@ public async Task<PSHostProcessResponse[]> Handle(GetPSHostProcessesParams reque
5050

5151
// NOTE: We do not currently support attaching to ourself in this manner, so we
5252
// exclude our process. When we maybe eventually do, we should name it.
53-
if (response.ProcessId == currentProcessId)
53+
if (response.ProcessId == s_currentPID)
5454
{
5555
continue;
5656
}
@@ -63,7 +63,7 @@ public async Task<PSHostProcessResponse[]> Handle(GetPSHostProcessesParams reque
6363

6464
public async Task<RunspaceResponse[]> Handle(GetRunspaceParams request, CancellationToken cancellationToken)
6565
{
66-
if (request.ProcessId == currentProcessId)
66+
if (request.ProcessId == s_currentPID)
6767
{
6868
throw new RpcErrorException(0, null, $"Attaching to the Extension Terminal is not supported!");
6969
}

0 commit comments

Comments
 (0)