Is it possible to set a breakpoint in a method chain in VS, and if so how?
Given the code
[Test]
public void Test1()
{
var a = new A();
开发者_StackOverflow 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'.
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.
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).
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.
精彩评论