OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.7k stars 169 forks source link

Debug tests vstest #734

Closed jpfeiffer16 closed 2 years ago

jpfeiffer16 commented 2 years ago

This is a better option for test debugging.

It uses the omnisharp

/v2/debugtest/getstartinfo
/v2/debugtest/launch

endpoints and then attaches vimspector to it. It then calls

/v2/debugtest/stop

to close out the session.

This depends on puremourning/vimspector/pull/473

nickspoons commented 2 years ago

This looks really great, I'll make some time and try it out this weekend (although I suppose we can't merge it until the Vimspector PR is merged).

jpfeiffer16 commented 2 years ago

Yea. You can check out that vimspector branch in your bundles folder to test it out if you don't want to wait till it's merged to test it.

nickspoons commented 2 years ago

It works! :tada:

This is so great - and the vimspector PR is really useful too. We should add a generic :OmniSharpDebug command as well, to start Vimspector debugging the current project (for non-test projects).

jpfeiffer16 commented 2 years ago

Yea. That's a good idea. We couldn't do anything to advanced with that since the configuration would be missing anything more than running it, it wouldn't be able to pass arguments to the program or anything. What is also compelling to complement that would be a feature to write a .vimspector.json file to disk for the current project for you kinda like the vscode debug configuration stuff.

So you could just start a project and hit a binding, and start it up in debug mode. Once you have a more complex program that requires arguments etc, you could hit another binding and have omnisharp generate a vimspector config for you. I think that would be pretty cool.

Another thing that I've noticed now since using vimspector more is the REPL evaluation is not great. There is room for improvement there. I do use that a lot in VSCode, so maybe that's something that would be able to be contributed to. I haven't really looked at it to much yet.

nickspoons commented 2 years ago

Hey I ran into an issue when testing further last night. I haven't been able to nail down exactly what the problem is but here's where I got to.

When launching vim from the project root (either .sln or .csproj directory I think) the test debugging works. However when I launch vim from a higher directory (in this case the root of a larger multi-solution codebase) then attempts to debug tests fail. It builds and starts vimspector but vimspector doesn't do anything, never receives control.

I can use :OmniSharpRunTest successfully like this, so I think this might be a vimspector config issue? I tried including the project directory as the "cwd" property of the vimspector config but that didn't seem to help.

I'll experiment further later on.

jpfeiffer16 commented 2 years ago

Ok. Good to know, thanks. This may be related to a problem I am working on right now that I ran across in the vimspector tests I wrote. I will keep this in mind.

nickspoons commented 2 years ago

Thanks. This is minor, but could you please also have a look at the vint warnings? I'd prefer to keep these clean where possible, using single quotes for strings and adding abort to functions where it makes sense.

jpfeiffer16 commented 2 years ago

Sure!

jpfeiffer16 commented 2 years ago

@nickspoons . We are still trying to work things out in the vimspector pr. If we end up going with things as they are now, I will add a fix for this issue in here before we merge. It will involve cding to the directory of the the sln file when we debug and then cding back when we are done. Does that sound acceptable to you?

Also, do you want me to do a rebase?

nickspoons commented 2 years ago

Thanks Joe, I've been following the vimspector PR with interest.

It will involve cding to the directory of the the sln file when we debug and then cding back when we are done. Does that sound acceptable to you?

Yeah this is fine. When I've been trying this PR, this is the way I've been doing it.

Also, do you want me to do a rebase?

That's up to you. We don't have a super-clean commit history, I sometimes do a squash merge when commits are particularly non-descriptive or messy but normally I just merge PRs as they are.

jpfeiffer16 commented 2 years ago

Awesome. That PR is getting merged the way it is. I will add the fix in here.

nickspoons commented 2 years ago

Love it! Thanks Joe!

jpfeiffer16 commented 2 years ago

No problem. Thanks for taking it!