From 6b339bb179dd61612b60e963299747ff36a86e16 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 24 Aug 2016 11:15:43 -0700 Subject: [PATCH 1/4] Improve OmniSharp options - Add new configuration for OmniSharp-specific options: "omnisharp" - Rename "csharp.omnisharp" to "omnisharp.path" (legacy option is still supported) - Rename "csharp.omnisharpUsesMono" to "omnisharp.useMono" (legacy option is still supported) - Add new option "omnisharp.loggingLevel" which can be set to "verbose". This enables debugging output from the OmniSharp server. --- src/omnisharp/omnisharp.ts | 3 ++- src/omnisharp/server.ts | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/omnisharp/omnisharp.ts b/src/omnisharp/omnisharp.ts index f07246ba7c..8d83c5f1bf 100644 --- a/src/omnisharp/omnisharp.ts +++ b/src/omnisharp/omnisharp.ts @@ -15,7 +15,8 @@ import * as path from 'path'; export interface Options { path?: string; - usesMono?: boolean; + useMono?: boolean; + loggingLevel?: string; } export enum Flavor { diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 680e92abb9..0a288ccc42 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -104,12 +104,26 @@ export abstract class OmnisharpServer { } private _readOptions(): omnisharp.Options { - const config = vscode.workspace.getConfiguration('csharp'); + // Extra effort is taken below to ensure that legacy versions of options + // are supported below. In particular, these are: + // + // - "csharp.omnisharp" -> "omnisharp.path" + // - "csharp.omnisharpUsesMono" -> "omnisharp.useMono" - return { - path: config.get('omnisharp'), - usesMono: config.get('omnisharpUsesMono') - }; + const omnisharpConfig = vscode.workspace.getConfiguration('omnisharp'); + const csharpConfig = vscode.workspace.getConfiguration('csharp'); + + const path = omnisharpConfig.has('path') + ? omnisharpConfig.get('path') + : csharpConfig.get('omnisharp'); + + const useMono = omnisharpConfig.has('useMono') + ? omnisharpConfig.get('useMono') + : csharpConfig.get('omnisharpUsesMono'); + + const loggingLevel = omnisharpConfig.get('loggingLevel'); + + return { path, useMono, loggingLevel }; } private _recordRequestDelay(requestName: string, elapsedTime: number) { @@ -237,7 +251,7 @@ export abstract class OmnisharpServer { const options = this._readOptions(); let flavor: omnisharp.Flavor; - if (options.path !== undefined && options.usesMono === true) { + if (options.path !== undefined && options.useMono === true) { flavor = omnisharp.Flavor.Mono; } else { @@ -250,11 +264,17 @@ export abstract class OmnisharpServer { const solutionPath = launchTarget.target; const cwd = dirname(solutionPath); - const args = [ + let args = [ '-s', solutionPath, '--hostPID', process.pid.toString(), 'DotNet:enablePackageRestore=false' - ].concat(this._extraArgs); + ]; + + if (options.loggingLevel === 'verbose') { + args.push('-v'); + } + + args = args.concat(this._extraArgs); this._fireEvent(Events.StdOut, `[INFO] Starting OmniSharp at '${solutionPath}'...\n`); this._fireEvent(Events.BeforeServerStart, solutionPath); From c3bff7eacad9329c5f61c23d10096a964b7a4c30 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 24 Aug 2016 14:21:36 -0700 Subject: [PATCH 2/4] Add configuration for new OmniSharp options in package.json --- package.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/package.json b/package.json index def2a9fa39..678917d9db 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,28 @@ "type": "boolean", "default": false, "description": "Suppress the warning that the .NET CLI is not on the path." + }, + "omnisharp.path": { + "type": [ + "string", + "null" + ], + "default": null, + "description": "Specifies the full path to the OmniSharp server." + }, + "omnisharp.useMono": { + "type": "boolean", + "default": false, + "description": "Launch OmniSharp with Mono." + }, + "omnisharp.loggingLevel": { + "type": "string", + "default": "default", + "enum": [ + "default", + "verbose" + ], + "description": "Specifies the level of logging output from the OmniSharp server." } } }, From 187dfc74b9a76d5fa81ecea2144e8ffba4d188a6 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 24 Aug 2016 14:41:31 -0700 Subject: [PATCH 3/4] Update text that reference old options --- src/omnisharp/server.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 0a288ccc42..5ec61bc629 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -411,7 +411,7 @@ export abstract class OmnisharpServer { return omnisharp.findServerPath(options.path).then(serverPath => { return resolve(serverPath); }).catch(err => { - vscode.window.showWarningMessage(`Invalid "csharp.omnisharp" user setting specified ('${options.path}).`); + vscode.window.showWarningMessage(`Invalid value specified for "omnisharp.path" ('${options.path}).`); return reject(err); }); } @@ -429,9 +429,9 @@ export abstract class OmnisharpServer { this._channel.appendLine(" 1. If it's not already installed, download and install Mono (https://www.mono-project.com)"); this._channel.appendLine(" 2. Download and untar the latest OmniSharp Mono release from https://github.com/OmniSharp/omnisharp-roslyn/releases/"); this._channel.appendLine(" 3. In Visual Studio Code, select Preferences->User Settings to open settings.json."); - this._channel.appendLine(" 4. In settings.json, add a new setting: \"csharp.omnisharp\": \"/path/to/omnisharp/OmniSharp.exe\""); - this._channel.appendLine(" 4. In settings.json, add a new setting: \"csharp.omnisharpUsesMono\": true"); - this._channel.appendLine(" 5. Restart Visual Studio Code."); + this._channel.appendLine(" 4. In settings.json, add a new setting: \"omnisharp.path\": \"/path/to/omnisharp/OmniSharp.exe\""); + this._channel.appendLine(" 5. In settings.json, add a new setting: \"omnisharp.useMono\": true"); + this._channel.appendLine(" 6. Restart Visual Studio Code."); this._channel.show(); throw err; From 1e2dc9fa132ba1e2a51f127d28cea19d54c0a83c Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 24 Aug 2016 14:43:47 -0700 Subject: [PATCH 4/4] tweak whitespace --- src/omnisharp/omnisharp.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/omnisharp/omnisharp.ts b/src/omnisharp/omnisharp.ts index 8d83c5f1bf..d5794d86ea 100644 --- a/src/omnisharp/omnisharp.ts +++ b/src/omnisharp/omnisharp.ts @@ -14,8 +14,8 @@ import * as fs from 'fs-extra-promise'; import * as path from 'path'; export interface Options { - path?: string; - useMono?: boolean; + path?: string; + useMono?: boolean; loggingLevel?: string; }