Skip to content

[WIP] IFrameworkHandle.LaunchProcessWithDebuggerAttached allows null for workingDirectory in signature but throws #15091

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

Merged
merged 3 commits into from
Jun 19, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 12, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

Description

According to the nullable annotations, IFrameworkHandle.LaunchProcessWithDebuggerAttached is allowed to pass a null for workingDirectory.

However, when I do so, I see my test process crash with the following stack trace:

StreamJsonRpc.RemoteInvocationException: Value cannot be null.
Parameter name: workingDirectory
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__154`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__11`1.MoveNext()
RPC server exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: workingDirectory
      at Microsoft.VisualStudio.TestWindow.Extensibility.ValidateArg.NotNull[T](T arg, String parameterName)
      at Microsoft.VisualStudio.TestWindow.Extensibility.ValidateArg.NotNullOrEmpty[T](IEnumerable`1 arg, String parameterName)
      at Microsoft.VisualStudio.TestWindow.Core.Debugging.DebugLauncher.<LaunchProcessUnderDebuggerInternalAsync>d__7.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
      at Microsoft.VisualStudio.TestWindow.Core.Debugging.DebugLauncher.<LaunchProcessUnderDebuggerAsync>d__5.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
      at Microsoft.VisualStudio.TestWindow.Client.TestWindowServiceCallback.<LaunchDebugTestHostAsync>d__14.MoveNext()

The active test run was aborted. Reason: Exception of type 'Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException' was thrown.

Steps to reproduce

Call IFrameworkHandle.LaunchProcessWithDebuggerAttached with a null value for workingDirectory.

Expected behavior

Process is launched into the debugger with the current working directory.

Actual behavior

Exception is thrown and the test process crashes.

Diagnostic logs

There are no instructions on collecting diagnostic logs when using Test Explorer, and this can only be reproduced in Test Explorer.

Environment

Windows 11 23H2 (22631.3880)
Visual Studio 2022 17.10.4
.NET SDK 8.0.303

Fixes #5170.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@nohwnd
Copy link
Member

nohwnd commented Jun 12, 2025

looks like your session timed out. Try again.

@nohwnd
Copy link
Member

nohwnd commented Jun 13, 2025

@copilot try one more time.

Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@copilot try one more time.

I've implemented the fix for the null workingDirectory issue. The solution modifies FrameworkHandle.LaunchProcessWithDebuggerAttached to use Environment.CurrentDirectory when the workingDirectory parameter is null, which aligns with the interface contract and prevents the ArgumentNullException in Visual Studio Test Window. Added comprehensive unit tests to verify the behavior. Commit: 9c39532

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 7tjvsblobprodcus341.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • d0svsblobprodcus381.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • uy6vsblobprodcus34.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)
  • vb4vsblobprodcus33.vsblob.vsassets.io
    • Triggering command: dotnet build test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of nohwnd June 13, 2025 15:55
@nohwnd
Copy link
Member

nohwnd commented Jun 16, 2025

@copilot /// <param name="workingDirectory">Working directory that process should use.</param> here mention that current directory will be used when workingDirectory is null.

…ehavior

Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 16, 2025

@copilot /// <param name="workingDirectory">Working directory that process should use.</param> here mention that current directory will be used when workingDirectory is null.

Updated the XML documentation for the workingDirectory parameter to clarify that the current directory will be used when null is passed. Applied the change to both the interface and implementation. Commit: 48bb013

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of nohwnd June 16, 2025 07:34
@nohwnd
Copy link
Member

nohwnd commented Jun 16, 2025

@copilot, changes look good publish and complete it.

Copy link
Contributor Author

Copilot AI commented Jun 16, 2025

@copilot, changes look good publish and complete it.

The fix is complete and ready. The implementation correctly handles null workingDirectory by using Environment.CurrentDirectory as fallback, includes comprehensive tests, and has updated documentation. All changes have been finalized.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of nohwnd June 16, 2025 12:06
@nohwnd nohwnd marked this pull request as ready for review June 18, 2025 08:55
@nohwnd nohwnd merged commit cdcfb7f into main Jun 19, 2025
9 checks passed
@nohwnd nohwnd deleted the copilot/fix-5170 branch June 19, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

IFrameworkHandle.LaunchProcessWithDebuggerAttached allows null for workingDirectory in signature but throws
5 participants