From cd7f5d29033e727b97078b8fc7be4483f9610d38 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 11:58:07 -0700 Subject: [PATCH 1/7] Introduce OmniSharpLaunchInfo type --- src/omnisharp/OmnisharpManager.ts | 18 +++++++++------- src/omnisharp/launcher.ts | 15 +++++++------- src/omnisharp/server.ts | 8 ++++---- test/featureTests/OmnisharpManager.test.ts | 24 +++++++++++----------- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/omnisharp/OmnisharpManager.ts b/src/omnisharp/OmnisharpManager.ts index aa843d44e6..95bd306a04 100644 --- a/src/omnisharp/OmnisharpManager.ts +++ b/src/omnisharp/OmnisharpManager.ts @@ -9,17 +9,21 @@ import * as util from '../common'; import { OmnisharpDownloader } from './OmnisharpDownloader'; import { PlatformInformation } from '../platform'; +export interface OmniSharpLaunchInfo { + LaunchPath: string; +} + export class OmnisharpManager { public constructor( private downloader: OmnisharpDownloader, private platformInfo: PlatformInformation) { } - public async GetOmnisharpPath(omnisharpPath: string, useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + public async GetOmnisharpPath(omnisharpPath: string, useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { // Looks at the options path, installs the dependencies and returns the path to be loaded by the omnisharp server if (path.isAbsolute(omnisharpPath)) { if (await util.fileExists(omnisharpPath)) { - return omnisharpPath; + return { LaunchPath: omnisharpPath }; } else { throw new Error('The system could not find the specified path'); @@ -33,7 +37,7 @@ export class OmnisharpManager { return await this.InstallVersionAndReturnLaunchPath(omnisharpPath, useMono, serverUrl, installPath, extensionPath); } - private async InstallLatestAndReturnLaunchPath(useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string) { + private async InstallLatestAndReturnLaunchPath(useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { let version = await this.downloader.GetLatestVersion(serverUrl, latestVersionFileServerPath); return await this.InstallVersionAndReturnLaunchPath(version, useMono, serverUrl, installPath, extensionPath); } @@ -49,7 +53,7 @@ export class OmnisharpManager { } } -function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string, useMono: boolean) { +function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string, useMono: boolean): OmniSharpLaunchInfo { if (!version) { throw new Error('Invalid Version'); } @@ -57,12 +61,12 @@ function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: str let basePath = path.resolve(extensionPath, installPath, version); if (platformInfo.isWindows()) { - return path.join(basePath, 'OmniSharp.exe'); + return { LaunchPath: path.join(basePath, 'OmniSharp.exe') }; } if (useMono) { - return path.join(basePath, 'omnisharp', 'OmniSharp.exe'); + return { LaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe') }; } - return path.join(basePath, 'run'); + return { LaunchPath: path.join(basePath, 'run') }; } diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index bec8ffe515..bdf611743f 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -10,6 +10,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as util from '../common'; import { Options } from './options'; +import { OmniSharpLaunchInfo } from './OmnisharpManager'; export enum LaunchTargetKind { Solution, @@ -204,9 +205,9 @@ export interface LaunchResult { usingMono: boolean; } -export async function launchOmniSharp(cwd: string, args: string[], launchPath: string): Promise { +export async function launchOmniSharp(cwd: string, args: string[], launchInfo: OmniSharpLaunchInfo): Promise { return new Promise((resolve, reject) => { - launch(cwd, args, launchPath) + launch(cwd, args, launchInfo) .then(result => { // async error - when target not not ENEOT result.process.on('error', err => { @@ -222,7 +223,7 @@ export async function launchOmniSharp(cwd: string, args: string[], launchPath: s }); } -async function launch(cwd: string, args: string[], launchPath: string): Promise { +async function launch(cwd: string, args: string[], launchInfo: OmniSharpLaunchInfo): Promise { return PlatformInformation.GetCurrent().then(platformInfo => { const options = Options.Read(); @@ -236,17 +237,17 @@ async function launch(cwd: string, args: string[], launchPath: string): Promise< } // If the user has provided an absolute path or the specified version has been installed successfully, we'll use the path. - if (launchPath) { + if (launchInfo.LaunchPath) { if (platformInfo.isWindows()) { - return launchWindows(launchPath, cwd, args); + return launchWindows(launchInfo.LaunchPath, cwd, args); } // If we're launching on macOS/Linux, we have two possibilities: // 1. Launch using Mono // 2. Launch process directly (e.g. a 'run' script) return options.useMono - ? launchNixMono(launchPath, cwd, args) - : launchNix(launchPath, cwd, args); + ? launchNixMono(launchInfo.LaunchPath, cwd, args) + : launchNix(launchInfo.LaunchPath, cwd, args); } // If the user has not provided a path, we'll use the locally-installed OmniSharp diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index d5431123fb..af0a491770 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -15,7 +15,7 @@ import { ReadLine, createInterface } from 'readline'; import { Request, RequestQueueCollection } from './requestQueue'; import { DelayTracker } from './delayTracker'; import { EventEmitter } from 'events'; -import { OmnisharpManager } from './OmnisharpManager'; +import { OmnisharpManager, OmniSharpLaunchInfo } from './OmnisharpManager'; import { Options } from './options'; import { PlatformInformation } from '../platform'; import { launchOmniSharp } from './launcher'; @@ -312,11 +312,11 @@ export class OmniSharpServer { args.push('--debug'); } - let launchPath: string; + let launchInfo: OmniSharpLaunchInfo; if (this._options.path) { try { let extensionPath = utils.getExtensionPath(); - launchPath = await this._omnisharpManager.GetOmnisharpPath(this._options.path, this._options.useMono, serverUrl, latestVersionFileServerPath, installPath, extensionPath); + launchInfo = await this._omnisharpManager.GetOmnisharpPath(this._options.path, this._options.useMono, serverUrl, latestVersionFileServerPath, installPath, extensionPath); } catch (error) { this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error)); @@ -327,7 +327,7 @@ export class OmniSharpServer { this.eventStream.post(new ObservableEvents.OmnisharpInitialisation(new Date(), solutionPath)); this._fireEvent(Events.BeforeServerStart, solutionPath); - return launchOmniSharp(cwd, args, launchPath).then(async value => { + return launchOmniSharp(cwd, args, launchInfo).then(async value => { this.eventStream.post(new ObservableEvents.OmnisharpLaunch(value.usingMono, value.command, value.process.pid)); this._serverProcess = value.process; diff --git a/test/featureTests/OmnisharpManager.test.ts b/test/featureTests/OmnisharpManager.test.ts index 55d45ebabb..5f7a0c2aeb 100644 --- a/test/featureTests/OmnisharpManager.test.ts +++ b/test/featureTests/OmnisharpManager.test.ts @@ -56,18 +56,18 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin test('Returns the same path if absolute path to an existing file is passed', async () => { tmpFile = tmp.fileSync(); - let omnisharpPath = await manager.GetOmnisharpPath(tmpFile.name, useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); - omnisharpPath.should.equal(tmpFile.name); + let launchInfo = await manager.GetOmnisharpPath(tmpFile.name, useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(tmpFile.name); }); test('Installs the latest version and returns the launch path based on the version and platform', async () => { - let omnisharpPath = await manager.GetOmnisharpPath("latest", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); - omnisharpPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + let launchInfo = await manager.GetOmnisharpPath("latest", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); }); test('Installs the test version and returns the launch path based on the version and platform', async () => { - let omnisharpPath = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); - omnisharpPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + let launchInfo = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); }); test('Downloads package from given url and installs them at the specified path', async () => { @@ -78,20 +78,20 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin test('Downloads package and returns launch path based on platform - Not using mono on Linux ', async () => { let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchPath = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run')); + let launchInfo = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run')); }); test('Downloads package and returns launch path based on platform - Using mono on Linux ', async () => { let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchPath = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe')); + let launchInfo = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe')); }); test('Downloads package and returns launch path based on install path ', async () => { let manager = GetTestOmnisharpManager(eventStream, platformInfo); - let launchPath = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, "installHere", extensionPath); - launchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe')); + let launchInfo = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, "installHere", extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe')); }); teardown(async () => { From 9a7eba40106081732d480cb66cc6c19ef632dbb2 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 11:59:29 -0700 Subject: [PATCH 2/7] Fix casing of 'OmniSharp' in user-facing error message --- src/omnisharp/OmnisharpManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omnisharp/OmnisharpManager.ts b/src/omnisharp/OmnisharpManager.ts index 95bd306a04..de87b300ee 100644 --- a/src/omnisharp/OmnisharpManager.ts +++ b/src/omnisharp/OmnisharpManager.ts @@ -48,7 +48,7 @@ export class OmnisharpManager { return GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath, useMono); } else { - throw new Error(`Invalid omnisharp version - ${version}`); + throw new Error(`Invalid OmniSharp version - ${version}`); } } } From b078c4a0bb5360f3bdc73254205f461546b83e85 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 15:18:49 -0700 Subject: [PATCH 3/7] Return both 'LaunchPath' and 'MonoLaunchPath' from OmniSharpManager --- src/omnisharp/OmnisharpManager.ts | 47 ++++++++++++---------- src/omnisharp/launcher.ts | 6 +-- src/omnisharp/server.ts | 6 +-- test/featureTests/OmnisharpManager.test.ts | 30 ++++++-------- 4 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/omnisharp/OmnisharpManager.ts b/src/omnisharp/OmnisharpManager.ts index de87b300ee..5074822a7d 100644 --- a/src/omnisharp/OmnisharpManager.ts +++ b/src/omnisharp/OmnisharpManager.ts @@ -9,8 +9,9 @@ import * as util from '../common'; import { OmnisharpDownloader } from './OmnisharpDownloader'; import { PlatformInformation } from '../platform'; -export interface OmniSharpLaunchInfo { +export interface LaunchInfo { LaunchPath: string; + MonoLaunchPath?: string; } export class OmnisharpManager { @@ -19,33 +20,34 @@ export class OmnisharpManager { private platformInfo: PlatformInformation) { } - public async GetOmnisharpPath(omnisharpPath: string, useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + public async GetOmniSharpLaunchInfo(omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { // Looks at the options path, installs the dependencies and returns the path to be loaded by the omnisharp server if (path.isAbsolute(omnisharpPath)) { - if (await util.fileExists(omnisharpPath)) { - return { LaunchPath: omnisharpPath }; - } - else { + if (!await util.fileExists(omnisharpPath)) { throw new Error('The system could not find the specified path'); } + + return { + LaunchPath: omnisharpPath + }; } - else if (omnisharpPath == "latest") { - return await this.InstallLatestAndReturnLaunchPath(useMono, serverUrl, latestVersionFileServerPath, installPath, extensionPath); + else if (omnisharpPath === 'latest') { + return await this.InstallLatestAndReturnLaunchPath(serverUrl, latestVersionFileServerPath, installPath, extensionPath); } - //If the path is neither a valid path on disk not the string "latest", treat it as a version - return await this.InstallVersionAndReturnLaunchPath(omnisharpPath, useMono, serverUrl, installPath, extensionPath); + // If the path is neither a valid path on disk not the string "latest", treat it as a version + return await this.InstallVersionAndReturnLaunchPath(omnisharpPath, serverUrl, installPath, extensionPath); } - private async InstallLatestAndReturnLaunchPath(useMono: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + private async InstallLatestAndReturnLaunchPath(serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { let version = await this.downloader.GetLatestVersion(serverUrl, latestVersionFileServerPath); - return await this.InstallVersionAndReturnLaunchPath(version, useMono, serverUrl, installPath, extensionPath); + return await this.InstallVersionAndReturnLaunchPath(version, serverUrl, installPath, extensionPath); } - private async InstallVersionAndReturnLaunchPath(version: string, useMono: boolean, serverUrl: string, installPath: string, extensionPath: string) { + private async InstallVersionAndReturnLaunchPath(version: string, serverUrl: string, installPath: string, extensionPath: string): Promise { if (semver.valid(version)) { await this.downloader.DownloadAndInstallOmnisharp(version, serverUrl, installPath); - return GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath, useMono); + return GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath); } else { throw new Error(`Invalid OmniSharp version - ${version}`); @@ -53,7 +55,7 @@ export class OmnisharpManager { } } -function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string, useMono: boolean): OmniSharpLaunchInfo { +function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string): LaunchInfo { if (!version) { throw new Error('Invalid Version'); } @@ -61,12 +63,13 @@ function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: str let basePath = path.resolve(extensionPath, installPath, version); if (platformInfo.isWindows()) { - return { LaunchPath: path.join(basePath, 'OmniSharp.exe') }; - } - if (useMono) { - return { LaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe') }; + return { + LaunchPath: path.join(basePath, 'OmniSharp.exe') + }; } - return { LaunchPath: path.join(basePath, 'run') }; -} - + return { + LaunchPath: path.join(basePath, 'run'), + MonoLaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe') + }; +} \ No newline at end of file diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index bdf611743f..ca4889386a 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -10,7 +10,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as util from '../common'; import { Options } from './options'; -import { OmniSharpLaunchInfo } from './OmnisharpManager'; +import { LaunchInfo } from './OmnisharpManager'; export enum LaunchTargetKind { Solution, @@ -205,7 +205,7 @@ export interface LaunchResult { usingMono: boolean; } -export async function launchOmniSharp(cwd: string, args: string[], launchInfo: OmniSharpLaunchInfo): Promise { +export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo): Promise { return new Promise((resolve, reject) => { launch(cwd, args, launchInfo) .then(result => { @@ -223,7 +223,7 @@ export async function launchOmniSharp(cwd: string, args: string[], launchInfo: O }); } -async function launch(cwd: string, args: string[], launchInfo: OmniSharpLaunchInfo): Promise { +async function launch(cwd: string, args: string[], launchInfo: LaunchInfo): Promise { return PlatformInformation.GetCurrent().then(platformInfo => { const options = Options.Read(); diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index af0a491770..7488dc7f66 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -15,7 +15,7 @@ import { ReadLine, createInterface } from 'readline'; import { Request, RequestQueueCollection } from './requestQueue'; import { DelayTracker } from './delayTracker'; import { EventEmitter } from 'events'; -import { OmnisharpManager, OmniSharpLaunchInfo } from './OmnisharpManager'; +import { OmnisharpManager, LaunchInfo } from './OmnisharpManager'; import { Options } from './options'; import { PlatformInformation } from '../platform'; import { launchOmniSharp } from './launcher'; @@ -312,11 +312,11 @@ export class OmniSharpServer { args.push('--debug'); } - let launchInfo: OmniSharpLaunchInfo; + let launchInfo: LaunchInfo; if (this._options.path) { try { let extensionPath = utils.getExtensionPath(); - launchInfo = await this._omnisharpManager.GetOmnisharpPath(this._options.path, this._options.useMono, serverUrl, latestVersionFileServerPath, installPath, extensionPath); + launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath); } catch (error) { this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error)); diff --git a/test/featureTests/OmnisharpManager.test.ts b/test/featureTests/OmnisharpManager.test.ts index 5f7a0c2aeb..27ae0e61b0 100644 --- a/test/featureTests/OmnisharpManager.test.ts +++ b/test/featureTests/OmnisharpManager.test.ts @@ -23,7 +23,6 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin const serverUrl = "https://roslynomnisharp.blob.core.windows.net"; const installPath = ".omnisharp/experimental"; const versionFilepathInServer = "releases/testVersionInfo.txt"; - const useMono = false; const eventStream = new EventStream(); const manager = GetTestOmnisharpManager(eventStream, platformInfo); let extensionPath: string; @@ -39,58 +38,53 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin }); test('Throws error if the path is neither an absolute path nor a valid semver, nor the string "latest"', async () => { - expect(manager.GetOmnisharpPath("Some incorrect path", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo("Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is null', async () => { - expect(manager.GetOmnisharpPath(null, useMono, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo(null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is empty', async () => { - expect(manager.GetOmnisharpPath("", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo("", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is an invalid semver', async () => { - expect(manager.GetOmnisharpPath("a.b.c", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo("a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Returns the same path if absolute path to an existing file is passed', async () => { tmpFile = tmp.fileSync(); - let launchInfo = await manager.GetOmnisharpPath(tmpFile.name, useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo(tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(tmpFile.name); }); test('Installs the latest version and returns the launch path based on the version and platform', async () => { - let launchInfo = await manager.GetOmnisharpPath("latest", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo("latest", serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); }); test('Installs the test version and returns the launch path based on the version and platform', async () => { - let launchInfo = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); }); test('Downloads package from given url and installs them at the specified path', async () => { - await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); let exists = await util.fileExists(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/install_check_1.2.3.txt`)); exists.should.equal(true); }); - test('Downloads package and returns launch path based on platform - Not using mono on Linux ', async () => { + test('Downloads package and returns launch path based on platform - on Linux ', async () => { let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchInfo = await manager.GetOmnisharpPath("1.2.3", useMono, serverUrl, versionFilepathInServer, installPath, extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run')); - }); - - test('Downloads package and returns launch path based on platform - Using mono on Linux ', async () => { - let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchInfo = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe')); + launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe')); }); test('Downloads package and returns launch path based on install path ', async () => { let manager = GetTestOmnisharpManager(eventStream, platformInfo); - let launchInfo = await manager.GetOmnisharpPath("1.2.3", true, serverUrl, versionFilepathInServer, "installHere", extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe')); }); From 151df01cfb7a3704a6978b1d3f6f2fb9661b00e2 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 16:09:38 -0700 Subject: [PATCH 4/7] Refactor launcher and ensure that we launch on global Mono if possible --- src/observers/OmnisharpLoggerObserver.ts | 4 +- src/omnisharp/OmnisharpManager.ts | 46 +++--- src/omnisharp/launcher.ts | 135 +++++++----------- src/omnisharp/loggingEvents.ts | 2 +- src/omnisharp/server.ts | 22 ++- .../logging/OmnisharpLoggerObserver.test.ts | 8 +- 6 files changed, 96 insertions(+), 121 deletions(-) diff --git a/src/observers/OmnisharpLoggerObserver.ts b/src/observers/OmnisharpLoggerObserver.ts index 37ffdafc40..5a53f1268b 100644 --- a/src/observers/OmnisharpLoggerObserver.ts +++ b/src/observers/OmnisharpLoggerObserver.ts @@ -54,8 +54,8 @@ export class OmnisharpLoggerObserver extends BaseLoggerObserver { } private handleOmnisharpLaunch(event: OmnisharpLaunch) { - if (event.usingMono) { - this.logger.appendLine(`OmniSharp server started with Mono`); + if (event.monoVersion) { + this.logger.appendLine(`OmniSharp server started with Mono ${event.monoVersion}`); } else { this.logger.appendLine(`OmniSharp server started`); diff --git a/src/omnisharp/OmnisharpManager.ts b/src/omnisharp/OmnisharpManager.ts index 5074822a7d..5dbfedb153 100644 --- a/src/omnisharp/OmnisharpManager.ts +++ b/src/omnisharp/OmnisharpManager.ts @@ -21,6 +21,12 @@ export class OmnisharpManager { } public async GetOmniSharpLaunchInfo(omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + if (!omnisharpPath) { + // If omnisharpPath was not specified, return the default path. + let basePath = path.resolve(extensionPath, '.omnisharp'); + return this.GetLaunchInfo(this.platformInfo, basePath); + } + // Looks at the options path, installs the dependencies and returns the path to be loaded by the omnisharp server if (path.isAbsolute(omnisharpPath)) { if (!await util.fileExists(omnisharpPath)) { @@ -32,44 +38,48 @@ export class OmnisharpManager { }; } else if (omnisharpPath === 'latest') { - return await this.InstallLatestAndReturnLaunchPath(serverUrl, latestVersionFileServerPath, installPath, extensionPath); + return await this.InstallLatestAndReturnLaunchInfo(serverUrl, latestVersionFileServerPath, installPath, extensionPath); } // If the path is neither a valid path on disk not the string "latest", treat it as a version - return await this.InstallVersionAndReturnLaunchPath(omnisharpPath, serverUrl, installPath, extensionPath); + return await this.InstallVersionAndReturnLaunchInfo(omnisharpPath, serverUrl, installPath, extensionPath); } - private async InstallLatestAndReturnLaunchPath(serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + private async InstallLatestAndReturnLaunchInfo(serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { let version = await this.downloader.GetLatestVersion(serverUrl, latestVersionFileServerPath); - return await this.InstallVersionAndReturnLaunchPath(version, serverUrl, installPath, extensionPath); + return await this.InstallVersionAndReturnLaunchInfo(version, serverUrl, installPath, extensionPath); } - private async InstallVersionAndReturnLaunchPath(version: string, serverUrl: string, installPath: string, extensionPath: string): Promise { + private async InstallVersionAndReturnLaunchInfo(version: string, serverUrl: string, installPath: string, extensionPath: string): Promise { if (semver.valid(version)) { await this.downloader.DownloadAndInstallOmnisharp(version, serverUrl, installPath); - return GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath); + return this.GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath); } else { throw new Error(`Invalid OmniSharp version - ${version}`); } } -} -function GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string): LaunchInfo { - if (!version) { - throw new Error('Invalid Version'); + private GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string): LaunchInfo { + if (!version) { + throw new Error('Invalid Version'); + } + + let basePath = path.resolve(extensionPath, installPath, version); + + return this.GetLaunchInfo(platformInfo, basePath); } - let basePath = path.resolve(extensionPath, installPath, version); + private GetLaunchInfo(platformInfo: PlatformInformation, basePath: string): LaunchInfo { + if (platformInfo.isWindows()) { + return { + LaunchPath: path.join(basePath, 'OmniSharp.exe') + }; + } - if (platformInfo.isWindows()) { return { - LaunchPath: path.join(basePath, 'OmniSharp.exe') + LaunchPath: path.join(basePath, 'run'), + MonoLaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe') }; } - - return { - LaunchPath: path.join(basePath, 'run'), - MonoLaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe') - }; } \ No newline at end of file diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index ca4889386a..84d76f5a38 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -8,7 +8,6 @@ import { satisfies } from 'semver'; import { PlatformInformation } from '../platform'; import * as path from 'path'; import * as vscode from 'vscode'; -import * as util from '../common'; import { Options } from './options'; import { LaunchInfo } from './OmnisharpManager'; @@ -202,7 +201,7 @@ function isCake(resource: vscode.Uri): boolean { export interface LaunchResult { process: ChildProcess; command: string; - usingMono: boolean; + monoVersion?: string; } export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo): Promise { @@ -224,49 +223,41 @@ export async function launchOmniSharp(cwd: string, args: string[], launchInfo: L } async function launch(cwd: string, args: string[], launchInfo: LaunchInfo): Promise { - return PlatformInformation.GetCurrent().then(platformInfo => { - const options = Options.Read(); - - if (options.useEditorFormattingSettings) { - let globalConfig = vscode.workspace.getConfiguration(); - let csharpConfig = vscode.workspace.getConfiguration('[csharp]'); + const platformInfo = await PlatformInformation.GetCurrent(); + const options = Options.Read(); - args.push(`formattingOptions:useTabs=${!getConfigurationValue(globalConfig, csharpConfig, 'editor.insertSpaces', true)}`); - args.push(`formattingOptions:tabSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); - args.push(`formattingOptions:indentationSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); - } + if (options.useEditorFormattingSettings) { + let globalConfig = vscode.workspace.getConfiguration(); + let csharpConfig = vscode.workspace.getConfiguration('[csharp]'); - // If the user has provided an absolute path or the specified version has been installed successfully, we'll use the path. - if (launchInfo.LaunchPath) { - if (platformInfo.isWindows()) { - return launchWindows(launchInfo.LaunchPath, cwd, args); - } + args.push(`formattingOptions:useTabs=${!getConfigurationValue(globalConfig, csharpConfig, 'editor.insertSpaces', true)}`); + args.push(`formattingOptions:tabSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); + args.push(`formattingOptions:indentationSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); + } - // If we're launching on macOS/Linux, we have two possibilities: - // 1. Launch using Mono - // 2. Launch process directly (e.g. a 'run' script) - return options.useMono - ? launchNixMono(launchInfo.LaunchPath, cwd, args) - : launchNix(launchInfo.LaunchPath, cwd, args); - } + if (platformInfo.isWindows()) { + return launchWindows(launchInfo.LaunchPath, cwd, args); + } - // If the user has not provided a path, we'll use the locally-installed OmniSharp - const basePath = path.resolve(util.getExtensionPath(), '.omnisharp'); + let monoVersion = await getMonoVersion(); + let isValidMonoAvailable = await satisfies(monoVersion, '>=5.2.0'); - if (platformInfo.isWindows()) { - return launchWindows(path.join(basePath, 'OmniSharp.exe'), cwd, args); + // If the user specifically said that they wanted to launch on Mono, respect their wishes. + if (options.useMono) { + if (!isValidMonoAvailable) { + throw new Error('Cannot start OmniSharp because Mono version >=5.2.0 is required.'); } - // If it's possible to launch on a global Mono, we'll do that. Otherwise, run with our - // locally installed Mono runtime. - return canLaunchMono() - .then(async () => { - return launchNixMono(path.join(basePath, 'omnisharp', 'OmniSharp.exe'), cwd, args); - }) - .catch(_ => { - return launchNix(path.join(basePath, 'run'), cwd, args); - }); - }); + return launchNixMono(launchInfo.LaunchPath, monoVersion, cwd, args); + } + + // If we can launch on the global Mono, do so; otherwise, launch directly; + if (isValidMonoAvailable && launchInfo.MonoLaunchPath) { + return launchNixMono(launchInfo.MonoLaunchPath, monoVersion, cwd, args); + } + else { + return launchNix(launchInfo.LaunchPath, cwd, args); + } } function getConfigurationValue(globalConfig: vscode.WorkspaceConfiguration, csharpConfig: vscode.WorkspaceConfiguration, @@ -304,7 +295,6 @@ function launchWindows(launchPath: string, cwd: string, args: string[]): LaunchR return { process, command: launchPath, - usingMono: false }; } @@ -316,58 +306,41 @@ function launchNix(launchPath: string, cwd: string, args: string[]): LaunchResul return { process, - command: launchPath, - usingMono: true + command: launchPath }; } -async function launchNixMono(launchPath: string, cwd: string, args: string[]): Promise { - return canLaunchMono() - .then(() => { - let argsCopy = args.slice(0); // create copy of details args - argsCopy.unshift(launchPath); - argsCopy.unshift("--assembly-loader=strict"); - - let process = spawn('mono', argsCopy, { - detached: false, - cwd: cwd - }); - - return { - process, - command: launchPath, - usingMono: true - }; - }); -} +function launchNixMono(launchPath: string, monoVersion: string, cwd: string, args: string[]): LaunchResult { + let argsCopy = args.slice(0); // create copy of details args + argsCopy.unshift(launchPath); + argsCopy.unshift("--assembly-loader=strict"); -async function canLaunchMono(): Promise { - return new Promise((resolve, reject) => { - hasMono('>=5.2.0').then(success => { - if (success) { - resolve(); - } - else { - reject(new Error('Cannot start Omnisharp because Mono version >=5.2.0 is required.')); - } - }); + let process = spawn('mono', argsCopy, { + detached: false, + cwd: cwd }); + + return { + process, + command: launchPath, + monoVersion, + }; } -export async function hasMono(range?: string): Promise { +async function getMonoVersion(): Promise { const versionRegexp = /(\d+\.\d+\.\d+)/; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let childprocess: ChildProcess; try { childprocess = spawn('mono', ['--version']); } catch (e) { - return resolve(false); + return resolve(undefined); } childprocess.on('error', function (err: any) { - resolve(false); + resolve(undefined); }); let stdout = ''; @@ -376,20 +349,14 @@ export async function hasMono(range?: string): Promise { }); childprocess.stdout.on('close', () => { - let match = versionRegexp.exec(stdout), - ret: boolean; + let match = versionRegexp.exec(stdout); - if (!match) { - ret = false; - } - else if (!range) { - ret = true; + if (match && match.length > 1) { + resolve(match[1]); } else { - ret = satisfies(match[1], range); + resolve(undefined); } - - resolve(ret); }); }); } \ No newline at end of file diff --git a/src/omnisharp/loggingEvents.ts b/src/omnisharp/loggingEvents.ts index 5eda58ff41..0a7f70fa67 100644 --- a/src/omnisharp/loggingEvents.ts +++ b/src/omnisharp/loggingEvents.ts @@ -27,7 +27,7 @@ export class OmnisharpInitialisation implements BaseEvent { } export class OmnisharpLaunch implements BaseEvent { - constructor(public usingMono: boolean, public command: string, public pid: number) { } + constructor(public monoVersion: string, public command: string, public pid: number) { } } export class PackageInstallation implements BaseEvent { diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 7488dc7f66..3a98b2e4ac 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -313,24 +313,22 @@ export class OmniSharpServer { } let launchInfo: LaunchInfo; - if (this._options.path) { - try { - let extensionPath = utils.getExtensionPath(); - launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath); - } - catch (error) { - this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error)); - return; - } + try { + let extensionPath = utils.getExtensionPath(); + launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath); + } + catch (error) { + this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error)); + return; } this.eventStream.post(new ObservableEvents.OmnisharpInitialisation(new Date(), solutionPath)); this._fireEvent(Events.BeforeServerStart, solutionPath); - return launchOmniSharp(cwd, args, launchInfo).then(async value => { - this.eventStream.post(new ObservableEvents.OmnisharpLaunch(value.usingMono, value.command, value.process.pid)); + return launchOmniSharp(cwd, args, launchInfo).then(async launchResult => { + this.eventStream.post(new ObservableEvents.OmnisharpLaunch(launchResult.monoVersion, launchResult.command, launchResult.process.pid)); - this._serverProcess = value.process; + this._serverProcess = launchResult.process; this._delayTrackers = {}; this._setState(ServerState.Started); this._fireEvent(Events.ServerStart, solutionPath); diff --git a/test/unitTests/logging/OmnisharpLoggerObserver.test.ts b/test/unitTests/logging/OmnisharpLoggerObserver.test.ts index e8e63a72ac..25a6012684 100644 --- a/test/unitTests/logging/OmnisharpLoggerObserver.test.ts +++ b/test/unitTests/logging/OmnisharpLoggerObserver.test.ts @@ -135,8 +135,8 @@ suite("OmnisharpLoggerObserver", () => { suite('OmnisharpLaunch', () => { [ - new OmnisharpLaunch(true, "someCommand", 4), - new OmnisharpLaunch(false, "someCommand", 4) + new OmnisharpLaunch("5.8.0", "someCommand", 4), + new OmnisharpLaunch(undefined, "someCommand", 4) ].forEach((event: OmnisharpLaunch) => { test(`Command and Pid are displayed`, () => { @@ -147,8 +147,8 @@ suite("OmnisharpLoggerObserver", () => { test(`Message is displayed depending on usingMono value`, () => { observer.post(event); - if (event.usingMono) { - expect(logOutput).to.contain("OmniSharp server started with Mono"); + if (event.monoVersion) { + expect(logOutput).to.contain("OmniSharp server started with Mono 5.8.0"); } else { expect(logOutput).to.contain("OmniSharp server started"); From 22fa49f070029d9aa6068eddd6fd31bd5f639b8d Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 17:57:11 -0700 Subject: [PATCH 5/7] Improve coverage a bit --- test/featureTests/OmnisharpManager.test.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/featureTests/OmnisharpManager.test.ts b/test/featureTests/OmnisharpManager.test.ts index 27ae0e61b0..9f2e7c8412 100644 --- a/test/featureTests/OmnisharpManager.test.ts +++ b/test/featureTests/OmnisharpManager.test.ts @@ -5,7 +5,7 @@ import * as path from 'path'; import * as util from '../../src/common'; -import { should } from "chai"; +import { expect, should } from "chai"; import { PlatformInformation } from "../../src/platform"; import { rimraf } from 'async-file'; import { OmnisharpManager } from '../../src/omnisharp/OmnisharpManager'; @@ -14,7 +14,6 @@ import { GetTestOmnisharpDownloader } from './testAssets/testAssets'; const chai = require("chai"); chai.use(require("chai-as-promised")); -let expect = chai.expect; const tmp = require('tmp'); @@ -53,6 +52,19 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin expect(manager.GetOmniSharpLaunchInfo("a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); + test('Returns default paths if no path is specified', async () => { + let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe')); + expect(launchInfo.MonoLaunchPath).to.be.undefined; + }); + + test('Returns default paths if no path is specified - Linux ', async () => { + let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); + let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/run')); + launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe')); + }); + test('Returns the same path if absolute path to an existing file is passed', async () => { tmpFile = tmp.fileSync(); let launchInfo = await manager.GetOmniSharpLaunchInfo(tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath); @@ -62,11 +74,13 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin test('Installs the latest version and returns the launch path based on the version and platform', async () => { let launchInfo = await manager.GetOmniSharpLaunchInfo("latest", serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + expect(launchInfo.MonoLaunchPath).to.be.undefined; }); test('Installs the test version and returns the launch path based on the version and platform', async () => { let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + expect(launchInfo.MonoLaunchPath).to.be.undefined; }); test('Downloads package from given url and installs them at the specified path', async () => { @@ -86,6 +100,7 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin let manager = GetTestOmnisharpManager(eventStream, platformInfo); let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe')); + expect(launchInfo.MonoLaunchPath).to.be.undefined; }); teardown(async () => { From 055652f8e1d04c2d086dcf0be0001fc1a110ce41 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 18:10:49 -0700 Subject: [PATCH 6/7] Use async/await in OmniSharpServer._start() --- src/omnisharp/server.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 3a98b2e4ac..510bf5904e 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -325,7 +325,8 @@ export class OmniSharpServer { this.eventStream.post(new ObservableEvents.OmnisharpInitialisation(new Date(), solutionPath)); this._fireEvent(Events.BeforeServerStart, solutionPath); - return launchOmniSharp(cwd, args, launchInfo).then(async launchResult => { + try { + let launchResult = await launchOmniSharp(cwd, args, launchInfo); this.eventStream.post(new ObservableEvents.OmnisharpLaunch(launchResult.monoVersion, launchResult.command, launchResult.process.pid)); this._serverProcess = launchResult.process; @@ -333,16 +334,15 @@ export class OmniSharpServer { this._setState(ServerState.Started); this._fireEvent(Events.ServerStart, solutionPath); - return this._doConnect(); - }).then(() => { - // Start telemetry reporting + await this._doConnect(); + this._telemetryIntervalId = setInterval(() => this._reportTelemetry(), TelemetryReportingDelay); - }).then(() => { this._requestQueue.drain(); - }).catch(async err => { + } + catch (err) { this._fireEvent(Events.ServerError, err); return this.stop(); - }); + } } private debounceUpdateProjectWithLeadingTrue = () => { From 3a0fc139f2cdfc45964c3d49c06ffd2cca89d2a4 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Wed, 25 Apr 2018 18:16:35 -0700 Subject: [PATCH 7/7] Fix test --- test/featureTests/OmnisharpManager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/featureTests/OmnisharpManager.test.ts b/test/featureTests/OmnisharpManager.test.ts index 9f2e7c8412..edbe7ae757 100644 --- a/test/featureTests/OmnisharpManager.test.ts +++ b/test/featureTests/OmnisharpManager.test.ts @@ -54,7 +54,7 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin test('Returns default paths if no path is specified', async () => { let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe')); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/OmniSharp.exe')); expect(launchInfo.MonoLaunchPath).to.be.undefined; });