1

I would like to toggle Visual Studio's "Just my code" features on the fly for specific sections of my code.

I searched google for it but the only thing related to JMC are blog posts and https://marketplace.visualstudio.com/items?itemName=SamHarwell.JustMyCodeToggle

What i mean would be something like

private void MyFunction(){
#jmc 1
FunctionThatCallsAlotOfExternalCode();
#jmc 0
FunctionThatCallsExternalCodeINeedToWatch();
}

I really hoped there was at least a extension for it :(

Bluescream
  • 261
  • 1
  • 8
  • Step Over (Usually F10) the first function and Step Into (Usually F11) the second one? If you find yourself in somewhere you don't want, Step Out (Usually Shift-F11) – Caius Jard Sep 22 '19 at 04:27

1 Answers1

1

If JustMyCode is on then you can decorate uninteresting methods with the System.Diagnostics.DebuggerNonUserCode attribute:

[DebuggerNonUserCode]
public void BoringFunction...

And the debugger won't put you into it

There are a couple of other attributes that my also help/work similarly - DebuggerStepThrough can be used to mark an entire class as uninteresting for debugging and DebuggerHidden hides indexers and properties from appearing in the call stack during debugging

For more info there's a discussion here: https://devblogs.microsoft.com/devops/using-the-debuggernonusercode-attribute-in-visual-studio-2015/

Caius Jard
  • 72,509
  • 5
  • 49
  • 80
  • Related info in https://stackoverflow.com/a/39401894/2864740 (might “work” with registry setting); or maybe it relates specifically to the exception handling case? – user2864740 Sep 22 '19 at 04:39
  • 1
    Not sure; it's something I would test out myself but I'm not near a PC right now. It does look like a strange coding pattern, to have a method that passes back an exception via an out. I'd like to see if that was relevant to the actual problem being complained of – Caius Jard Sep 22 '19 at 04:57