Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release build was broken because of an #if DEBUG for System.Diagnostics #2144

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected override void BeginProcessing()
{
// NOTE: Ignore the suggestion to use Environment.ProcessId as it doesn't work for
// .NET 4.6.2 (for Windows PowerShell), and this won't be caught in CI.
Console.WriteLine($"Waiting for debugger to attach, PID: {Process.GetCurrentProcess().Id}");
Console.WriteLine($"Waiting for debugger to attach, PID: {s_currentPID}");
while (!Debugger.IsAttached)
{
Thread.Sleep(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -13,7 +14,6 @@
using Microsoft.PowerShell.EditorServices.Services.Extension;

#if DEBUG
using System.Diagnostics;
using Serilog.Debugging;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ internal record PsesAttachRequestArguments : AttachRequestArguments

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

if (processIdIsSet)
{
if (request.ProcessId == currentProcessId)
if (request.ProcessId == s_currentPID)
{
throw new RpcErrorException(0, null, $"Attaching to the Extension Terminal is not supported!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class PSHostProcessAndRunspaceHandlers : IGetPSHostProcessesHandler, IG
private readonly ILogger<PSHostProcessAndRunspaceHandlers> _logger;
private readonly IInternalPowerShellExecutionService _executionService;
private readonly IRunspaceContext _runspaceContext;
private static readonly int currentProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
private static readonly int s_currentPID = System.Diagnostics.Process.GetCurrentProcess().Id;

public PSHostProcessAndRunspaceHandlers(
ILoggerFactory factory,
Expand Down Expand Up @@ -50,7 +50,7 @@ public async Task<PSHostProcessResponse[]> Handle(GetPSHostProcessesParams reque

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

public async Task<RunspaceResponse[]> Handle(GetRunspaceParams request, CancellationToken cancellationToken)
{
if (request.ProcessId == currentProcessId)
if (request.ProcessId == s_currentPID)
{
throw new RpcErrorException(0, null, $"Attaching to the Extension Terminal is not supported!");
}
Expand Down
Loading