question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging Async methods not working

See original GitHub issue

I install MrAdvice in my project and I have this code which I have no problem in debugging :

    class Program
    {
        static void Main()
        {
            Async().GetAwaiter().GetResult();
            Non_Async();
        }

        static async Task Async()
        {
            var foo = "bar";
            // can see foo in debug
        }

        static void Non_Async()
        {
            var foo = "bar";
            // can see foo in debug
        }
    }

when I add an Advice class to my code, I can no longer see local variables in async methods in debug mode.

    class Program
    {
        static void Main()
        {
            Async().GetAwaiter().GetResult();
            Non_Async();
        }

        static async Task Async()
        {
            var foo = "bar";
            // can NOT see foo in debug
        }

        static void Non_Async()
        {
            var foo = "bar";
            // can see foo in debug
        }
    }

   class AdviceA : Attribute, IMethodAdvice
    {
        public void Advise(MethodAdviceContext context)
        {
            Console.WriteLine("Entry From Advice A");
            context.Proceed();
            Console.WriteLine("Exit From Advice A");
        }
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Kahbazicommented, Jun 26, 2017

@picrap thanks, really appreciate it.

1reaction
picrapcommented, Jun 25, 2017

The async debug was solved in dnlib, so MrAdvice 2.5.3 uses it and solves the problem too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I debug code in an async method?
Because you are not await ing your GetDataAsync method. When the first await is reached the thread is returned to the caller.
Read more >
How Do I Debug Async Code in Visual Studio?
You can access the Tasks window at Debug > Windows > Task or by using CTRL+SHIFT+D, K. Tasks window. How can I locate...
Read more >
Debug Async Code
In this article, you will learn how to debug async code. ... integrated with Visual Studio, we can debug the code and solve...
Read more >
Debugger can't step into async function which returns ...
I'm finding sometimes the debugger (VS 2019) steps into await calls as expected, and sometimes it steps into disassembly of the async support ......
Read more >
Debugger cannot step over "await" when using custom task ...
I just want to add that when I run the code in a new CLI project with just an "async Task Main()" the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found