Skip to content

Add support for "justMyCode" debugger option #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SeeminglyScience opened this issue Jan 24, 2018 · 10 comments
Open

Add support for "justMyCode" debugger option #618

SeeminglyScience opened this issue Jan 24, 2018 · 10 comments
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).

Comments

@SeeminglyScience
Copy link
Collaborator

Debugging a test and stepping in and out of Pester can be frustrating. It'd be nice if we could have an option to automatically step through to the next in-workspace stop.

@TylerLeonhardt
Copy link
Member

Can you elaborate on this one some more?

@TylerLeonhardt TylerLeonhardt added Issue-Enhancement A feature request (enhancement). Area-Debugging labels Jan 25, 2018
@SeeminglyScience
Copy link
Collaborator Author

justMyCode is a common option in debuggers that makes it so you don't step into code outside of your project. For example, if you had the following code in C#

var userInput = System.Console.ReadKey();
return userInput;

If the debugger was stopped on line one, and you "step into" (F11) you would continue to line 2 instead of stepping into the code for System.Console.ReadKey()

@CJHarmath
Copy link

+1 yes it's indeed very frustrating to keep jumping into Pester's It.ps1, Should.ps1, etc when trying to debug / step into a test.

@tylerl0706 here is more on the "Just My Code" https://docs.microsoft.com/en-us/visualstudio/debugger/just-my-code which is available in Visual Studio and it' super useful

Imagine a largish powershell module with a bunch of tests where you would want to debug a failing test to better see what went wrong. While step into the code, you will end up in the Pester functions which is not at all what you would want to debug.

Node has a skipFiles setting in launch.json and the reason is that they don't want to step into the 3rd party node modules either while debugging.

We would need something like that for PowerShell, so you can configure what files / modules do you want to step into or step over.

skipFiles might not be the best in this case, we would rather want a flag for "debug only files in this folders" I suppose.

Perhaps something like this ?

"includeFiles": [
                "**/*.ps*1", // by default add this. so we only debug files in the current folder. i.e.: Just My Code
                "../myOtherModuleIWantToDebug/**/*.ps*1" // if there are other modules to debug add their paths as well with globbing
            ]

@rjmholt
Copy link
Contributor

rjmholt commented Aug 1, 2018

This looks like added impetus for the ask in PowerShell/vscode-powershell#1039.

I'd imagine this would be useful for codeLens and the debugger alike, with the default being only files in the current workspace.

@rkeithhill
Copy link
Contributor

Is this something we can implement in the extension? Seems like support for this should be wired into the PowerShell debugger within the PowerShell engine. Of course, it would need input in terms of what is "my code".

@rjmholt
Copy link
Contributor

rjmholt commented Aug 1, 2018

Ah good point! Perhaps we should open an issue with PowerShell. Then we would just need to route a VSCode configuration through (if that is the best design...)

@rkeithhill
Copy link
Contributor

rkeithhill commented Aug 1, 2018

Or maybe provide a callback where PSES could say whether or not the "file location" is considered "my code" (or not).

@rjmholt
Copy link
Contributor

rjmholt commented Aug 1, 2018

Another consideration is that we'll probably have to implement this feature ourselves at least somewhat, since it will never find its way back into PowerShell v5.

@SeeminglyScience
Copy link
Collaborator Author

It probably wouldn't be too difficult to implement in PSES.

Because we use a custom host, we have to implement a lot of the debugger stop logic anyway. We just hook into the Debugger.OnDebuggerStop event and start a prompt. All we'd have to do is test the invocation info from the debugger stop args, if it's "my code" then continue like normal, if it isn't then set the continuation action and exit the method.

Even if PowerShell supports it, we'd probably have to write our own logic anyway.

@KirkMunro
Copy link

KirkMunro commented Sep 28, 2019

Please have a look at Issue #10530 in PowerShell/PowerShell for some thoughts I've been developing related to Just-My-Code debugging. This should be added to PowerShell itself, in such a way that tooling can leverage and support it.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 28, 2019
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

6 participants