Skip to content

Commit 7d416b1

Browse files
Merge pull request #1844 from OmniSharp/master
Merge master into release
2 parents e20c819 + 7dfb3af commit 7d416b1

38 files changed

+656
-150
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ out
99
install.*
1010

1111
*.vsix
12+
13+
obj/
14+
bin/

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ addons:
1414
apt:
1515
sources:
1616
- ubuntu-toolchain-r-test
17+
- sourceline: 'deb https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main'
18+
key_url: 'https://packages.microsoft.com/keys/microsoft.asc'
1719
packages:
1820
- g++-4.9
1921
- libsecret-1-dev
22+
- dotnet-sdk-2.0.2
2023

2124
install:
2225
- npm install

.vscode/launch.json

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,51 @@
1616
]
1717
},
1818
{
19-
"name": "Launch Tests",
19+
"name": "Launch Unit Tests",
2020
"type": "extensionHost",
2121
"request": "launch",
2222
"runtimeExecutable": "${execPath}",
23-
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
23+
"args": [
24+
"--extensionDevelopmentPath=${workspaceRoot}",
25+
"--extensionTestsPath=${workspaceRoot}/out/test/unitTests"
26+
],
27+
"stopOnEntry": false,
28+
"sourceMaps": true,
29+
"outFiles": [
30+
"${workspaceRoot}/out/test/**/*.js"
31+
]
32+
},
33+
{
34+
"name": "Launch singleCsproj Workspace Tests",
35+
"type": "extensionHost",
36+
"request": "launch",
37+
"runtimeExecutable": "${execPath}",
38+
"args": [
39+
"${workspaceRoot}/test/integrationTests/testAssets/singleCsproj",
40+
"--extensionDevelopmentPath=${workspaceRoot}",
41+
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
42+
],
43+
"stopOnEntry": false,
44+
"sourceMaps": true,
45+
"outFiles": [
46+
"${workspaceRoot}/out/test/**/*.js"
47+
]
48+
},
49+
{
50+
"name": "Launch slnWithCsproj Workspace Tests",
51+
"type": "extensionHost",
52+
"request": "launch",
53+
"runtimeExecutable": "${execPath}",
54+
"args": [
55+
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj",
56+
"--extensionDevelopmentPath=${workspaceRoot}",
57+
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
58+
],
2459
"stopOnEntry": false,
2560
"sourceMaps": true,
2661
"outFiles": [
2762
"${workspaceRoot}/out/test/**/*.js"
2863
]
2964
}
3065
]
31-
}
66+
}

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"**/node_modules": true,
1212
"out/": true
1313
},
14+
15+
"csharp.suppressDotnetRestoreNotification": true,
1416

