Skip to content
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

Add vscode implemention of the 'RunTestsInContext' and `DebugTestsInContext' commands #3772

Merged
merged 9 commits into from
May 13, 2020

Conversation

333fred
Copy link
Member

@333fred 333fred commented May 9, 2020

This is the omnisharp-vsocde side of OmniSharp/omnisharp-roslyn#1782. I've implemented support for both of those commands, and bound them to the same default shortcuts as in VS proper. These commands can also be invoked from the command palette.

I've also done a small bit of refactoring to remove references to legacy project.json support. There is no support for loading this project type in Omnisharp anymore, so this was cruft that was unnecessary at this point.

…ontext' commands

This is the omnisharp-vsocde side of OmniSharp/omnisharp-roslyn#1782. I've implemented support for both of those commands, and bound them to the same default shortcuts as in VS proper. These commands can also be invoked from the command palette.

I've also done a small bit of refactoring to remove references to legacy project.json support. There is no support for loading this project type in Omnisharp anymore, so this was cruft that was unnecessary at this point.
@333fred
Copy link
Member Author

333fred commented May 10, 2020

Some screenshots:

image

image

image

image

image

image

Note: that last one is hard to actually get, you have to bind the command to your own keyboard shortcut without a when clause or edit the existing when clause.

@codecov
Copy link

codecov bot commented May 10, 2020

Codecov Report

Merging #3772 into master will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3772      +/-   ##
==========================================
+ Coverage   87.03%   87.16%   +0.12%     
==========================================
  Files          59       59              
  Lines        1782     1800      +18     
  Branches      207      207              
==========================================
+ Hits         1551     1569      +18     
  Misses        176      176              
  Partials       55       55              
Flag Coverage Δ
#integration 100.00% <ø> (ø)
#unit 87.16% <100.00%> (+0.12%) ⬆️
Impacted Files Coverage Δ
src/observers/DotnetTestChannelObserver.ts 100.00% <ø> (ø)
src/observers/DotnetTestLoggerObserver.ts 98.75% <100.00%> (+0.13%) ⬆️
src/omnisharp/EventType.ts 100.00% <100.00%> (ø)
src/omnisharp/loggingEvents.ts 97.98% <100.00%> (+0.06%) ⬆️
src/omnisharp/protocol.ts 77.69% <100.00%> (+0.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7012473...c1a022b. Read the comment docs.

{
"command": "dotnet.test.runTestsInContext",
"key": "ctrl+r t",
"mac": "cmd+r t",
Copy link
Member Author

@333fred 333fred May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually know what the keyboard shortcuts for run/debug tests in VS for Mac are, so I've just done the equivalent of the Windows ones. If there's a better one to use, I'm all ears.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those work for me

@@ -284,7 +284,6 @@ export interface AutoCompleteResponse {

export interface ProjectInformationResponse {
MsBuildProject: MSBuildProject;
DotNetProject: DotNetProject;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omnisharp no longer has a project information provider for project.json projects, so anything that used this was not used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing!

@@ -477,8 +476,10 @@ export namespace V2 {
export const GetTestStartInfo = '/v2/getteststartinfo';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command can probably be removed as well, as it was used by the project.json support. Let me know if you'd like me to go through and remove it as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are interested, you could remove in a follow up PR or open a tracking issue with the suggestion. Thanks!

Copy link
Contributor

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, this is great.


const request: protocol.V2.DebugTestsInContextGetStartInfoRequest = {
FileName: fileName,
Line: line + 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this due to vscode using zero-indexed positions while roslyn uses one-indexed positions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's because the deserializer expects the incoming position to be 1-indexed. Both vscode and roslyn actually expect 0-indexed.

{
"command": "dotnet.test.runTestsInContext",
"key": "ctrl+r t",
"mac": "cmd+r t",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those work for me

@@ -284,7 +284,6 @@ export interface AutoCompleteResponse {

export interface ProjectInformationResponse {
MsBuildProject: MSBuildProject;
DotNetProject: DotNetProject;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing!

@@ -477,8 +476,10 @@ export namespace V2 {
export const GetTestStartInfo = '/v2/getteststartinfo';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are interested, you could remove in a follow up PR or open a tracking issue with the suggestion. Thanks!

JoeRobich and others added 4 commits May 11, 2020 13:59
…in an editor

These commands are sorted below rename and other modification actions. Default groups in vscode are documented here: https://code.visualstudio.com/api/references/contribution-points#Sorting-of-groups. 2_ is below modification, and the `@` is used for relative ordering of commands in a group.
@333fred
Copy link
Member Author

333fred commented May 13, 2020

I've additionally added the commands to the right-click context menu in C# editors. They looks like this:
image

{
"command": "dotnet.test.runTestsInContext",
"when": "editorLangId == csharp",
"group": "2_dotnet@1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vscode groups are documented here: https://code.visualstudio.com/api/references/contribution-points#Sorting-of-groups

2_ puts them after find all refs/rename, but before copy/paste. The @ symbol on the end denotes relative ordering of commands in a group.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dig it

@JoeRobich JoeRobich merged commit 74cb376 into dotnet:master May 13, 2020
@333fred 333fred deleted the runtestsincontext branch May 13, 2020 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants