vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Add format specifier to allow all threads to run

Open gregg-miskelly opened this issue 6 years ago • 9 comments

Steps to reproduce

  1. Debug the following program
  2. Evaluate Program.Test

Expected behavior

There is some way to evaluate this

Actual behavior

Debugger prints: The function evaluation requires all threads to run.

Program content

using System;

namespace clinew
{
    class Program
    {
        static string Test
        {
            get
            {
                System.Diagnostics.Debugger.NotifyOfCrossThreadDependency();
                return "Test";
            }
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

gregg-miskelly avatar Oct 17 '18 20:10 gregg-miskelly

I imagine we could implement this either by supporting some sort of format specifier (ex: Program.MyProperty,allthreads) or, for the watch/variables window, maybe we can add a context menu item.

gregg-miskelly avatar Oct 17 '18 20:10 gregg-miskelly

Has this ever been implemented?

Currently in the Watch it just states "The function evaluation requires all threads to run."

In the Watch window there is a need to be able to evaluate functions that requires all threads to run. In Visual Studio we had the option to click the little "thread" button in the Watch window that would execute these functions.

Messulethe92 avatar Jul 02 '19 05:07 Messulethe92

No, not yet

gregg-miskelly avatar Jul 02 '19 16:07 gregg-miskelly

Is there any update on this? I'm really not getting a wonderful experience while debugging. Wonder if there's workaround for this in the meantime?

ashishshuklabs avatar Apr 20 '20 23:04 ashishshuklabs

Same here. This issue makes debugging difficult for 3rd party types. Is there a way to improve debugging?

tobobw avatar May 08 '23 08:05 tobobw

@gregg-miskelly Are there any chances that this issue will be fixed in the future? For example, it significantly affects the development of C# Selenium tests on MacOS. Debugging on such a configuration is only possible in JetBrains Rider.

algot avatar Feb 29 '24 04:02 algot

@algot this is certainly something that I hope we get to without waiting forever. The two challenges are:

  1. The normal problem that the VS debugger team is small, and the number of important issues to deal with exceeds our capacity to work on them.
  2. For this particular issue, VS Code doesn't have a mechanism to provide an experience similar to Visual Studio or JetBrains Rider. So, implementing something good here requires changes to VS Code and the Debug Adapter Protocol, which makes this much more expensive to implement than one might think.

How helpful would you find it if the C# Extension supported a not-great-but-maybe-unblocks-you experience where you could append something like ,allthreads (example: SomeObject.SomeProperty,allthreads) to the evaluation arguments to allow the evaluation to proceed allowing all threads to run?

gregg-miskelly avatar Feb 29 '24 23:02 gregg-miskelly

@gregg-miskelly The suggestion of having a not-perfect but potentially unblocking feature like appending ",allthreads" to evaluation arguments in the C# Extension is appreciated. If this approach can offer a workaround for debugging such code, it would be beneficial to have this option.

algot avatar Feb 29 '24 23:02 algot

I am splitting this issue into two parts, this issue will just track the format specifier, and I opened #6959 to track possible future work to make this experience better.

gregg-miskelly avatar Mar 09 '24 00:03 gregg-miskelly

The next version of the C# extension (which I believe is 2.27) will support this. The format specifier is , run-all-threads.

gregg-miskelly avatar Apr 19 '24 21:04 gregg-miskelly