1517
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib",
1618
"typescript.tsdk": "./node_modules/typescript/lib"

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
"vscode:prepublish": "tsc -p ./",
2727
"compile": "tsc -p ./ && gulp tslint",
2828
"watch": "tsc -watch -p ./",
29-
"test": "node ./node_modules/vscode/bin/test",
29+
"test": "npm-run-all test:unit test:integration",
30+
"test:unit": "cross-env CODE_TESTS_PATH=./out/test/unitTests npm run test:runInVsCode",
31+
"test:integration": "npm-run-all test:integration:*",
32+
"test:integration:singleCsproj": "cross-env OSVC_SUITE=singleCsproj npm run test:runSuiteInVsCode",
33+
"test:integration:slnWithCsproj": "cross-env OSVC_SUITE=slnWithCsproj npm run test:runSuiteInVsCode",
34+
"test:runSuiteInVsCode": "cross-env CODE_TESTS_PATH=./out/test/integrationTests CODE_TESTS_WORKSPACE=./test/integrationTests/testAssets/$OSVC_SUITE npm run test:runInVsCode",
35+
"test:runInVsCode": "node ./test/runVsCodeTestsWithAbsolutePaths.js",
3036
"postinstall": "node ./node_modules/vscode/bin/install"
3137
},
3238
"dependencies": {
@@ -46,18 +52,24 @@
4652
},
4753
"devDependencies": {
4854
"@types/chai": "^3.4.34",
55+
"@types/chai-arrays": "^1.0.2",
4956
"@types/fs-extra": "4.0.3",
5057
"@types/mkdirp": "^0.3.29",
5158
"@types/mocha": "^2.2.32",
5259
"@types/node": "^6.0.40",
5360
"@types/semver": "^5.3.30",
5461
"@types/tmp": "0.0.32",
62+
"async-file": "^2.0.2",
5563
"chai": "^3.5.0",
64+
"chai-arrays": "^2.0.0",
65+
"chai-fs": "^1.0.0",
66+
"cross-env": "^5.1.1",
5667
"del": "^2.0.2",
5768
"gulp": "^3.9.1",
5869
"gulp-mocha": "^2.1.3",
5970
"gulp-tslint": "^4.3.0",
6071
"mocha": "^2.3.3",
72+
"npm-run-all": "^4.1.1",
6173
"plist": "^2.0.1",
6274
"tslint": "^3.15.1",
6375
"tslint-microsoft-contrib": "^2.0.12",

src/assets.ts

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66
import * as fs from 'fs-extra';
77
import * as path from 'path';
8-
import * as vscode from 'vscode';
8+
import * as protocol from './omnisharp/protocol';
9+
import * as serverUtils from './omnisharp/utils';
910
import * as tasks from 'vscode-tasks';
11+
import * as util from './common';
12+
import * as vscode from 'vscode';
13+
1014
import { OmniSharpServer } from './omnisharp/server';
11-
import * as serverUtils from './omnisharp/utils';
12-
import * as protocol from './omnisharp/protocol';
1315
import { tolerantParse } from './json';
14-
import * as util from './common';
1516

1617
export class AssetGenerator {
17-
public rootPath: string;
18+
public workspaceFolder: vscode.WorkspaceFolder;
1819
public vscodeFolder: string;
1920
public tasksJsonPath: string;
2021
public launchJsonPath: string;
@@ -26,13 +27,33 @@ export class AssetGenerator {
2627
private executableName: string;
2728
private configurationName: string;
2829

29-
public constructor(workspaceInfo: protocol.WorkspaceInformationResponse, rootPath: string = vscode.workspace.rootPath) {
30-
if (rootPath === null || rootPath === undefined) {
31-
throw new Error('rootPath must set.');
30+
public constructor(workspaceInfo: protocol.WorkspaceInformationResponse, workspaceFolder: vscode.WorkspaceFolder = undefined) {
31+
if (workspaceFolder) {
32+
this.workspaceFolder = workspaceFolder;
3233
}
34+
else {
35+
let resourcePath: string = undefined;
36+
37+
if (!resourcePath && workspaceInfo.Cake) {
38+
resourcePath = workspaceInfo.Cake.Path;
39+
}
3340

34-
this.rootPath = rootPath;
35-
this.vscodeFolder = path.join(this.rootPath, '.vscode');
41+
if (!resourcePath && workspaceInfo.ScriptCs) {
42+
resourcePath = workspaceInfo.ScriptCs.Path;
43+
}
44+
45+
if (!resourcePath && workspaceInfo.DotNet && workspaceInfo.DotNet.Projects.length > 0) {
46+
resourcePath = workspaceInfo.DotNet.Projects[0].Path;
47+
}
48+
49+
if (!resourcePath && workspaceInfo.MsBuild) {
50+
resourcePath = workspaceInfo.MsBuild.SolutionPath;
51+
}
52+
53+
this.workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(resourcePath));
54+
}
55+
56+
this.vscodeFolder = path.join(this.workspaceFolder.uri.fsPath, '.vscode');
3657
this.tasksJsonPath = path.join(this.vscodeFolder, 'tasks.json');
3758
this.launchJsonPath = path.join(this.vscodeFolder, 'launch.json');
3859

@@ -132,15 +153,15 @@ export class AssetGenerator {
132153
let result = '${workspaceFolder}';
133154

134155
if (this.projectPath) {
135-
result = path.join(result, path.relative(this.rootPath, this.projectPath));
156+
result = path.join(result, path.relative(this.workspaceFolder.uri.fsPath, this.projectPath));
136157
}
137158

138159
result = path.join(result, `bin/${this.configurationName}/${this.targetFramework}/${this.executableName}`);
139160

140161
return result;
141162
}
142163

143-
private computeWorkingDirectory() : string {
164+
private computeWorkingDirectory(): string {
144165
if (!this.hasProject) {
145166
// If there's no target project data, use a placeholder for the path.
146167
return '${workspaceFolder}';
@@ -149,7 +170,7 @@ export class AssetGenerator {
149170
let result = '${workspaceFolder}';
150171

151172
if (this.projectPath) {
152-
result = path.join(result, path.relative(this.rootPath, this.projectPath));
173+
result = path.join(result, path.relative(this.workspaceFolder.uri.fsPath, this.projectPath));
153174
}
154175

155176
return result;
@@ -179,7 +200,7 @@ export class AssetGenerator {
179200
private createBuildTaskDescription(): tasks.TaskDescription {
180201
let buildPath = '';
181202
if (this.hasProject) {
182-
buildPath = path.join('${workspaceFolder}', path.relative(this.rootPath, this.projectFilePath));
203+
buildPath = path.join('${workspaceFolder}', path.relative(this.workspaceFolder.uri.fsPath, this.projectFilePath));
183204
}
184205

185206
return {
@@ -235,7 +256,7 @@ export function createWebLaunchConfiguration(programPath: string, workingDirecto
235256
}`;
236257
}
237258

238-
export function createLaunchConfiguration(programPath: string, workingDirectory: string): string {
259+
export function createLaunchConfiguration(programPath: string, workingDirectory: string): string {
239260
return `
240261
{
241262
"name": ".NET Core Launch (console)",
@@ -378,13 +399,13 @@ interface PromptItem extends vscode.MessageItem {
378399
result: PromptResult;
379400
}
380401

381-
function promptToAddAssets() {
402+
function promptToAddAssets(workspaceFolder: vscode.WorkspaceFolder) {
382403
return new Promise<PromptResult>((resolve, reject) => {
383404
const yesItem: PromptItem = { title: 'Yes', result: PromptResult.Yes };
384405
const noItem: PromptItem = { title: 'Not Now', result: PromptResult.No, isCloseAffordance: true };
385406
const disableItem: PromptItem = { title: "Don't Ask Again", result: PromptResult.Disable };
386407

387-
const projectName = path.basename(vscode.workspace.rootPath);
408+
const projectName = path.basename(workspaceFolder.uri.fsPath);
388409

389410
vscode.window.showWarningMessage(
390411
`Required assets to build and debug are missing from '${projectName}'. Add them?`, disableItem, noItem, yesItem)
@@ -463,7 +484,7 @@ export enum AddAssetResult {
463484

464485
export function addAssetsIfNecessary(server: OmniSharpServer): Promise<AddAssetResult> {
465486
return new Promise<AddAssetResult>((resolve, reject) => {
466-
if (!vscode.workspace.rootPath) {
487+
if (!vscode.workspace.workspaceFolders) {
467488
return resolve(AddAssetResult.NotApplicable);
468489
}
469490

@@ -476,7 +497,7 @@ export function addAssetsIfNecessary(server: OmniSharpServer): Promise<AddAssetR
476497
return resolve(AddAssetResult.NotApplicable);
477498
}
478499

479-
promptToAddAssets().then(result => {
500+
promptToAddAssets(generator.workspaceFolder).then(result => {
480501
if (result === PromptResult.Disable) {
481502
return resolve(AddAssetResult.Disable);
482503
}
@@ -546,24 +567,20 @@ function shouldGenerateAssets(generator: AssetGenerator) {
546567
});
547568
}
548569

549-
export function generateAssets(server: OmniSharpServer) {
550-
serverUtils.requestWorkspaceInformation(server).then(info => {
551-
if (protocol.containsDotNetCoreProjects(info)) {
552-
const generator = new AssetGenerator(info);
553-
getOperations(generator).then(operations => {
554-
if (hasAddOperations(operations)) {
555-
shouldGenerateAssets(generator).then(res => {
556-
if (res) {
557-
fs.ensureDir(generator.vscodeFolder, err => {
558-
addAssets(generator, operations);
559-
});
560-
}
561-
});
562-
}
563-
});
564-
}
565-
else {
566-
vscode.window.showErrorMessage("Could not locate .NET Core project. Assets were not generated.");
570+
export async function generateAssets(server: OmniSharpServer) {
571+
let workspaceInformation = await serverUtils.requestWorkspaceInformation(server);
572+
if (protocol.containsDotNetCoreProjects(workspaceInformation)) {
573+
const generator = new AssetGenerator(workspaceInformation);
574+
let operations = await getOperations(generator);
575+
if (hasAddOperations(operations)) {
576+
let doGenerateAssets = await shouldGenerateAssets(generator);
577+
if (doGenerateAssets) {
578+
await fs.ensureDir(generator.vscodeFolder);
579+
await addAssets(generator, operations);
580+
}
567581
}
568-
});
582+
}
583+
else {
584+
await vscode.window.showErrorMessage("Could not locate .NET Core project. Assets were not generated.");
585+
}
569586
}

src/configurationProvider.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as vscode from 'vscode';
76
import * as fs from 'fs-extra';
87
import * as path from 'path';
9-
import { parse } from 'jsonc-parser';
10-
import { OmniSharpServer } from './omnisharp/server';
118
import * as serverUtils from './omnisharp/utils';
9+
import * as vscode from 'vscode';
10+
11+
import { AssetGenerator, addTasksJsonIfNecessary, createAttachConfiguration, createLaunchConfiguration, createWebLaunchConfiguration } from './assets';
12+
13+
import { OmniSharpServer } from './omnisharp/server';
1214
import { containsDotNetCoreProjects } from './omnisharp/protocol';
13-
import { AssetGenerator, addTasksJsonIfNecessary, createLaunchConfiguration, createAttachConfiguration, createWebLaunchConfiguration } from './assets';
1415
import { isSubfolderOf } from './common';
16+
import { parse } from 'jsonc-parser';
1517

1618
export class CSharpConfigurationProvider implements vscode.DebugConfigurationProvider {
1719
private server: OmniSharpServer;
@@ -101,7 +103,7 @@ export class CSharpConfigurationProvider implements vscode.DebugConfigurationPro
101103
/**
102104
* Try to add all missing attributes to the debug configuration being launched.
103105
*/
104-
resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
106+
resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
105107
// vsdbg does the error checking
106108
return config;
107109
}

src/coreclr-debug/activate.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,49 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import * as vscode from 'vscode';
7+
import * as debugInstall from './install';
88
import * as os from 'os';
9-
import TelemetryReporter from 'vscode-extension-telemetry';
9+
import * as vscode from 'vscode';
10+
1011
import { CoreClrDebugUtil, DotnetInfo, } from './util';
11-
import * as debugInstall from './install';
12+
1213
import { Logger } from './../logger';
1314
import { PlatformInformation } from './../platform';
15+
import TelemetryReporter from 'vscode-extension-telemetry';
1416

1517
let _debugUtil: CoreClrDebugUtil = null;
1618
let _reporter: TelemetryReporter = null;
1719
let _logger: Logger = null;
1820

19-
export function activate(thisExtension : vscode.Extension<any>, context: vscode.ExtensionContext, reporter: TelemetryReporter, logger: Logger, channel: vscode.OutputChannel) {
21+
export async function activate(thisExtension : vscode.Extension<any>, context: vscode.ExtensionContext, reporter: TelemetryReporter, logger: Logger, channel: vscode.OutputChannel) {
2022
_debugUtil = new CoreClrDebugUtil(context.extensionPath, logger);
2123
_reporter = reporter;
2224
_logger = logger;
2325

2426
if (!CoreClrDebugUtil.existsSync(_debugUtil.debugAdapterDir())) {
25-
PlatformInformation.GetCurrent().then((info) => {
26-
if (info.architecture !== "x86_64") {
27-
if (info.isWindows() && info.architecture === "x86") {
27+
let platformInformation: PlatformInformation;
28+
29+
try {
30+
platformInformation = await PlatformInformation.GetCurrent();
31+
}
32+
catch (err) {
33+
// Somehow we couldn't figure out the platform we are on
34+
logger.appendLine("[ERROR]: C# Extension failed to install the debugger package");
35+
showInstallErrorMessage(channel);
36+
}
37+
38+
if (platformInformation) {
39+
if (platformInformation.architecture !== "x86_64") {
40+
if (platformInformation.isWindows() && platformInformation.architecture === "x86") {
2841
logger.appendLine(`[WARNING]: x86 Windows is not currently supported by the .NET Core debugger. Debugging will not be available.`);
2942
} else {
30-
logger.appendLine(`[WARNING]: Processor architecture '${info.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`);
43+
logger.appendLine(`[WARNING]: Processor architecture '${platformInformation.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`);
3144
}
3245
} else {
3346
logger.appendLine("[ERROR]: C# Extension failed to install the debugger package");
3447
showInstallErrorMessage(channel);
3548
}
36-
}, (err) => {
37-
// Somehow we couldn't figure out the platform we are on
38-
logger.appendLine("[ERROR]: C# Extension failed to install the debugger package");
39-
showInstallErrorMessage(channel);
40-
});
49+
}
4150
} else if (!CoreClrDebugUtil.existsSync(_debugUtil.installCompleteFilePath())) {
4251
completeDebuggerInstall(logger, channel);
4352
}

0 commit comments

Comments
 (0)