-
Notifications
You must be signed in to change notification settings - Fork 677
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
Enable multiple download of omnisharp #2065
Conversation
…ns of omnisharp (#2028) * Enable usage of multiple versions * Either load the server from a path or download the version packages * Tests for the package creator * Added null check and removed semver check in package creator * Test for the experiment omnisharp downloader * Added test for package manager * Code clean up * Added null or empty check for version * Changes * Modified the description Put the clean up logic in the teardown function * Remove comment * Remove unnecessary usage * CR comments * Removed experimental * Modified launcher * Removed experimental * Modified tests * Modified package description to include version information * Renamed launch path * Add more tests * Changed the description in package.json
* Enable usage of multiple versions * Either load the server from a path or download the version packages * Tests for the package creator * Added null check and removed semver check in package creator * Test for the experiment omnisharp downloader * Added test for package manager * Code clean up * Added null or empty check for version * Changes * Modified the description * Put the clean up logic in the teardown function * Remove comment * Remove unnecessary usage * CR comments * Removed experimental * Modified launcher * Removed experimental * Modified tests * Modified package description to include version information * Renamed launch path * Add more tests * Changed the description in package.json * Getting latest version info * Refactored code and added tests * Remove unnecessary using * CR comments * Use common function for latest download * Add new line * Resolve binaries on linux
package.json
Outdated
@@ -39,6 +39,7 @@ | |||
"postinstall": "node ./node_modules/vscode/bin/install" | |||
}, | |||
"dependencies": { | |||
"chai-as-promised": "^7.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a dev dependency only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is automatically added when I npm install the package. What do you think should be changed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just move this dependency in the devdependecies list and fix it to 7.1.1 instead of compatible versions
package.json
Outdated
@@ -93,7 +94,8 @@ | |||
"architectures": [ | |||
"x86" | |||
], | |||
"installTestPath": "./.omnisharp/OmniSharp.exe" | |||
"installTestPath": "./.omnisharp/OmniSharp.exe", | |||
"experimentalPackageId": "win-x86" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename experimentalPackageId
to platformId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks pretty good. There's probably some stuff we can clean up later. I made a couple of comments--fix those up and I think we're good to go.
src/OmnisharpDownload.Helper.ts
Outdated
installationStage = ''; | ||
logger.appendLine('Finished'); | ||
|
||
statusItem.dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems weird that this method takes statusItem just to call dispose on it.
if (platformInfo.distribution) { | ||
telemetryProps['platform.distribution'] = platformInfo.distribution.toTelemetryString(); | ||
} | ||
if (reporter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is reporter ever null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think so. But I just followed by the pattern followed by CSharpExtDownloader.
Currently this pattern helps because in testing I am conveniently passing this field as null, but in future we might want to test the Telemetry as well.
For the current PR, I think we can retain this pattern. What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can refactor later.
src/omnisharp/OmnisharpDownloader.ts
Outdated
|
||
public async DownloadAndInstallOmnisharp(version: string, serverUrl: string, installPath: string) { | ||
if (!version) { | ||
throw new Error('Invalid version'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this happens, this is basically a bug in our code, right? Since this method is not expecting a null version. "invalid version" makes it sound like a user mistake, which it isn't.
src/omnisharp/OmnisharpManager.ts
Outdated
} | ||
} | ||
else if (omnisharpPath == "latest") { | ||
return await this.LatestInstallAndReturnLaunchPath(downloader, useMono, serverUrl, versionFilePathInServer, installPath, extensionPath, platformInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this method InstallLatestAndReturnLaunchPath
src/omnisharp/OmnisharpManager.ts
Outdated
return GetLaunchPathForVersion(platformInfo, version, installPath, extensionPath, useMono); | ||
} | ||
else { | ||
throw new Error('Invalid omnisharp version specified'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include the specified version in this message?
|
||
let basePath = path.resolve(extensionPath, installPath, version); | ||
|
||
if (platformInfo.isWindows()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
platformInfo.isWindows() || useMono
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, in case of useMono we append an extra "omnisharp" to the path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
throw new Error('Invalid version'); | ||
} | ||
|
||
let versionPackage = <Package>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the ...
operator and just change the fields you care about?
{...package, url = zzz, experimentalPackageId = xxx
Means the same thing, but might be easier to tell what fields you're changing.
src/omnisharp/server.ts
Outdated
let launchPath: string; | ||
if (this._options.path) { | ||
try { | ||
let serverUrl = "https://roslynomnisharp.blob.core.windows.net"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move these into some obvious constant definitions somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you suggest can these be moved? Should we define some object that contains these fields in the package.json and just read from it here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just move them up to be const fields in server.ts
src/packages.ts
Outdated
@@ -24,6 +24,7 @@ export interface Package { | |||
architectures: string[]; | |||
binaries: string[]; | |||
tmpFile: tmp.SynchrounousResult; | |||
experimentalPackageId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to whatever name Peter came up with :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename the experimentalPackageId. Otherwise lgtm.
…nisharp-vscode into experiment_download
Fixes: #1909
Final PR including all the changes.