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
46 changes: 45 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,35 @@
"command": "razor.reportIssue",
"title": "Report a Razor issue",
"category": "Razor"
},
{
"command": "dotnet.test.runTestsInContext",
"title": "Run Tests in Context",
"category": ".NET"
},
{
"command": "dotnet.test.debugTestsInContext",
"title": "Debug Tests in Context",
"category": ".NET"
}
],
"keybindings": [
{
"command": "o.showOutput",
"key": "Ctrl+Shift+F9",
"mac": "Cmd+Shift+F9"
},
{
"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

"when": "editorLangId == csharp && editorTextFocus"
},
{
"command": "dotnet.test.debugTestsInContext",
"key": "ctrl+r ctrl+t",
"mac": "cmd+r cmd+t",
"when": "editorLangId == csharp && editorTextFocus"
}
],
"snippets": [
Expand Down Expand Up @@ -3249,7 +3271,29 @@
"command": "razor.reportIssue",
"when": "resourceLangId == aspnetcorerazor"
}
],
"editor/context": [
{
"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

},
{
"command": "dotnet.test.debugTestsInContext",
"when": "editorLangId == csharp",
"group": "2_dotnet@2"
}
],
"commandPalette": [
{
"command": "dotnet.test.runTestsInContext",
"when": "editorLangId == csharp"
},
{
"command": "dotnet.test.debugTestsInContext",
"when": "editorLangId == csharp"
}
]
}
}
}
}
7 changes: 3 additions & 4 deletions src/features/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
const quickFixes = result.QuickFixes;
const count = quickFixes.length;
const locations = quickFixes.map(toLocation);

// Allow language middlewares to re-map its edits if necessary.
const remappedLocations = await this._languageMiddlewareFeature.remap("remapLocations", locations, token);

Expand Down Expand Up @@ -166,9 +166,8 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
catch (error) {
return undefined;
}

// We do not support running all tests on legacy projects.
if (projectInfo.MsBuildProject && !projectInfo.DotNetProject) {

if (projectInfo.MsBuildProject) {
codeLens.command = {
title: pluralTitle,
command: pluralCommandName,
Expand Down
8 changes: 0 additions & 8 deletions src/features/diagnosticsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,12 @@ export class Advisor {
}

private _addOrUpdateProjectFileCount(info: protocol.ProjectInformationResponse): void {
if (info.DotNetProject && info.DotNetProject.SourceFiles) {
this._updateProjectFileCount(info.DotNetProject.Path, info.DotNetProject.SourceFiles.length);
}

if (info.MsBuildProject && info.MsBuildProject.SourceFiles) {
this._updateProjectFileCount(info.MsBuildProject.Path, info.MsBuildProject.SourceFiles.length);
}
}

private _removeProjectFileCount(info: protocol.ProjectInformationResponse): void {
if (info.DotNetProject && info.DotNetProject.SourceFiles) {
delete this._projectSourceFileCounts[info.DotNetProject.Path];
}

if (info.MsBuildProject && info.MsBuildProject.SourceFiles) {
delete this._projectSourceFileCounts[info.MsBuildProject.Path];
}
Expand Down
Loading