5

Given the code

    [Test]
    public void Test1()
    {
        var a = new A();
        a
            .Method1()
            .Method2();
    }

is it possible to set a breakpoint so that execution pauses after Method1() has executed, but before Method2 without going to the definition of Method2 and putting a breakpoint there? When I do it, the breakpoint appears at the 'a'.

mcintyre321
  • 12,996
  • 8
  • 66
  • 103

3 Answers3

6

you can't set a breakpoint there, but you can set your breakpoint on the whole statement, and then use the "Step into Specific >" command on the right-click menu (Debug.StepIntoSpecific) to step into Method2().

you can also do repeated step in/step out to step through the indivdual method calls of the compound statement.

Spongman
  • 9,665
  • 8
  • 39
  • 58
  • Thank you! Didn't know that hidden gem in Visual Studio but it can be really useful! (It has a strange German translation though… “Einzelschritt in Angabe”) – ygoe Sep 17 '14 at 14:12
3

Use Rider instead of Visual Studio. IntelliJ Idea is capable of logical step in when fluent syntax is used. It is 2017 and fluent syntax is everywhere (LINQ). Shame on Visual Studio (even 2017).

lukyer
  • 7,595
  • 3
  • 37
  • 31
0

No, the debugger's unit of executable code is a statement. There are only two in the method body in your snippet. Post feature requests to connect.microsoft.com. It's going to be a hard sell, it is not technically impossible but a potentially heavy re-engineering effort.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • 1
    You can actually step through to that stage using "f11 - step into", so it's probably not too hard for them to do. – mcintyre321 May 10 '11 at 12:12